| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual void OnAuthInstanceClosed() {} | 82 virtual void OnAuthInstanceClosed() {} |
| 83 | 83 |
| 84 // Called whenever the ARC clipboard interface state changes. | 84 // Called whenever the ARC clipboard interface state changes. |
| 85 virtual void OnClipboardInstanceReady() {} | 85 virtual void OnClipboardInstanceReady() {} |
| 86 virtual void OnClipboardInstanceClosed() {} | 86 virtual void OnClipboardInstanceClosed() {} |
| 87 | 87 |
| 88 // Called whenever the ARC input interface state changes. | 88 // Called whenever the ARC input interface state changes. |
| 89 virtual void OnInputInstanceReady() {} | 89 virtual void OnInputInstanceReady() {} |
| 90 virtual void OnInputInstanceClosed() {} | 90 virtual void OnInputInstanceClosed() {} |
| 91 | 91 |
| 92 // Called whenever the ARC intent helper interface state changes. |
| 93 virtual void OnIntentHelperInstanceReady() {} |
| 94 virtual void OnIntentHelperInstanceClosed() {} |
| 95 |
| 92 // Called whenever the ARC notification interface state changes. | 96 // Called whenever the ARC notification interface state changes. |
| 93 virtual void OnNotificationsInstanceReady() {} | 97 virtual void OnNotificationsInstanceReady() {} |
| 94 virtual void OnNotificationsInstanceClosed() {} | 98 virtual void OnNotificationsInstanceClosed() {} |
| 95 | 99 |
| 96 // Called whenever the ARC power interface state changes. | 100 // Called whenever the ARC power interface state changes. |
| 97 virtual void OnPowerInstanceReady() {} | 101 virtual void OnPowerInstanceReady() {} |
| 98 virtual void OnPowerInstanceClosed() {} | 102 virtual void OnPowerInstanceClosed() {} |
| 99 | 103 |
| 100 // Called whenever the ARC process interface state changes. | 104 // Called whenever the ARC process interface state changes. |
| 101 virtual void OnProcessInstanceReady() {} | 105 virtual void OnProcessInstanceReady() {} |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void RemoveObserver(Observer* observer); | 147 void RemoveObserver(Observer* observer); |
| 144 | 148 |
| 145 // Gets the Mojo interface for all the instance services. This will return | 149 // Gets the Mojo interface for all the instance services. This will return |
| 146 // nullptr if that particular service is not ready yet. Use an Observer if | 150 // nullptr if that particular service is not ready yet. Use an Observer if |
| 147 // you want to be notified when this is ready. This can only be called on the | 151 // you want to be notified when this is ready. This can only be called on the |
| 148 // thread that this class was created on. | 152 // thread that this class was created on. |
| 149 AppInstance* app_instance() { return app_ptr_.get(); } | 153 AppInstance* app_instance() { return app_ptr_.get(); } |
| 150 AuthInstance* auth_instance() { return auth_ptr_.get(); } | 154 AuthInstance* auth_instance() { return auth_ptr_.get(); } |
| 151 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); } | 155 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); } |
| 152 InputInstance* input_instance() { return input_ptr_.get(); } | 156 InputInstance* input_instance() { return input_ptr_.get(); } |
| 157 IntentHelperInstance* intent_helper_instance() { |
| 158 return intent_helper_ptr_.get(); |
| 159 } |
| 153 NotificationsInstance* notifications_instance() { | 160 NotificationsInstance* notifications_instance() { |
| 154 return notifications_ptr_.get(); | 161 return notifications_ptr_.get(); |
| 155 } | 162 } |
| 156 PowerInstance* power_instance() { return power_ptr_.get(); } | 163 PowerInstance* power_instance() { return power_ptr_.get(); } |
| 157 ProcessInstance* process_instance() { return process_ptr_.get(); } | 164 ProcessInstance* process_instance() { return process_ptr_.get(); } |
| 158 SettingsInstance* settings_instance() { return settings_ptr_.get(); } | 165 SettingsInstance* settings_instance() { return settings_ptr_.get(); } |
| 159 VideoInstance* video_instance() { return video_ptr_.get(); } | 166 VideoInstance* video_instance() { return video_ptr_.get(); } |
| 160 | 167 |
| 161 int32_t app_version() const { return app_ptr_.version(); } | 168 int32_t app_version() const { return app_ptr_.version(); } |
| 162 int32_t auth_version() const { return auth_ptr_.version(); } | 169 int32_t auth_version() const { return auth_ptr_.version(); } |
| 163 int32_t clipboard_version() const { return clipboard_ptr_.version(); } | 170 int32_t clipboard_version() const { return clipboard_ptr_.version(); } |
| 164 int32_t input_version() const { return input_ptr_.version(); } | 171 int32_t input_version() const { return input_ptr_.version(); } |
| 172 int32_t intent_helper_version() const { return intent_helper_ptr_.version(); } |
| 165 int32_t notifications_version() const { return notifications_ptr_.version(); } | 173 int32_t notifications_version() const { return notifications_ptr_.version(); } |
| 166 int32_t power_version() const { return power_ptr_.version(); } | 174 int32_t power_version() const { return power_ptr_.version(); } |
| 167 int32_t process_version() const { return process_ptr_.version(); } | 175 int32_t process_version() const { return process_ptr_.version(); } |
| 168 int32_t settings_version() const { return settings_ptr_.version(); } | 176 int32_t settings_version() const { return settings_ptr_.version(); } |
| 169 int32_t video_version() const { return video_ptr_.version(); } | 177 int32_t video_version() const { return video_ptr_.version(); } |
| 170 | 178 |
| 171 // ArcHost: | 179 // ArcHost: |
| 172 void OnAppInstanceReady(AppInstancePtr app_ptr) override; | 180 void OnAppInstanceReady(AppInstancePtr app_ptr) override; |
| 173 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; | 181 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; |
| 174 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override; | 182 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override; |
| 175 void OnInputInstanceReady(InputInstancePtr input_ptr) override; | 183 void OnInputInstanceReady(InputInstancePtr input_ptr) override; |
| 184 void OnIntentHelperInstanceReady( |
| 185 IntentHelperInstancePtr intent_helper_ptr) override; |
| 176 void OnNotificationsInstanceReady( | 186 void OnNotificationsInstanceReady( |
| 177 NotificationsInstancePtr notifications_ptr) override; | 187 NotificationsInstancePtr notifications_ptr) override; |
| 178 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; | 188 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; |
| 179 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; | 189 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; |
| 180 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override; | 190 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override; |
| 181 void OnVideoInstanceReady(VideoInstancePtr video_ptr) override; | 191 void OnVideoInstanceReady(VideoInstancePtr video_ptr) override; |
| 182 | 192 |
| 183 // Gets the current state of the bridge service. | 193 // Gets the current state of the bridge service. |
| 184 State state() const { return state_; } | 194 State state() const { return state_; } |
| 185 | 195 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 207 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 217 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
| 208 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 218 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
| 209 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 219 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
| 210 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); | 220 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); |
| 211 | 221 |
| 212 // Called when one of the individual channels is closed. | 222 // Called when one of the individual channels is closed. |
| 213 void CloseAppChannel(); | 223 void CloseAppChannel(); |
| 214 void CloseAuthChannel(); | 224 void CloseAuthChannel(); |
| 215 void CloseClipboardChannel(); | 225 void CloseClipboardChannel(); |
| 216 void CloseInputChannel(); | 226 void CloseInputChannel(); |
| 227 void CloseIntentHelperChannel(); |
| 217 void CloseNotificationsChannel(); | 228 void CloseNotificationsChannel(); |
| 218 void ClosePowerChannel(); | 229 void ClosePowerChannel(); |
| 219 void CloseProcessChannel(); | 230 void CloseProcessChannel(); |
| 220 void CloseSettingsChannel(); | 231 void CloseSettingsChannel(); |
| 221 void CloseVideoChannel(); | 232 void CloseVideoChannel(); |
| 222 | 233 |
| 223 // Callbacks for QueryVersion. | 234 // Callbacks for QueryVersion. |
| 224 void OnAppVersionReady(int32_t version); | 235 void OnAppVersionReady(int32_t version); |
| 225 void OnAuthVersionReady(int32_t version); | 236 void OnAuthVersionReady(int32_t version); |
| 226 void OnClipboardVersionReady(int32_t version); | 237 void OnClipboardVersionReady(int32_t version); |
| 227 void OnInputVersionReady(int32_t version); | 238 void OnInputVersionReady(int32_t version); |
| 239 void OnIntentHelperVersionReady(int32_t version); |
| 228 void OnNotificationsVersionReady(int32_t version); | 240 void OnNotificationsVersionReady(int32_t version); |
| 229 void OnPowerVersionReady(int32_t version); | 241 void OnPowerVersionReady(int32_t version); |
| 230 void OnProcessVersionReady(int32_t version); | 242 void OnProcessVersionReady(int32_t version); |
| 231 void OnSettingsVersionReady(int32_t version); | 243 void OnSettingsVersionReady(int32_t version); |
| 232 void OnVideoVersionReady(int32_t version); | 244 void OnVideoVersionReady(int32_t version); |
| 233 | 245 |
| 234 // Mojo interfaces. | 246 // Mojo interfaces. |
| 235 AppInstancePtr app_ptr_; | 247 AppInstancePtr app_ptr_; |
| 236 AuthInstancePtr auth_ptr_; | 248 AuthInstancePtr auth_ptr_; |
| 237 ClipboardInstancePtr clipboard_ptr_; | 249 ClipboardInstancePtr clipboard_ptr_; |
| 238 InputInstancePtr input_ptr_; | 250 InputInstancePtr input_ptr_; |
| 251 IntentHelperInstancePtr intent_helper_ptr_; |
| 239 NotificationsInstancePtr notifications_ptr_; | 252 NotificationsInstancePtr notifications_ptr_; |
| 240 PowerInstancePtr power_ptr_; | 253 PowerInstancePtr power_ptr_; |
| 241 ProcessInstancePtr process_ptr_; | 254 ProcessInstancePtr process_ptr_; |
| 242 SettingsInstancePtr settings_ptr_; | 255 SettingsInstancePtr settings_ptr_; |
| 243 VideoInstancePtr video_ptr_; | 256 VideoInstancePtr video_ptr_; |
| 244 | 257 |
| 245 // Temporary Mojo interfaces. After a Mojo interface pointer has been | 258 // Temporary Mojo interfaces. After a Mojo interface pointer has been |
| 246 // received from the other endpoint, we still need to asynchronously query | 259 // received from the other endpoint, we still need to asynchronously query |
| 247 // its version. While that is going on, we should still return nullptr on | 260 // its version. While that is going on, we should still return nullptr on |
| 248 // the xxx_instance() functions. | 261 // the xxx_instance() functions. |
| 249 // To keep the xxx_instance() functions being trivial, store the instance | 262 // To keep the xxx_instance() functions being trivial, store the instance |
| 250 // pointer in a temporary variable to avoid losing its reference. | 263 // pointer in a temporary variable to avoid losing its reference. |
| 251 AppInstancePtr temporary_app_ptr_; | 264 AppInstancePtr temporary_app_ptr_; |
| 252 AuthInstancePtr temporary_auth_ptr_; | 265 AuthInstancePtr temporary_auth_ptr_; |
| 253 ClipboardInstancePtr temporary_clipboard_ptr_; | 266 ClipboardInstancePtr temporary_clipboard_ptr_; |
| 254 InputInstancePtr temporary_input_ptr_; | 267 InputInstancePtr temporary_input_ptr_; |
| 268 IntentHelperInstancePtr temporary_intent_helper_ptr_; |
| 255 NotificationsInstancePtr temporary_notifications_ptr_; | 269 NotificationsInstancePtr temporary_notifications_ptr_; |
| 256 PowerInstancePtr temporary_power_ptr_; | 270 PowerInstancePtr temporary_power_ptr_; |
| 257 ProcessInstancePtr temporary_process_ptr_; | 271 ProcessInstancePtr temporary_process_ptr_; |
| 258 SettingsInstancePtr temporary_settings_ptr_; | 272 SettingsInstancePtr temporary_settings_ptr_; |
| 259 VideoInstancePtr temporary_video_ptr_; | 273 VideoInstancePtr temporary_video_ptr_; |
| 260 | 274 |
| 261 base::ObserverList<Observer> observer_list_; | 275 base::ObserverList<Observer> observer_list_; |
| 262 | 276 |
| 263 base::ThreadChecker thread_checker_; | 277 base::ThreadChecker thread_checker_; |
| 264 | 278 |
| 265 // If the ARC instance service is available. | 279 // If the ARC instance service is available. |
| 266 bool available_; | 280 bool available_; |
| 267 | 281 |
| 268 // The current state of the bridge. | 282 // The current state of the bridge. |
| 269 ArcBridgeService::State state_; | 283 ArcBridgeService::State state_; |
| 270 | 284 |
| 271 // WeakPtrFactory to use callbacks. | 285 // WeakPtrFactory to use callbacks. |
| 272 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 286 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
| 273 | 287 |
| 274 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 288 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
| 275 }; | 289 }; |
| 276 | 290 |
| 277 } // namespace arc | 291 } // namespace arc |
| 278 | 292 |
| 279 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 293 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
| OLD | NEW |