| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 virtual void OnPowerInstanceClosed() {} | 94 virtual void OnPowerInstanceClosed() {} |
| 95 | 95 |
| 96 // Called whenever the ARC process interface state changes. | 96 // Called whenever the ARC process interface state changes. |
| 97 virtual void OnProcessInstanceReady() {} | 97 virtual void OnProcessInstanceReady() {} |
| 98 virtual void OnProcessInstanceClosed() {} | 98 virtual void OnProcessInstanceClosed() {} |
| 99 | 99 |
| 100 // Called whenever the ARC settings interface state changes. | 100 // Called whenever the ARC settings interface state changes. |
| 101 virtual void OnSettingsInstanceReady() {} | 101 virtual void OnSettingsInstanceReady() {} |
| 102 virtual void OnSettingsInstanceClosed() {} | 102 virtual void OnSettingsInstanceClosed() {} |
| 103 | 103 |
| 104 // Called whenever the ARC video interface state changes. |
| 105 virtual void OnVideoInstanceReady() {} |
| 106 virtual void OnVideoInstanceClosed() {} |
| 107 |
| 104 protected: | 108 protected: |
| 105 virtual ~Observer() {} | 109 virtual ~Observer() {} |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 ~ArcBridgeService() override; | 112 ~ArcBridgeService() override; |
| 109 | 113 |
| 110 // Gets the global instance of the ARC Bridge Service. This can only be | 114 // Gets the global instance of the ARC Bridge Service. This can only be |
| 111 // called on the thread that this class was created on. | 115 // called on the thread that this class was created on. |
| 112 static ArcBridgeService* Get(); | 116 static ArcBridgeService* Get(); |
| 113 | 117 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 140 // thread that this class was created on. | 144 // thread that this class was created on. |
| 141 AppInstance* app_instance() { return app_ptr_.get(); } | 145 AppInstance* app_instance() { return app_ptr_.get(); } |
| 142 AuthInstance* auth_instance() { return auth_ptr_.get(); } | 146 AuthInstance* auth_instance() { return auth_ptr_.get(); } |
| 143 InputInstance* input_instance() { return input_ptr_.get(); } | 147 InputInstance* input_instance() { return input_ptr_.get(); } |
| 144 NotificationsInstance* notifications_instance() { | 148 NotificationsInstance* notifications_instance() { |
| 145 return notifications_ptr_.get(); | 149 return notifications_ptr_.get(); |
| 146 } | 150 } |
| 147 PowerInstance* power_instance() { return power_ptr_.get(); } | 151 PowerInstance* power_instance() { return power_ptr_.get(); } |
| 148 ProcessInstance* process_instance() { return process_ptr_.get(); } | 152 ProcessInstance* process_instance() { return process_ptr_.get(); } |
| 149 SettingsInstance* settings_instance() { return settings_ptr_.get(); } | 153 SettingsInstance* settings_instance() { return settings_ptr_.get(); } |
| 154 VideoInstance* video_instance() { return video_ptr_.get(); } |
| 150 | 155 |
| 151 int32_t app_version() const { return app_ptr_.version(); } | 156 int32_t app_version() const { return app_ptr_.version(); } |
| 152 int32_t auth_version() const { return auth_ptr_.version(); } | 157 int32_t auth_version() const { return auth_ptr_.version(); } |
| 153 int32_t input_version() const { return input_ptr_.version(); } | 158 int32_t input_version() const { return input_ptr_.version(); } |
| 154 int32_t notifications_version() const { return notifications_ptr_.version(); } | 159 int32_t notifications_version() const { return notifications_ptr_.version(); } |
| 155 int32_t power_version() const { return power_ptr_.version(); } | 160 int32_t power_version() const { return power_ptr_.version(); } |
| 156 int32_t process_version() const { return process_ptr_.version(); } | 161 int32_t process_version() const { return process_ptr_.version(); } |
| 157 int32_t settings_version() const { return settings_ptr_.version(); } | 162 int32_t settings_version() const { return settings_ptr_.version(); } |
| 163 int32_t video_version() const { return video_ptr_.version(); } |
| 158 | 164 |
| 159 // ArcHost: | 165 // ArcHost: |
| 160 void OnAppInstanceReady(AppInstancePtr app_ptr) override; | 166 void OnAppInstanceReady(AppInstancePtr app_ptr) override; |
| 161 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; | 167 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; |
| 162 void OnInputInstanceReady(InputInstancePtr input_ptr) override; | 168 void OnInputInstanceReady(InputInstancePtr input_ptr) override; |
| 163 void OnNotificationsInstanceReady( | 169 void OnNotificationsInstanceReady( |
| 164 NotificationsInstancePtr notifications_ptr) override; | 170 NotificationsInstancePtr notifications_ptr) override; |
| 165 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; | 171 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; |
| 166 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; | 172 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; |
| 167 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override; | 173 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override; |
| 174 void OnVideoInstanceReady(VideoInstancePtr video_ptr) override; |
| 168 | 175 |
| 169 // Gets the current state of the bridge service. | 176 // Gets the current state of the bridge service. |
| 170 State state() const { return state_; } | 177 State state() const { return state_; } |
| 171 | 178 |
| 172 // Gets if ARC is available in this system. | 179 // Gets if ARC is available in this system. |
| 173 bool available() const { return available_; } | 180 bool available() const { return available_; } |
| 174 | 181 |
| 175 protected: | 182 protected: |
| 176 ArcBridgeService(); | 183 ArcBridgeService(); |
| 177 | 184 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 196 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); | 203 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); |
| 197 | 204 |
| 198 // Called when one of the individual channels is closed. | 205 // Called when one of the individual channels is closed. |
| 199 void CloseAppChannel(); | 206 void CloseAppChannel(); |
| 200 void CloseAuthChannel(); | 207 void CloseAuthChannel(); |
| 201 void CloseInputChannel(); | 208 void CloseInputChannel(); |
| 202 void CloseNotificationsChannel(); | 209 void CloseNotificationsChannel(); |
| 203 void ClosePowerChannel(); | 210 void ClosePowerChannel(); |
| 204 void CloseProcessChannel(); | 211 void CloseProcessChannel(); |
| 205 void CloseSettingsChannel(); | 212 void CloseSettingsChannel(); |
| 213 void CloseVideoChannel(); |
| 206 | 214 |
| 207 // Callbacks for QueryVersion. | 215 // Callbacks for QueryVersion. |
| 208 void OnAppVersionReady(int32_t version); | 216 void OnAppVersionReady(int32_t version); |
| 209 void OnAuthVersionReady(int32_t version); | 217 void OnAuthVersionReady(int32_t version); |
| 210 void OnInputVersionReady(int32_t version); | 218 void OnInputVersionReady(int32_t version); |
| 211 void OnNotificationsVersionReady(int32_t version); | 219 void OnNotificationsVersionReady(int32_t version); |
| 212 void OnPowerVersionReady(int32_t version); | 220 void OnPowerVersionReady(int32_t version); |
| 213 void OnProcessVersionReady(int32_t version); | 221 void OnProcessVersionReady(int32_t version); |
| 214 void OnSettingsVersionReady(int32_t version); | 222 void OnSettingsVersionReady(int32_t version); |
| 223 void OnVideoVersionReady(int32_t version); |
| 215 | 224 |
| 216 // Mojo interfaces. | 225 // Mojo interfaces. |
| 217 AppInstancePtr app_ptr_; | 226 AppInstancePtr app_ptr_; |
| 218 AuthInstancePtr auth_ptr_; | 227 AuthInstancePtr auth_ptr_; |
| 219 InputInstancePtr input_ptr_; | 228 InputInstancePtr input_ptr_; |
| 220 NotificationsInstancePtr notifications_ptr_; | 229 NotificationsInstancePtr notifications_ptr_; |
| 221 PowerInstancePtr power_ptr_; | 230 PowerInstancePtr power_ptr_; |
| 222 ProcessInstancePtr process_ptr_; | 231 ProcessInstancePtr process_ptr_; |
| 223 SettingsInstancePtr settings_ptr_; | 232 SettingsInstancePtr settings_ptr_; |
| 233 VideoInstancePtr video_ptr_; |
| 224 | 234 |
| 225 // Temporary Mojo interfaces. After a Mojo interface pointer has been | 235 // Temporary Mojo interfaces. After a Mojo interface pointer has been |
| 226 // received from the other endpoint, we still need to asynchronously query | 236 // received from the other endpoint, we still need to asynchronously query |
| 227 // its version. While that is going on, we should still return nullptr on | 237 // its version. While that is going on, we should still return nullptr on |
| 228 // the xxx_instance() functions. | 238 // the xxx_instance() functions. |
| 229 // To keep the xxx_instance() functions being trivial, store the instance | 239 // To keep the xxx_instance() functions being trivial, store the instance |
| 230 // pointer in a temporary variable to avoid losing its reference. | 240 // pointer in a temporary variable to avoid losing its reference. |
| 231 AppInstancePtr temporary_app_ptr_; | 241 AppInstancePtr temporary_app_ptr_; |
| 232 AuthInstancePtr temporary_auth_ptr_; | 242 AuthInstancePtr temporary_auth_ptr_; |
| 233 InputInstancePtr temporary_input_ptr_; | 243 InputInstancePtr temporary_input_ptr_; |
| 234 NotificationsInstancePtr temporary_notifications_ptr_; | 244 NotificationsInstancePtr temporary_notifications_ptr_; |
| 235 PowerInstancePtr temporary_power_ptr_; | 245 PowerInstancePtr temporary_power_ptr_; |
| 236 ProcessInstancePtr temporary_process_ptr_; | 246 ProcessInstancePtr temporary_process_ptr_; |
| 237 SettingsInstancePtr temporary_settings_ptr_; | 247 SettingsInstancePtr temporary_settings_ptr_; |
| 248 VideoInstancePtr temporary_video_ptr_; |
| 238 | 249 |
| 239 base::ObserverList<Observer> observer_list_; | 250 base::ObserverList<Observer> observer_list_; |
| 240 | 251 |
| 241 base::ThreadChecker thread_checker_; | 252 base::ThreadChecker thread_checker_; |
| 242 | 253 |
| 243 // If the ARC instance service is available. | 254 // If the ARC instance service is available. |
| 244 bool available_; | 255 bool available_; |
| 245 | 256 |
| 246 // The current state of the bridge. | 257 // The current state of the bridge. |
| 247 ArcBridgeService::State state_; | 258 ArcBridgeService::State state_; |
| 248 | 259 |
| 249 // WeakPtrFactory to use callbacks. | 260 // WeakPtrFactory to use callbacks. |
| 250 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 261 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 251 | 262 |
| 252 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 263 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 253 }; | 264 }; |
| 254 | 265 |
| 255 } // namespace arc | 266 } // namespace arc |
| 256 | 267 |
| 257 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 268 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |