Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/observer_list_threadsafe.h" | 9 #include "base/observer_list_threadsafe.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "chromeos/dbus/dbus_method_call_status.h" | 11 #include "chromeos/dbus/dbus_method_call_status.h" |
| 12 #include "components/arc/arc_bridge_input_devices.h" | |
| 12 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
| 13 #include "ipc/ipc_channel_proxy.h" | 14 #include "ipc/ipc_channel_proxy.h" |
| 14 #include "ipc/ipc_listener.h" | 15 #include "ipc/ipc_listener.h" |
| 15 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
| 16 | |
| 17 class PrefRegistrySimple; | 17 class PrefRegistrySimple; |
| 18 class PrefService; | 18 class PrefService; |
| 19 | 19 |
| 20 namespace arc { | 20 namespace arc { |
| 21 | 21 |
| 22 class ArcBridgeTest; | 22 class ArcBridgeTest; |
| 23 | 23 |
| 24 // The Chrome-side service that handles ARC instances and ARC bridge creation. | 24 // The Chrome-side service that handles ARC instances and ARC bridge creation. |
| 25 // This service handles the lifetime of ARC instances and sets up the | 25 // This service handles the lifetime of ARC instances and sets up the |
| 26 // communication channel (the ARC bridge) used to send and receive messages. | 26 // communication channel (the ARC bridge) used to send and receive messages. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 94 |
| 95 // Gets the current state of the bridge service. | 95 // Gets the current state of the bridge service. |
| 96 State GetState() const { return state_; } | 96 State GetState() const { return state_; } |
| 97 | 97 |
| 98 // Enables or disables the bridge for this session. | 98 // Enables or disables the bridge for this session. |
| 99 void SetEnabled(bool enabled); | 99 void SetEnabled(bool enabled); |
| 100 | 100 |
| 101 // Gets if the bridge is enabled for this session. | 101 // Gets if the bridge is enabled for this session. |
| 102 bool IsEnabled() const { return enabled_; } | 102 bool IsEnabled() const { return enabled_; } |
| 103 | 103 |
| 104 // Requests registration of an input device on the ARC instance. | 104 // Translates and sends input event to the ARC instance. |
| 105 // TODO(denniskempin): Make this interface more typesafe. | 105 void SendInputEvent(ui::Event* event); |
| 106 // |name| should be the displayable name of the emulated device (e.g. "Chrome | |
| 107 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") | |
| 108 // and |fd| a file descriptor that emulates the kernel events of the device. | |
| 109 bool RegisterInputDevice(const std::string& name, | |
| 110 const std::string& device_type, | |
| 111 base::ScopedFD fd); | |
| 112 | 106 |
| 113 private: | 107 private: |
| 114 friend class arc::ArcBridgeTest; | 108 friend class arc::ArcBridgeTest; |
| 115 | 109 |
| 116 // Binds to the socket specified by |socket_path|. | 110 // Binds to the socket specified by |socket_path|. |
| 117 void SocketConnect(const base::FilePath& socket_path); | 111 void SocketConnect(const base::FilePath& socket_path); |
| 118 | 112 |
| 119 // Binds to the socket specified by |socket_path| after creating its parent | 113 // Binds to the socket specified by |socket_path| after creating its parent |
| 120 // directory is present. | 114 // directory is present. |
| 121 void SocketConnectAfterEnsureParentDirectory( | 115 void SocketConnectAfterEnsureParentDirectory( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 138 // Finishes shutdown after deleting the socket file. | 132 // Finishes shutdown after deleting the socket file. |
| 139 void FinishShutdownAfterSocketDeleted(bool socket_deleted); | 133 void FinishShutdownAfterSocketDeleted(bool socket_deleted); |
| 140 | 134 |
| 141 // IPC::Listener: | 135 // IPC::Listener: |
| 142 bool OnMessageReceived(const IPC::Message& message) override; | 136 bool OnMessageReceived(const IPC::Message& message) override; |
| 143 | 137 |
| 144 // DBus callbacks. | 138 // DBus callbacks. |
| 145 void OnInstanceStarted(chromeos::DBusMethodCallStatus status); | 139 void OnInstanceStarted(chromeos::DBusMethodCallStatus status); |
| 146 void OnInstanceStopped(chromeos::DBusMethodCallStatus status); | 140 void OnInstanceStopped(chromeos::DBusMethodCallStatus status); |
| 147 | 141 |
| 142 // Creates and registers an input device on the ARC instance. | |
| 143 // TODO(denniskempin): Make this interface more typesafe. | |
| 144 // |name| should be the displayable name of the emulated device (e.g. "Chrome | |
| 145 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") | |
| 146 // Returns a file descriptor that receives the kernel events of the device. | |
| 147 base::ScopedFD CreateBridgeInputDevice(const std::string& name, | |
| 148 const std::string& device_type); | |
| 149 | |
| 150 // Register all bridge input devices with the ARC instance. Called | |
| 151 // once the instance is ready. | |
| 152 void SetupBridgeInputDevices(); | |
| 153 | |
| 148 // Thread in which IPC messaging is performed. | 154 // Thread in which IPC messaging is performed. |
| 149 base::Thread ipc_thread_; | 155 base::Thread ipc_thread_; |
| 150 | 156 |
| 151 // Task runner on which incoming messages are handled. | 157 // Task runner on which incoming messages are handled. |
| 152 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; | 158 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; |
| 153 | 159 |
| 154 // Task runner on which file operations are performed. | 160 // Task runner on which file operations are performed. |
| 155 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 161 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 156 | 162 |
| 157 // The channel through which messages are sent. | 163 // The channel through which messages are sent. |
| 158 scoped_ptr<IPC::ChannelProxy> ipc_channel_; | 164 scoped_ptr<IPC::ChannelProxy> ipc_channel_; |
| 159 | 165 |
| 160 // List of observers to notify of state changes. | 166 // List of observers to notify of state changes. |
| 161 scoped_refptr<base::ObserverListThreadSafe<Observer>> observer_list_; | 167 scoped_refptr<base::ObserverListThreadSafe<Observer>> observer_list_; |
| 162 | 168 |
| 163 // If the ARC instance service is available. | 169 // If the ARC instance service is available. |
| 164 bool available_; | 170 bool available_; |
| 165 | 171 |
| 166 // If ARC has been enabled by policy and user choice. | 172 // If ARC has been enabled by policy and user choice. |
| 167 bool enabled_; | 173 bool enabled_; |
| 168 | 174 |
| 169 // The current state of the bridge. | 175 // The current state of the bridge. |
| 170 ArcBridgeService::State state_; | 176 ArcBridgeService::State state_; |
| 171 | 177 |
| 178 // List of bridge input devices registered with the ARC instance. | |
| 179 ScopedVector<BridgeInputDevice> bridge_devices_; | |
| 180 | |
| 172 // WeakPtrFactory to use callbacks. | 181 // WeakPtrFactory to use callbacks. |
| 173 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 182 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 174 | 183 |
| 184 | |
|
elijahtaylor1
2015/11/02 22:30:29
nit: whitespace
| |
| 175 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 185 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 176 }; | 186 }; |
| 177 | 187 |
| 178 } // namespace arc | 188 } // namespace arc |
| 179 | 189 |
| 180 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 190 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |