Skip to content

Commit

Permalink
Migrate gesture_properties_service.mojom to the new Mojo types
Browse files Browse the repository at this point in the history
Convert the implementation and all users of the
ui::ozone::mojom::GesturePropertiesService interface.

Bug: 955171
Change-Id: I8a70b91624fef3f7e94e25e2f7071d85a4dec42a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864776
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Reviewed-by: Michael Spang <spang@chromium.org>
Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#708759}
  • Loading branch information
hferreiro authored and Commit Bot committed Oct 23, 2019
1 parent 84b4b23 commit 4d9ad32
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 24 deletions.
4 changes: 1 addition & 3 deletions ash/dbus/gesture_properties_service_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,9 @@ GesturePropertiesServiceProvider::GetService() {
return service_for_test_;

if (!service_.is_bound()) {
ui::ozone::mojom::GesturePropertiesServiceRequest request =
mojo::MakeRequest(&service_);
ui::OzonePlatform::GetInstance()
->GetInputController()
->GetGesturePropertiesService(std::move(request));
->GetGesturePropertiesService(service_.BindNewPipeAndPassReceiver());
}
return service_.get();
}
Expand Down
3 changes: 2 additions & 1 deletion ash/dbus/gesture_properties_service_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "chromeos/dbus/services/cros_dbus_service.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/ozone/public/mojom/gesture_properties_service.mojom.h"

namespace dbus {
Expand Down Expand Up @@ -65,7 +66,7 @@ class ASH_EXPORT GesturePropertiesServiceProvider

ui::ozone::mojom::GesturePropertiesService* GetService();

ui::ozone::mojom::GesturePropertiesServicePtr service_;
mojo::Remote<ui::ozone::mojom::GesturePropertiesService> service_;
ui::ozone::mojom::GesturePropertiesService* service_for_test_ = nullptr;

base::WeakPtrFactory<GesturePropertiesServiceProvider> weak_ptr_factory_;
Expand Down
2 changes: 1 addition & 1 deletion ui/events/ozone/DEPS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_rules = [
"+device/udev_linux",
"+mojo/public/cpp/bindings/binding.h",
"+mojo/public/cpp/bindings",
"+ui/ozone/public",
]
6 changes: 4 additions & 2 deletions ui/events/ozone/chromeos/gesture_properties_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "ui/events/ozone/chromeos/gesture_properties_service.h"

#include <utility>

namespace ui {

namespace {
Expand Down Expand Up @@ -66,8 +68,8 @@ bool TrySetPropertyValues(GesturesProp* property,

GesturePropertiesService::GesturePropertiesService(
GesturePropertyProvider* provider,
ozone::mojom::GesturePropertiesServiceRequest request)
: prop_provider_(provider), binding_(this, std::move(request)) {}
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver)
: prop_provider_(provider), receiver_(this, std::move(receiver)) {}

void GesturePropertiesService::ListDevices(ListDevicesCallback reply) {
base::flat_map<int, std::string> response = {};
Expand Down
8 changes: 5 additions & 3 deletions ui/events/ozone/chromeos/gesture_properties_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef UI_EVENTS_OZONE_CHROMEOS_GESTURE_PROPERTIES_SERVICE_H_
#define UI_EVENTS_OZONE_CHROMEOS_GESTURE_PROPERTIES_SERVICE_H_

#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h"
#include "ui/ozone/public/mojom/gesture_properties_service.mojom.h"
Expand All @@ -19,7 +20,8 @@ class EVENTS_OZONE_EVDEV_EXPORT GesturePropertiesService
public:
GesturePropertiesService(
GesturePropertyProvider* provider,
ui::ozone::mojom::GesturePropertiesServiceRequest request);
mojo::PendingReceiver<ui::ozone::mojom::GesturePropertiesService>
receiver);

void ListDevices(ListDevicesCallback callback) override;
void ListProperties(int32_t device_id,
Expand All @@ -34,7 +36,7 @@ class EVENTS_OZONE_EVDEV_EXPORT GesturePropertiesService

private:
GesturePropertyProvider* prop_provider_;
mojo::Binding<ui::ozone::mojom::GesturePropertiesService> binding_;
mojo::Receiver<ui::ozone::mojom::GesturePropertiesService> receiver_;
};

} // namespace ui
Expand Down
5 changes: 3 additions & 2 deletions ui/events/ozone/evdev/input_controller_evdev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/input.h>

#include <algorithm>
#include <utility>

#include "base/bind.h"
#include "base/callback.h"
Expand Down Expand Up @@ -189,9 +190,9 @@ void InputControllerEvdev::GetTouchEventLog(const base::FilePath& out_dir,
}

void InputControllerEvdev::GetGesturePropertiesService(
ozone::mojom::GesturePropertiesServiceRequest request) {
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver) {
if (input_device_factory_)
input_device_factory_->GetGesturePropertiesService(std::move(request));
input_device_factory_->GetGesturePropertiesService(std::move(receiver));
}

void InputControllerEvdev::ScheduleUpdateDeviceSettings() {
Expand Down
4 changes: 3 additions & 1 deletion ui/events/ozone/evdev/input_controller_evdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/ozone/evdev/input_device_settings_evdev.h"
#include "ui/ozone/public/input_controller.h"
Expand Down Expand Up @@ -70,7 +71,8 @@ class EVENTS_OZONE_EVDEV_EXPORT InputControllerEvdev : public InputController {
void SetInternalKeyboardFilter(bool enable_filter,
std::vector<DomCode> allowed_keys) override;
void GetGesturePropertiesService(
ozone::mojom::GesturePropertiesServiceRequest request) override;
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver)
override;

private:
// Post task to update settings.
Expand Down
4 changes: 2 additions & 2 deletions ui/events/ozone/evdev/input_device_factory_evdev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ void InputDeviceFactoryEvdev::GetTouchEventLog(
}

void InputDeviceFactoryEvdev::GetGesturePropertiesService(
ozone::mojom::GesturePropertiesServiceRequest request) {
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver) {
#if defined(USE_EVDEV_GESTURES)
gesture_properties_service_ = std::make_unique<GesturePropertiesService>(
gesture_property_provider_.get(), std::move(request));
gesture_property_provider_.get(), std::move(receiver));
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion ui/events/ozone/evdev/input_device_factory_evdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/task_runner.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/events/ozone/evdev/event_converter_evdev.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
Expand Down Expand Up @@ -68,7 +69,7 @@ class EVENTS_OZONE_EVDEV_EXPORT InputDeviceFactoryEvdev {
InputController::GetTouchEventLogReply reply);

void GetGesturePropertiesService(
ozone::mojom::GesturePropertiesServiceRequest request);
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver);

base::WeakPtr<InputDeviceFactoryEvdev> GetWeakPtr();

Expand Down
6 changes: 4 additions & 2 deletions ui/events/ozone/evdev/input_device_factory_evdev_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h"

#include <utility>

#include "base/bind.h"
#include "base/callback.h"
#include "base/threading/thread_task_runner_handle.h"
Expand Down Expand Up @@ -99,11 +101,11 @@ void InputDeviceFactoryEvdevProxy::GetTouchEventLog(
}

void InputDeviceFactoryEvdevProxy::GetGesturePropertiesService(
ozone::mojom::GesturePropertiesServiceRequest request) {
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver) {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&InputDeviceFactoryEvdev::GetGesturePropertiesService,
input_device_factory_, std::move(request)));
input_device_factory_, std::move(receiver)));
}

} // namespace ui
9 changes: 5 additions & 4 deletions ui/events/ozone/evdev/input_device_factory_evdev_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_PROXY_EVDEV_H_
#define UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_PROXY_EVDEV_H_
#ifndef UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_EVDEV_PROXY_H_
#define UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_EVDEV_PROXY_H_

#include <memory>
#include <set>
Expand All @@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/ozone/public/input_controller.h"

Expand Down Expand Up @@ -47,7 +48,7 @@ class EVENTS_OZONE_EVDEV_EXPORT InputDeviceFactoryEvdevProxy {
void GetTouchEventLog(const base::FilePath& out_dir,
InputController::GetTouchEventLogReply reply);
void GetGesturePropertiesService(
ozone::mojom::GesturePropertiesServiceRequest request);
mojo::PendingReceiver<ozone::mojom::GesturePropertiesService> receiver);

private:
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
Expand All @@ -58,4 +59,4 @@ class EVENTS_OZONE_EVDEV_EXPORT InputDeviceFactoryEvdevProxy {

} // namespace ui

#endif // UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_PROXY_EVDEV_H_
#endif // UI_EVENTS_OZONE_EVDEV_INPUT_DEVICE_FACTORY_EVDEV_PROXY_H_
3 changes: 2 additions & 1 deletion ui/ozone/public/input_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class StubInputController : public InputController {
void SetInternalKeyboardFilter(bool enable_filter,
std::vector<DomCode> allowed_keys) override {}
void GetGesturePropertiesService(
ui::ozone::mojom::GesturePropertiesServiceRequest request) override {}
mojo::PendingReceiver<ui::ozone::mojom::GesturePropertiesService>
receiver) override {}

private:
DISALLOW_COPY_AND_ASSIGN(StubInputController);
Expand Down
4 changes: 3 additions & 1 deletion ui/ozone/public/input_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/ozone/public/mojom/gesture_properties_service.mojom.h"

namespace base {
Expand Down Expand Up @@ -92,7 +93,8 @@ class COMPONENT_EXPORT(OZONE_BASE) InputController {
std::vector<DomCode> allowed_keys) = 0;

virtual void GetGesturePropertiesService(
ui::ozone::mojom::GesturePropertiesServiceRequest request) = 0;
mojo::PendingReceiver<ui::ozone::mojom::GesturePropertiesService>
receiver) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(InputController);
Expand Down

0 comments on commit 4d9ad32

Please sign in to comment.