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.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class Observer { | 62 class Observer { |
| 63 public: | 63 public: |
| 64 // Called whenever the state of the bridge has changed. | 64 // Called whenever the state of the bridge has changed. |
| 65 virtual void OnStateChanged(State state) {} | 65 virtual void OnStateChanged(State state) {} |
| 66 | 66 |
| 67 // Called whenever ARC's availability has changed for this system. | 67 // Called whenever ARC's availability has changed for this system. |
| 68 virtual void OnAvailableChanged(bool available) {} | 68 virtual void OnAvailableChanged(bool available) {} |
| 69 | 69 |
| 70 // Called whenever to create video accelerator connection. | |
| 71 virtual void OnCreateArcVideoAcceleratorConnection() {} | |
|
Owen Lin
2015/12/07 09:05:23
How about rename it as OnRequestArcVideoAccelerato
kcwu
2015/12/10 10:17:37
Revised to use new ArcBridgeService's new observer
| |
| 72 | |
| 70 protected: | 73 protected: |
| 71 virtual ~Observer() {} | 74 virtual ~Observer() {} |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 ArcBridgeService( | 77 ArcBridgeService( |
| 75 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, | 78 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, |
| 76 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); | 79 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); |
| 77 ~ArcBridgeService() override; | 80 ~ArcBridgeService() override; |
| 78 | 81 |
| 79 // Gets the global instance of the ARC Bridge Service. This can only be | 82 // Gets the global instance of the ARC Bridge Service. This can only be |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 108 // Requests registration of an input device on the ARC instance. | 111 // Requests registration of an input device on the ARC instance. |
| 109 // TODO(denniskempin): Make this interface more typesafe. | 112 // TODO(denniskempin): Make this interface more typesafe. |
| 110 // |name| should be the displayable name of the emulated device (e.g. "Chrome | 113 // |name| should be the displayable name of the emulated device (e.g. "Chrome |
| 111 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") | 114 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") |
| 112 // and |fd| a file descriptor that emulates the kernel events of the device. | 115 // and |fd| a file descriptor that emulates the kernel events of the device. |
| 113 // This can only be called on the thread that this class was created on. | 116 // This can only be called on the thread that this class was created on. |
| 114 bool RegisterInputDevice(const std::string& name, | 117 bool RegisterInputDevice(const std::string& name, |
| 115 const std::string& device_type, | 118 const std::string& device_type, |
| 116 base::ScopedFD fd); | 119 base::ScopedFD fd); |
| 117 | 120 |
| 121 bool NotifyVideoAcceleratorConnectionCreated(IPC::ChannelHandle handle); | |
| 122 | |
| 118 private: | 123 private: |
| 119 friend class ArcBridgeTest; | 124 friend class ArcBridgeTest; |
| 120 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 125 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
| 121 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 126 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
| 122 | 127 |
| 123 // If all pre-requisites are true (ARC is available, it has been enabled, and | 128 // If all pre-requisites are true (ARC is available, it has been enabled, and |
| 124 // the session has started), and ARC is stopped, start ARC. If ARC is running | 129 // the session has started), and ARC is stopped, start ARC. If ARC is running |
| 125 // and the pre-requisites stop being true, stop ARC. | 130 // and the pre-requisites stop being true, stop ARC. |
| 126 void PrerequisitesChanged(); | 131 void PrerequisitesChanged(); |
| 127 | 132 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 141 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path, | 146 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path, |
| 142 bool socket_permissions_success); | 147 bool socket_permissions_success); |
| 143 | 148 |
| 144 // Stops the running instance. | 149 // Stops the running instance. |
| 145 void StopInstance(); | 150 void StopInstance(); |
| 146 | 151 |
| 147 // Called when the ARC instance has finished setting up and is ready for user | 152 // Called when the ARC instance has finished setting up and is ready for user |
| 148 // interaction. | 153 // interaction. |
| 149 void OnInstanceReady(); | 154 void OnInstanceReady(); |
| 150 | 155 |
| 156 void OnCreateArcVideoAcceleratorConnection(); | |
| 157 | |
| 151 // Changes the current state and notifies all observers. | 158 // Changes the current state and notifies all observers. |
| 152 void SetState(State state); | 159 void SetState(State state); |
| 153 | 160 |
| 154 // IPC::Listener: | 161 // IPC::Listener: |
| 155 bool OnMessageReceived(const IPC::Message& message) override; | 162 bool OnMessageReceived(const IPC::Message& message) override; |
| 156 | 163 |
| 157 // DBus callbacks. | 164 // DBus callbacks. |
| 158 void OnArcAvailable(bool available); | 165 void OnArcAvailable(bool available); |
| 159 void OnInstanceStarted(bool success); | 166 void OnInstanceStarted(bool success); |
| 160 void OnInstanceStopped(bool success); | 167 void OnInstanceStopped(bool success); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 178 | 185 |
| 179 // WeakPtrFactory to use callbacks. | 186 // WeakPtrFactory to use callbacks. |
| 180 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 187 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 181 | 188 |
| 182 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 189 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 183 }; | 190 }; |
| 184 | 191 |
| 185 } // namespace arc | 192 } // namespace arc |
| 186 | 193 |
| 187 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 194 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |