| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Called whenever the state of the bridge has changed. | 70 // Called whenever the state of the bridge has changed. |
| 71 virtual void OnStateChanged(State state) {} | 71 virtual void OnStateChanged(State state) {} |
| 72 | 72 |
| 73 // Called whenever ARC's availability has changed for this system. | 73 // Called whenever ARC's availability has changed for this system. |
| 74 virtual void OnAvailableChanged(bool available) {} | 74 virtual void OnAvailableChanged(bool available) {} |
| 75 | 75 |
| 76 // Called whenever the ARC app interface state changes. | 76 // Called whenever the ARC app interface state changes. |
| 77 virtual void OnAppInstanceReady() {} | 77 virtual void OnAppInstanceReady() {} |
| 78 virtual void OnAppInstanceClosed() {} | 78 virtual void OnAppInstanceClosed() {} |
| 79 | 79 |
| 80 // Called whenever the ARC audio interface state changes. |
| 81 virtual void OnAudioInstanceReady() {} |
| 82 virtual void OnAudioInstanceClosed() {} |
| 83 |
| 80 // Called whenever the ARC auth interface state changes. | 84 // Called whenever the ARC auth interface state changes. |
| 81 virtual void OnAuthInstanceReady() {} | 85 virtual void OnAuthInstanceReady() {} |
| 82 virtual void OnAuthInstanceClosed() {} | 86 virtual void OnAuthInstanceClosed() {} |
| 83 | 87 |
| 84 // Called whenever the ARC clipboard interface state changes. | 88 // Called whenever the ARC clipboard interface state changes. |
| 85 virtual void OnClipboardInstanceReady() {} | 89 virtual void OnClipboardInstanceReady() {} |
| 86 virtual void OnClipboardInstanceClosed() {} | 90 virtual void OnClipboardInstanceClosed() {} |
| 87 | 91 |
| 88 // Called whenever the ARC crash collector interface state changes. | 92 // Called whenever the ARC crash collector interface state changes. |
| 89 virtual void OnCrashCollectorInstanceReady() {} | 93 virtual void OnCrashCollectorInstanceReady() {} |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // Adds or removes observers. This can only be called on the thread that this | 160 // Adds or removes observers. This can only be called on the thread that this |
| 157 // class was created on. | 161 // class was created on. |
| 158 void AddObserver(Observer* observer); | 162 void AddObserver(Observer* observer); |
| 159 void RemoveObserver(Observer* observer); | 163 void RemoveObserver(Observer* observer); |
| 160 | 164 |
| 161 // Gets the Mojo interface for all the instance services. This will return | 165 // Gets the Mojo interface for all the instance services. This will return |
| 162 // nullptr if that particular service is not ready yet. Use an Observer if | 166 // nullptr if that particular service is not ready yet. Use an Observer if |
| 163 // you want to be notified when this is ready. This can only be called on the | 167 // you want to be notified when this is ready. This can only be called on the |
| 164 // thread that this class was created on. | 168 // thread that this class was created on. |
| 165 AppInstance* app_instance() { return app_ptr_.get(); } | 169 AppInstance* app_instance() { return app_ptr_.get(); } |
| 170 AudioInstance* audio_instance() { return audio_ptr_.get(); } |
| 166 AuthInstance* auth_instance() { return auth_ptr_.get(); } | 171 AuthInstance* auth_instance() { return auth_ptr_.get(); } |
| 167 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); } | 172 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); } |
| 168 CrashCollectorInstance* crash_collector_instance() { | 173 CrashCollectorInstance* crash_collector_instance() { |
| 169 return crash_collector_ptr_.get(); | 174 return crash_collector_ptr_.get(); |
| 170 } | 175 } |
| 171 ImeInstance* ime_instance() { return ime_ptr_.get(); } | 176 ImeInstance* ime_instance() { return ime_ptr_.get(); } |
| 172 InputInstance* input_instance() { return input_ptr_.get(); } | 177 InputInstance* input_instance() { return input_ptr_.get(); } |
| 173 IntentHelperInstance* intent_helper_instance() { | 178 IntentHelperInstance* intent_helper_instance() { |
| 174 return intent_helper_ptr_.get(); | 179 return intent_helper_ptr_.get(); |
| 175 } | 180 } |
| 176 NetInstance* net_instance() { return net_ptr_.get(); } | 181 NetInstance* net_instance() { return net_ptr_.get(); } |
| 177 NotificationsInstance* notifications_instance() { | 182 NotificationsInstance* notifications_instance() { |
| 178 return notifications_ptr_.get(); | 183 return notifications_ptr_.get(); |
| 179 } | 184 } |
| 180 PolicyInstance* policy_instance() { return policy_ptr_.get(); } | 185 PolicyInstance* policy_instance() { return policy_ptr_.get(); } |
| 181 PowerInstance* power_instance() { return power_ptr_.get(); } | 186 PowerInstance* power_instance() { return power_ptr_.get(); } |
| 182 ProcessInstance* process_instance() { return process_ptr_.get(); } | 187 ProcessInstance* process_instance() { return process_ptr_.get(); } |
| 183 VideoInstance* video_instance() { return video_ptr_.get(); } | 188 VideoInstance* video_instance() { return video_ptr_.get(); } |
| 184 | 189 |
| 185 int32_t app_version() const { return app_ptr_.version(); } | 190 int32_t app_version() const { return app_ptr_.version(); } |
| 191 int32_t audio_version() const { return audio_ptr_.version(); } |
| 186 int32_t auth_version() const { return auth_ptr_.version(); } | 192 int32_t auth_version() const { return auth_ptr_.version(); } |
| 187 int32_t clipboard_version() const { return clipboard_ptr_.version(); } | 193 int32_t clipboard_version() const { return clipboard_ptr_.version(); } |
| 188 int32_t crash_collector_version() const { | 194 int32_t crash_collector_version() const { |
| 189 return crash_collector_ptr_.version(); | 195 return crash_collector_ptr_.version(); |
| 190 } | 196 } |
| 191 int32_t ime_version() const { return ime_ptr_.version(); } | 197 int32_t ime_version() const { return ime_ptr_.version(); } |
| 192 int32_t input_version() const { return input_ptr_.version(); } | 198 int32_t input_version() const { return input_ptr_.version(); } |
| 193 int32_t intent_helper_version() const { return intent_helper_ptr_.version(); } | 199 int32_t intent_helper_version() const { return intent_helper_ptr_.version(); } |
| 194 int32_t net_version() const { return net_ptr_.version(); } | 200 int32_t net_version() const { return net_ptr_.version(); } |
| 195 int32_t notifications_version() const { return notifications_ptr_.version(); } | 201 int32_t notifications_version() const { return notifications_ptr_.version(); } |
| 196 int32_t policy_version() const { return policy_ptr_.version(); } | 202 int32_t policy_version() const { return policy_ptr_.version(); } |
| 197 int32_t power_version() const { return power_ptr_.version(); } | 203 int32_t power_version() const { return power_ptr_.version(); } |
| 198 int32_t process_version() const { return process_ptr_.version(); } | 204 int32_t process_version() const { return process_ptr_.version(); } |
| 199 int32_t video_version() const { return video_ptr_.version(); } | 205 int32_t video_version() const { return video_ptr_.version(); } |
| 200 | 206 |
| 201 // ArcHost: | 207 // ArcHost: |
| 202 void OnAppInstanceReady(AppInstancePtr app_ptr) override; | 208 void OnAppInstanceReady(AppInstancePtr app_ptr) override; |
| 209 void OnAudioInstanceReady(AudioInstancePtr audio_ptr) override; |
| 203 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; | 210 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; |
| 204 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override; | 211 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override; |
| 205 void OnCrashCollectorInstanceReady( | 212 void OnCrashCollectorInstanceReady( |
| 206 CrashCollectorInstancePtr crash_collector_ptr) override; | 213 CrashCollectorInstancePtr crash_collector_ptr) override; |
| 207 void OnImeInstanceReady(ImeInstancePtr ime_ptr) override; | 214 void OnImeInstanceReady(ImeInstancePtr ime_ptr) override; |
| 208 void OnInputInstanceReady(InputInstancePtr input_ptr) override; | 215 void OnInputInstanceReady(InputInstancePtr input_ptr) override; |
| 209 void OnIntentHelperInstanceReady( | 216 void OnIntentHelperInstanceReady( |
| 210 IntentHelperInstancePtr intent_helper_ptr) override; | 217 IntentHelperInstancePtr intent_helper_ptr) override; |
| 211 void OnNetInstanceReady(NetInstancePtr net_ptr) override; | 218 void OnNetInstanceReady(NetInstancePtr net_ptr) override; |
| 212 void OnNotificationsInstanceReady( | 219 void OnNotificationsInstanceReady( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 240 | 247 |
| 241 private: | 248 private: |
| 242 friend class ArcBridgeTest; | 249 friend class ArcBridgeTest; |
| 243 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 250 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
| 244 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 251 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
| 245 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 252 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
| 246 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); | 253 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); |
| 247 | 254 |
| 248 // Called when one of the individual channels is closed. | 255 // Called when one of the individual channels is closed. |
| 249 void CloseAppChannel(); | 256 void CloseAppChannel(); |
| 257 void CloseAudioChannel(); |
| 250 void CloseAuthChannel(); | 258 void CloseAuthChannel(); |
| 251 void CloseClipboardChannel(); | 259 void CloseClipboardChannel(); |
| 252 void CloseCrashCollectorChannel(); | 260 void CloseCrashCollectorChannel(); |
| 253 void CloseImeChannel(); | 261 void CloseImeChannel(); |
| 254 void CloseInputChannel(); | 262 void CloseInputChannel(); |
| 255 void CloseIntentHelperChannel(); | 263 void CloseIntentHelperChannel(); |
| 256 void CloseNetChannel(); | 264 void CloseNetChannel(); |
| 257 void CloseNotificationsChannel(); | 265 void CloseNotificationsChannel(); |
| 258 void ClosePolicyChannel(); | 266 void ClosePolicyChannel(); |
| 259 void ClosePowerChannel(); | 267 void ClosePowerChannel(); |
| 260 void CloseProcessChannel(); | 268 void CloseProcessChannel(); |
| 261 void CloseVideoChannel(); | 269 void CloseVideoChannel(); |
| 262 | 270 |
| 263 // Callbacks for QueryVersion. | 271 // Callbacks for QueryVersion. |
| 264 void OnAppVersionReady(int32_t version); | 272 void OnAppVersionReady(int32_t version); |
| 273 void OnAudioVersionReady(int32_t version); |
| 265 void OnAuthVersionReady(int32_t version); | 274 void OnAuthVersionReady(int32_t version); |
| 266 void OnClipboardVersionReady(int32_t version); | 275 void OnClipboardVersionReady(int32_t version); |
| 267 void OnCrashCollectorVersionReady(int32_t version); | 276 void OnCrashCollectorVersionReady(int32_t version); |
| 268 void OnImeVersionReady(int32_t version); | 277 void OnImeVersionReady(int32_t version); |
| 269 void OnInputVersionReady(int32_t version); | 278 void OnInputVersionReady(int32_t version); |
| 270 void OnIntentHelperVersionReady(int32_t version); | 279 void OnIntentHelperVersionReady(int32_t version); |
| 271 void OnNetVersionReady(int32_t version); | 280 void OnNetVersionReady(int32_t version); |
| 272 void OnNotificationsVersionReady(int32_t version); | 281 void OnNotificationsVersionReady(int32_t version); |
| 273 void OnPolicyVersionReady(int32_t version); | 282 void OnPolicyVersionReady(int32_t version); |
| 274 void OnPowerVersionReady(int32_t version); | 283 void OnPowerVersionReady(int32_t version); |
| 275 void OnProcessVersionReady(int32_t version); | 284 void OnProcessVersionReady(int32_t version); |
| 276 void OnVideoVersionReady(int32_t version); | 285 void OnVideoVersionReady(int32_t version); |
| 277 | 286 |
| 278 // Mojo interfaces. | 287 // Mojo interfaces. |
| 279 AppInstancePtr app_ptr_; | 288 AppInstancePtr app_ptr_; |
| 289 AudioInstancePtr audio_ptr_; |
| 280 AuthInstancePtr auth_ptr_; | 290 AuthInstancePtr auth_ptr_; |
| 281 ClipboardInstancePtr clipboard_ptr_; | 291 ClipboardInstancePtr clipboard_ptr_; |
| 282 CrashCollectorInstancePtr crash_collector_ptr_; | 292 CrashCollectorInstancePtr crash_collector_ptr_; |
| 283 ImeInstancePtr ime_ptr_; | 293 ImeInstancePtr ime_ptr_; |
| 284 InputInstancePtr input_ptr_; | 294 InputInstancePtr input_ptr_; |
| 285 IntentHelperInstancePtr intent_helper_ptr_; | 295 IntentHelperInstancePtr intent_helper_ptr_; |
| 286 NetInstancePtr net_ptr_; | 296 NetInstancePtr net_ptr_; |
| 287 NotificationsInstancePtr notifications_ptr_; | 297 NotificationsInstancePtr notifications_ptr_; |
| 288 PolicyInstancePtr policy_ptr_; | 298 PolicyInstancePtr policy_ptr_; |
| 289 PowerInstancePtr power_ptr_; | 299 PowerInstancePtr power_ptr_; |
| 290 ProcessInstancePtr process_ptr_; | 300 ProcessInstancePtr process_ptr_; |
| 291 VideoInstancePtr video_ptr_; | 301 VideoInstancePtr video_ptr_; |
| 292 | 302 |
| 293 // Temporary Mojo interfaces. After a Mojo interface pointer has been | 303 // Temporary Mojo interfaces. After a Mojo interface pointer has been |
| 294 // received from the other endpoint, we still need to asynchronously query | 304 // received from the other endpoint, we still need to asynchronously query |
| 295 // its version. While that is going on, we should still return nullptr on | 305 // its version. While that is going on, we should still return nullptr on |
| 296 // the xxx_instance() functions. | 306 // the xxx_instance() functions. |
| 297 // To keep the xxx_instance() functions being trivial, store the instance | 307 // To keep the xxx_instance() functions being trivial, store the instance |
| 298 // pointer in a temporary variable to avoid losing its reference. | 308 // pointer in a temporary variable to avoid losing its reference. |
| 299 AppInstancePtr temporary_app_ptr_; | 309 AppInstancePtr temporary_app_ptr_; |
| 310 AudioInstancePtr temporary_audio_ptr_; |
| 300 AuthInstancePtr temporary_auth_ptr_; | 311 AuthInstancePtr temporary_auth_ptr_; |
| 301 ClipboardInstancePtr temporary_clipboard_ptr_; | 312 ClipboardInstancePtr temporary_clipboard_ptr_; |
| 302 CrashCollectorInstancePtr temporary_crash_collector_ptr_; | 313 CrashCollectorInstancePtr temporary_crash_collector_ptr_; |
| 303 ImeInstancePtr temporary_ime_ptr_; | 314 ImeInstancePtr temporary_ime_ptr_; |
| 304 InputInstancePtr temporary_input_ptr_; | 315 InputInstancePtr temporary_input_ptr_; |
| 305 IntentHelperInstancePtr temporary_intent_helper_ptr_; | 316 IntentHelperInstancePtr temporary_intent_helper_ptr_; |
| 306 NetInstancePtr temporary_net_ptr_; | 317 NetInstancePtr temporary_net_ptr_; |
| 307 NotificationsInstancePtr temporary_notifications_ptr_; | 318 NotificationsInstancePtr temporary_notifications_ptr_; |
| 308 PolicyInstancePtr temporary_policy_ptr_; | 319 PolicyInstancePtr temporary_policy_ptr_; |
| 309 PowerInstancePtr temporary_power_ptr_; | 320 PowerInstancePtr temporary_power_ptr_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 322 | 333 |
| 323 // WeakPtrFactory to use callbacks. | 334 // WeakPtrFactory to use callbacks. |
| 324 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 335 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 325 | 336 |
| 326 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 337 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 327 }; | 338 }; |
| 328 | 339 |
| 329 } // namespace arc | 340 } // namespace arc |
| 330 | 341 |
| 331 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 342 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |