Commit de063bcc authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert VibrationManager to new Mojo types

This CL converts VibrationManager{Ptr, Request} in services and
blink to the new Mojo type.

Bug: 955171, 978694
Change-Id: Idaa3a0cdd1c3feec0868f14df93cd71f93fe9fa0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810448Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#697968}
parent 0c0f34a2
......@@ -186,7 +186,7 @@ void DeviceService::OnStart() {
registry_.AddInterface<mojom::NFCProvider>(base::Bind(
&DeviceService::BindNFCProviderReceiver, base::Unretained(this)));
registry_.AddInterface<mojom::VibrationManager>(base::Bind(
&DeviceService::BindVibrationManagerRequest, base::Unretained(this)));
&DeviceService::BindVibrationManagerReceiver, base::Unretained(this)));
#endif
#if (defined(OS_LINUX) && defined(USE_UDEV)) || defined(OS_WIN) || \
......@@ -248,9 +248,9 @@ void DeviceService::BindNFCProviderReceiver(
NOTREACHED();
}
void DeviceService::BindVibrationManagerRequest(
mojom::VibrationManagerRequest request) {
VibrationManagerImpl::Create(std::move(request));
void DeviceService::BindVibrationManagerReceiver(
mojo::PendingReceiver<mojom::VibrationManager> receiver) {
VibrationManagerImpl::Create(std::move(receiver));
}
#endif
......
......@@ -158,7 +158,8 @@ class DeviceService : public service_manager::Service {
mojo::PendingReceiver<mojom::HidManager> receiver);
void BindNFCProviderReceiver(
mojo::PendingReceiver<mojom::NFCProvider> receiver);
void BindVibrationManagerRequest(mojom::VibrationManagerRequest request);
void BindVibrationManagerReceiver(
mojo::PendingReceiver<mojom::VibrationManager> receiver);
#endif
#if defined(OS_CHROMEOS)
......
......@@ -5,13 +5,14 @@
#ifndef SERVICES_DEVICE_VIBRATION_VIBRATION_MANAGER_IMPL_H_
#define SERVICES_DEVICE_VIBRATION_VIBRATION_MANAGER_IMPL_H_
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/device/public/mojom/vibration_manager.mojom.h"
namespace device {
class VibrationManagerImpl {
public:
static void Create(mojo::InterfaceRequest<mojom::VibrationManager> request);
static void Create(mojo::PendingReceiver<mojom::VibrationManager> receiver);
static int64_t milli_seconds_for_testing_;
static bool cancelled_for_testing_;
......
......@@ -7,7 +7,7 @@
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace device {
......@@ -35,9 +35,10 @@ class VibrationManagerEmptyImpl : public mojom::VibrationManager {
} // namespace
// static
void VibrationManagerImpl::Create(mojom::VibrationManagerRequest request) {
mojo::MakeStrongBinding(std::make_unique<VibrationManagerEmptyImpl>(),
std::move(request));
void VibrationManagerImpl::Create(
mojo::PendingReceiver<mojom::VibrationManager> receiver) {
mojo::MakeSelfOwnedReceiver(std::make_unique<VibrationManagerEmptyImpl>(),
std::move(receiver));
}
} // namespace device
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/run_loop.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/device_service_test_base.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/device/public/mojom/vibration_manager.mojom.h"
......@@ -27,7 +28,8 @@ class VibrationManagerImplTest : public DeviceServiceTestBase {
void SetUp() override {
DeviceServiceTestBase::SetUp();
connector()->BindInterface(mojom::kServiceName, &vibration_manager_);
connector()->Connect(mojom::kServiceName,
vibration_manager_.BindNewPipeAndPassReceiver());
}
void Vibrate(int64_t milliseconds) {
......@@ -61,7 +63,7 @@ class VibrationManagerImplTest : public DeviceServiceTestBase {
}
private:
mojom::VibrationManagerPtr vibration_manager_;
mojo::Remote<mojom::VibrationManager> vibration_manager_;
DISALLOW_COPY_AND_ASSIGN(VibrationManagerImplTest);
};
......
......@@ -86,7 +86,7 @@ VibrationController::VibrationController(LocalFrame& frame)
is_calling_cancel_(false),
is_calling_vibrate_(false) {
frame.GetInterfaceProvider().GetInterface(
mojo::MakeRequest(&vibration_manager_));
vibration_manager_.BindNewPipeAndPassReceiver());
}
VibrationController::~VibrationController() = default;
......
......@@ -21,6 +21,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_VIBRATION_VIBRATION_CONTROLLER_H_
#include "base/macros.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/vibration_manager.mojom-blink.h"
#include "third_party/blink/renderer/core/execution_context/context_lifecycle_observer.h"
#include "third_party/blink/renderer/core/page/page_visibility_observer.h"
......@@ -73,9 +74,9 @@ class MODULES_EXPORT VibrationController final
// Inherited from PageVisibilityObserver.
void PageVisibilityChanged() override;
// Ptr to VibrationManager mojo interface. This is reset in |contextDestroyed|
// and must not be called or recreated after it is reset.
device::mojom::blink::VibrationManagerPtr vibration_manager_;
// Remote to VibrationManager mojo interface. This is reset in
// |contextDestroyed| and must not be called or recreated after it is reset.
mojo::Remote<device::mojom::blink::VibrationManager> vibration_manager_;
// Timer for calling |doVibrate| after a delay. It is safe to call
// |startOneshot| when the timer is already running: it may affect the time
......
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