Commit 61ed25c3 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert ScreenOrientation and ScreenOrientationListener to new Mojo types

This CL converts ScreenOrientationRequest and
ScreenOrientationListenerRequest in services and content to the
new Mojo type.

Bug: 955171
Change-Id: I1317ef2f1c6693604026b14c25f05045a7da79cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809044Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#697617}
parent 6b970b43
......@@ -11,6 +11,7 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/public/renderer/render_frame.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/web/web_local_frame.h"
......@@ -31,7 +32,7 @@ void MockScreenOrientationClient::ResetData() {
device_orientation_ = blink::kWebScreenOrientationPortraitPrimary;
current_orientation_ = blink::kWebScreenOrientationPortraitPrimary;
is_disabled_ = false;
bindings_.CloseAllBindings();
receivers_.Clear();
}
void MockScreenOrientationClient::UpdateDeviceOrientation(
......@@ -119,9 +120,10 @@ bool MockScreenOrientationClient::IsOrientationAllowedByCurrentLock(
}
}
void MockScreenOrientationClient::AddBinding(
void MockScreenOrientationClient::AddReceiver(
mojo::ScopedInterfaceEndpointHandle handle) {
bindings_.AddBinding(this, device::mojom::ScreenOrientationAssociatedRequest(
receivers_.Add(
this, mojo::PendingAssociatedReceiver<device::mojom::ScreenOrientation>(
std::move(handle)));
}
......@@ -137,7 +139,7 @@ void MockScreenOrientationClient::OverrideAssociatedInterfaceProviderForFrame(
provider->OverrideBinderForTesting(
device::mojom::ScreenOrientation::Name_,
base::BindRepeating(&MockScreenOrientationClient::AddBinding,
base::BindRepeating(&MockScreenOrientationClient::AddReceiver,
base::Unretained(this)));
}
......
......@@ -10,7 +10,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "content/shell/test_runner/test_runner_export.h"
#include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "services/device/public/mojom/screen_orientation.mojom.h"
#include "third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h"
......@@ -37,7 +37,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient
bool IsDisabled() const { return is_disabled_; }
void SetDisabled(bool disabled);
void AddBinding(mojo::ScopedInterfaceEndpointHandle handle);
void AddReceiver(mojo::ScopedInterfaceEndpointHandle handle);
void OverrideAssociatedInterfaceProviderForFrame(blink::WebLocalFrame* frame);
// device::mojom::ScreenOrientation implementation.
......@@ -60,7 +60,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient
blink::WebScreenOrientationType device_orientation_;
blink::WebScreenOrientationType current_orientation_;
bool is_disabled_;
mojo::AssociatedBindingSet<device::mojom::ScreenOrientation> bindings_;
mojo::AssociatedReceiverSet<device::mojom::ScreenOrientation> receivers_;
DISALLOW_COPY_AND_ASSIGN(MockScreenOrientationClient);
};
......
......@@ -156,7 +156,7 @@ void DeviceService::OnStart() {
base::Bind(&DeviceService::BindPublicIpAddressGeolocationProviderReceiver,
base::Unretained(this)));
registry_.AddInterface<mojom::ScreenOrientationListener>(
base::Bind(&DeviceService::BindScreenOrientationListenerRequest,
base::Bind(&DeviceService::BindScreenOrientationListenerReceiver,
base::Unretained(this)));
registry_.AddInterface<mojom::SensorProvider>(base::Bind(
&DeviceService::BindSensorProviderRequest, base::Unretained(this)));
......@@ -318,13 +318,13 @@ void DeviceService::BindPublicIpAddressGeolocationProviderReceiver(
public_ip_address_geolocation_provider_->Bind(std::move(receiver));
}
void DeviceService::BindScreenOrientationListenerRequest(
mojom::ScreenOrientationListenerRequest request) {
void DeviceService::BindScreenOrientationListenerReceiver(
mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver) {
#if defined(OS_ANDROID)
if (io_task_runner_) {
io_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&ScreenOrientationListenerAndroid::Create,
std::move(request)));
std::move(receiver)));
}
#endif
}
......
......@@ -174,8 +174,8 @@ class DeviceService : public service_manager::Service {
mojo::PendingReceiver<mojom::PublicIpAddressGeolocationProvider>
receiver);
void BindScreenOrientationListenerRequest(
mojom::ScreenOrientationListenerRequest request);
void BindScreenOrientationListenerReceiver(
mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver);
void BindSensorProviderRequest(mojom::SensorProviderRequest request);
......
......@@ -6,17 +6,17 @@
#include "base/android/jni_android.h"
#include "base/message_loop/message_loop_current.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/device/screen_orientation/screen_orientation_jni_headers/ScreenOrientationListener_jni.h"
namespace device {
// static
void ScreenOrientationListenerAndroid::Create(
mojom::ScreenOrientationListenerRequest request) {
mojo::MakeStrongBinding(
mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver) {
mojo::MakeSelfOwnedReceiver(
base::WrapUnique(new ScreenOrientationListenerAndroid()),
std::move(request));
std::move(receiver));
}
ScreenOrientationListenerAndroid::ScreenOrientationListenerAndroid() = default;
......
......@@ -6,6 +6,7 @@
#define SERVICES_DEVICE_SCREEN_ORIENTATION_SCREEN_ORIENTATION_LISTENER_ANDROID_H_
#include "base/macros.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/device/public/mojom/screen_orientation.mojom.h"
namespace device {
......@@ -13,7 +14,8 @@ namespace device {
class ScreenOrientationListenerAndroid
: public mojom::ScreenOrientationListener {
public:
static void Create(mojom::ScreenOrientationListenerRequest request);
static void Create(
mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver);
~ScreenOrientationListenerAndroid() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment