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

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: Implementation only. 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..ba78c443a7fb5de0f016f1083dc3151f7c71ff3d
--- /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_device_server.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. This runs in the mus-ws process.
+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();
+
+ // 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);
+
+ // 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:
+ // mojo::InterfaceFactory<mojom::InputDeviceServer>:
+ void Create(shell::Connection* connection,
+ mojom::InputDeviceServerRequest request) override;
+
+ // Sends the current state of all input-devices to an observer.
+ void SendDeviceListsComplete(mojom::InputDeviceObserverMojo* observer);
sadrul 2016/06/10 18:01:49 non-overrides before overrides
kylechar 2016/06/10 19:29:31 Done.
+
+ 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