Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: components/mus/input_devices/input_device_server.h

Issue 1992443002: Add Mojo IPC based input-device service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_ddm
Patch Set: Fixes for comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/mus/input_devices/input_device_server.h
diff --git a/components/mus/input_devices/input_device_server.h b/components/mus/input_devices/input_device_server.h
new file mode 100644
index 0000000000000000000000000000000000000000..41355d8d9bcdd63c9b5aa6d0680cfb6362053358
--- /dev/null
+++ b/components/mus/input_devices/input_device_server.h
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_MUS_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_
+#define COMPONENTS_MUS_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_
+
+#include "base/macros.h"
+#include "components/mus/public/interfaces/input_devices/input_devices.mojom.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "mojo/public/cpp/bindings/interface_ptr_set.h"
+#include "services/shell/public/cpp/connection.h"
+#include "services/shell/public/cpp/interface_factory.h"
+#include "ui/events/devices/device_data_manager.h"
+#include "ui/events/devices/input_device_event_observer.h"
+
+namespace input_device {
+
+// Listens to DeviceDataManager for updates on input-devices and forwards those
+// updates to any registered InputDeviceObserverMojo in other processes via
+// Mojo IPC. The mus-ws process owns this.
+class InputDeviceServer
+ : public shell::InterfaceFactory<mojom::InputDeviceServer>,
+ public mojom::InputDeviceServer,
+ public ui::InputDeviceEventObserver {
+ public:
+ InputDeviceServer();
+ ~InputDeviceServer() override;
+
+ // Registers this instance as a local observer with DeviceDataManager.
+ void RegisterAsObserver();
sadrul 2016/06/08 16:31:09 This doesn't seem to be called from anywhere yet?
kylechar 2016/06/08 18:13:16 Rebase problem. It's needed.
+
+ // Registers interface with the shell connection so remote observers can
+ // connect. You should have already called RegisterAsObserver() to get
+ // local input-device event updates.
+ void RegisterInterface(shell::Connection* connection);
+
+ // mojo::InterfaceFactory<mojom::InputDeviceServer>:
+ void Create(shell::Connection* connection,
sadrul 2016/06/08 16:31:09 This could be private too I think?
kylechar 2016/06/08 18:13:16 Done.
+ mojom::InputDeviceServerRequest request) override;
+
+ // mojom::InputDeviceServer:
+ void AddObserver(mojom::InputDeviceObserverMojoPtr observer) override;
+
+ // ui::InputDeviceEventObserver:
+ void OnKeyboardDeviceConfigurationChanged() override;
+ void OnTouchscreenDeviceConfigurationChanged() override;
+ void OnMouseDeviceConfigurationChanged() override;
+ void OnTouchpadDeviceConfigurationChanged() override;
+ void OnDeviceListsComplete() override;
+
+ private:
+ // Sends the current state of input devices to new observers.
+ void SendInputDeviceState(mojom::InputDeviceObserverMojo* observer);
+
+ mojo::BindingSet<mojom::InputDeviceServer> bindings_;
+ mojo::InterfacePtrSet<mojom::InputDeviceObserverMojo> observers_;
+
+ // DeviceDataManager instance we are registered as an observer with.
+ ui::DeviceDataManager* manager_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(InputDeviceServer);
+};
+
+} // namespace input_device
+
+#endif // COMPONENTS_MUS_INPUT_DEVICES_INPUT_DEVICE_SERVER_H_

Powered by Google App Engine
This is Rietveld 408576698