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 @@ ...@@ -11,6 +11,7 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/public/renderer/render_frame.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/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_local_frame.h"
...@@ -31,7 +32,7 @@ void MockScreenOrientationClient::ResetData() { ...@@ -31,7 +32,7 @@ void MockScreenOrientationClient::ResetData() {
device_orientation_ = blink::kWebScreenOrientationPortraitPrimary; device_orientation_ = blink::kWebScreenOrientationPortraitPrimary;
current_orientation_ = blink::kWebScreenOrientationPortraitPrimary; current_orientation_ = blink::kWebScreenOrientationPortraitPrimary;
is_disabled_ = false; is_disabled_ = false;
bindings_.CloseAllBindings(); receivers_.Clear();
} }
void MockScreenOrientationClient::UpdateDeviceOrientation( void MockScreenOrientationClient::UpdateDeviceOrientation(
...@@ -119,10 +120,11 @@ bool MockScreenOrientationClient::IsOrientationAllowedByCurrentLock( ...@@ -119,10 +120,11 @@ bool MockScreenOrientationClient::IsOrientationAllowedByCurrentLock(
} }
} }
void MockScreenOrientationClient::AddBinding( void MockScreenOrientationClient::AddReceiver(
mojo::ScopedInterfaceEndpointHandle handle) { mojo::ScopedInterfaceEndpointHandle handle) {
bindings_.AddBinding(this, device::mojom::ScreenOrientationAssociatedRequest( receivers_.Add(
std::move(handle))); this, mojo::PendingAssociatedReceiver<device::mojom::ScreenOrientation>(
std::move(handle)));
} }
void MockScreenOrientationClient::OverrideAssociatedInterfaceProviderForFrame( void MockScreenOrientationClient::OverrideAssociatedInterfaceProviderForFrame(
...@@ -137,7 +139,7 @@ void MockScreenOrientationClient::OverrideAssociatedInterfaceProviderForFrame( ...@@ -137,7 +139,7 @@ void MockScreenOrientationClient::OverrideAssociatedInterfaceProviderForFrame(
provider->OverrideBinderForTesting( provider->OverrideBinderForTesting(
device::mojom::ScreenOrientation::Name_, device::mojom::ScreenOrientation::Name_,
base::BindRepeating(&MockScreenOrientationClient::AddBinding, base::BindRepeating(&MockScreenOrientationClient::AddReceiver,
base::Unretained(this))); base::Unretained(this)));
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "content/shell/test_runner/test_runner_export.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 "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "services/device/public/mojom/screen_orientation.mojom.h" #include "services/device/public/mojom/screen_orientation.mojom.h"
#include "third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h" #include "third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h"
...@@ -37,7 +37,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient ...@@ -37,7 +37,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient
bool IsDisabled() const { return is_disabled_; } bool IsDisabled() const { return is_disabled_; }
void SetDisabled(bool disabled); void SetDisabled(bool disabled);
void AddBinding(mojo::ScopedInterfaceEndpointHandle handle); void AddReceiver(mojo::ScopedInterfaceEndpointHandle handle);
void OverrideAssociatedInterfaceProviderForFrame(blink::WebLocalFrame* frame); void OverrideAssociatedInterfaceProviderForFrame(blink::WebLocalFrame* frame);
// device::mojom::ScreenOrientation implementation. // device::mojom::ScreenOrientation implementation.
...@@ -60,7 +60,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient ...@@ -60,7 +60,7 @@ class TEST_RUNNER_EXPORT MockScreenOrientationClient
blink::WebScreenOrientationType device_orientation_; blink::WebScreenOrientationType device_orientation_;
blink::WebScreenOrientationType current_orientation_; blink::WebScreenOrientationType current_orientation_;
bool is_disabled_; bool is_disabled_;
mojo::AssociatedBindingSet<device::mojom::ScreenOrientation> bindings_; mojo::AssociatedReceiverSet<device::mojom::ScreenOrientation> receivers_;
DISALLOW_COPY_AND_ASSIGN(MockScreenOrientationClient); DISALLOW_COPY_AND_ASSIGN(MockScreenOrientationClient);
}; };
......
...@@ -156,7 +156,7 @@ void DeviceService::OnStart() { ...@@ -156,7 +156,7 @@ void DeviceService::OnStart() {
base::Bind(&DeviceService::BindPublicIpAddressGeolocationProviderReceiver, base::Bind(&DeviceService::BindPublicIpAddressGeolocationProviderReceiver,
base::Unretained(this))); base::Unretained(this)));
registry_.AddInterface<mojom::ScreenOrientationListener>( registry_.AddInterface<mojom::ScreenOrientationListener>(
base::Bind(&DeviceService::BindScreenOrientationListenerRequest, base::Bind(&DeviceService::BindScreenOrientationListenerReceiver,
base::Unretained(this))); base::Unretained(this)));
registry_.AddInterface<mojom::SensorProvider>(base::Bind( registry_.AddInterface<mojom::SensorProvider>(base::Bind(
&DeviceService::BindSensorProviderRequest, base::Unretained(this))); &DeviceService::BindSensorProviderRequest, base::Unretained(this)));
...@@ -318,13 +318,13 @@ void DeviceService::BindPublicIpAddressGeolocationProviderReceiver( ...@@ -318,13 +318,13 @@ void DeviceService::BindPublicIpAddressGeolocationProviderReceiver(
public_ip_address_geolocation_provider_->Bind(std::move(receiver)); public_ip_address_geolocation_provider_->Bind(std::move(receiver));
} }
void DeviceService::BindScreenOrientationListenerRequest( void DeviceService::BindScreenOrientationListenerReceiver(
mojom::ScreenOrientationListenerRequest request) { mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver) {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (io_task_runner_) { if (io_task_runner_) {
io_task_runner_->PostTask( io_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&ScreenOrientationListenerAndroid::Create, FROM_HERE, base::BindOnce(&ScreenOrientationListenerAndroid::Create,
std::move(request))); std::move(receiver)));
} }
#endif #endif
} }
......
...@@ -174,8 +174,8 @@ class DeviceService : public service_manager::Service { ...@@ -174,8 +174,8 @@ class DeviceService : public service_manager::Service {
mojo::PendingReceiver<mojom::PublicIpAddressGeolocationProvider> mojo::PendingReceiver<mojom::PublicIpAddressGeolocationProvider>
receiver); receiver);
void BindScreenOrientationListenerRequest( void BindScreenOrientationListenerReceiver(
mojom::ScreenOrientationListenerRequest request); mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver);
void BindSensorProviderRequest(mojom::SensorProviderRequest request); void BindSensorProviderRequest(mojom::SensorProviderRequest request);
......
...@@ -6,17 +6,17 @@ ...@@ -6,17 +6,17 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/message_loop/message_loop_current.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" #include "services/device/screen_orientation/screen_orientation_jni_headers/ScreenOrientationListener_jni.h"
namespace device { namespace device {
// static // static
void ScreenOrientationListenerAndroid::Create( void ScreenOrientationListenerAndroid::Create(
mojom::ScreenOrientationListenerRequest request) { mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver) {
mojo::MakeStrongBinding( mojo::MakeSelfOwnedReceiver(
base::WrapUnique(new ScreenOrientationListenerAndroid()), base::WrapUnique(new ScreenOrientationListenerAndroid()),
std::move(request)); std::move(receiver));
} }
ScreenOrientationListenerAndroid::ScreenOrientationListenerAndroid() = default; ScreenOrientationListenerAndroid::ScreenOrientationListenerAndroid() = default;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define SERVICES_DEVICE_SCREEN_ORIENTATION_SCREEN_ORIENTATION_LISTENER_ANDROID_H_ #define SERVICES_DEVICE_SCREEN_ORIENTATION_SCREEN_ORIENTATION_LISTENER_ANDROID_H_
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/device/public/mojom/screen_orientation.mojom.h" #include "services/device/public/mojom/screen_orientation.mojom.h"
namespace device { namespace device {
...@@ -13,7 +14,8 @@ namespace device { ...@@ -13,7 +14,8 @@ namespace device {
class ScreenOrientationListenerAndroid class ScreenOrientationListenerAndroid
: public mojom::ScreenOrientationListener { : public mojom::ScreenOrientationListener {
public: public:
static void Create(mojom::ScreenOrientationListenerRequest request); static void Create(
mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver);
~ScreenOrientationListenerAndroid() override; ~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