| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 auth interface state changes. | 80 // Called whenever the ARC auth interface state changes. |
| 81 virtual void OnAuthInstanceReady() {} | 81 virtual void OnAuthInstanceReady() {} |
| 82 virtual void OnAuthInstanceClosed() {} | 82 virtual void OnAuthInstanceClosed() {} |
| 83 | 83 |
| 84 // Called whenever the ARC clipboard interface state changes. |
| 85 virtual void OnClipboardInstanceReady() {} |
| 86 virtual void OnClipboardInstanceClosed() {} |
| 87 |
| 84 // Called whenever the ARC input interface state changes. | 88 // Called whenever the ARC input interface state changes. |
| 85 virtual void OnInputInstanceReady() {} | 89 virtual void OnInputInstanceReady() {} |
| 86 virtual void OnInputInstanceClosed() {} | 90 virtual void OnInputInstanceClosed() {} |
| 87 | 91 |
| 88 // Called whenever the ARC notification interface state changes. | 92 // Called whenever the ARC notification interface state changes. |
| 89 virtual void OnNotificationsInstanceReady() {} | 93 virtual void OnNotificationsInstanceReady() {} |
| 90 virtual void OnNotificationsInstanceClosed() {} | 94 virtual void OnNotificationsInstanceClosed() {} |
| 91 | 95 |
| 92 // Called whenever the ARC power interface state changes. | 96 // Called whenever the ARC power interface state changes. |
| 93 virtual void OnPowerInstanceReady() {} | 97 virtual void OnPowerInstanceReady() {} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // class was created on. | 137 // class was created on. |
| 134 void AddObserver(Observer* observer); | 138 void AddObserver(Observer* observer); |
| 135 void RemoveObserver(Observer* observer); | 139 void RemoveObserver(Observer* observer); |
| 136 | 140 |
| 137 // Gets the Mojo interface for all the instance services. This will return | 141 // Gets the Mojo interface for all the instance services. This will return |
| 138 // nullptr if that particular service is not ready yet. Use an Observer if | 142 // nullptr if that particular service is not ready yet. Use an Observer if |
| 139 // you want to be notified when this is ready. This can only be called on the | 143 // you want to be notified when this is ready. This can only be called on the |
| 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(); } |
| 147 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); } |
| 143 InputInstance* input_instance() { return input_ptr_.get(); } | 148 InputInstance* input_instance() { return input_ptr_.get(); } |
| 144 NotificationsInstance* notifications_instance() { | 149 NotificationsInstance* notifications_instance() { |
| 145 return notifications_ptr_.get(); | 150 return notifications_ptr_.get(); |
| 146 } | 151 } |
| 147 PowerInstance* power_instance() { return power_ptr_.get(); } | 152 PowerInstance* power_instance() { return power_ptr_.get(); } |
| 148 ProcessInstance* process_instance() { return process_ptr_.get(); } | 153 ProcessInstance* process_instance() { return process_ptr_.get(); } |
| 149 SettingsInstance* settings_instance() { return settings_ptr_.get(); } | 154 SettingsInstance* settings_instance() { return settings_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(); } |
| 158 int32_t clipboard_version() const { return clipboard_ptr_.version(); } |
| 153 int32_t input_version() const { return input_ptr_.version(); } | 159 int32_t input_version() const { return input_ptr_.version(); } |
| 154 int32_t notifications_version() const { return notifications_ptr_.version(); } | 160 int32_t notifications_version() const { return notifications_ptr_.version(); } |
| 155 int32_t power_version() const { return power_ptr_.version(); } | 161 int32_t power_version() const { return power_ptr_.version(); } |
| 156 int32_t process_version() const { return process_ptr_.version(); } | 162 int32_t process_version() const { return process_ptr_.version(); } |
| 157 int32_t settings_version() const { return settings_ptr_.version(); } | 163 int32_t settings_version() const { return settings_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; |
| 168 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override; |
| 162 void OnInputInstanceReady(InputInstancePtr input_ptr) override; | 169 void OnInputInstanceReady(InputInstancePtr input_ptr) override; |
| 163 void OnNotificationsInstanceReady( | 170 void OnNotificationsInstanceReady( |
| 164 NotificationsInstancePtr notifications_ptr) override; | 171 NotificationsInstancePtr notifications_ptr) override; |
| 165 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; | 172 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; |
| 166 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; | 173 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; |
| 167 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override; | 174 void OnSettingsInstanceReady(SettingsInstancePtr process_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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 191 private: | 198 private: |
| 192 friend class ArcBridgeTest; | 199 friend class ArcBridgeTest; |
| 193 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 200 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
| 194 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 201 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
| 195 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 202 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
| 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(); |
| 208 void CloseClipboardChannel(); |
| 201 void CloseInputChannel(); | 209 void CloseInputChannel(); |
| 202 void CloseNotificationsChannel(); | 210 void CloseNotificationsChannel(); |
| 203 void ClosePowerChannel(); | 211 void ClosePowerChannel(); |
| 204 void CloseProcessChannel(); | 212 void CloseProcessChannel(); |
| 205 void CloseSettingsChannel(); | 213 void CloseSettingsChannel(); |
| 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); |
| 218 void OnClipboardVersionReady(int32_t version); |
| 210 void OnInputVersionReady(int32_t version); | 219 void OnInputVersionReady(int32_t version); |
| 211 void OnNotificationsVersionReady(int32_t version); | 220 void OnNotificationsVersionReady(int32_t version); |
| 212 void OnPowerVersionReady(int32_t version); | 221 void OnPowerVersionReady(int32_t version); |
| 213 void OnProcessVersionReady(int32_t version); | 222 void OnProcessVersionReady(int32_t version); |
| 214 void OnSettingsVersionReady(int32_t version); | 223 void OnSettingsVersionReady(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_; |
| 228 ClipboardInstancePtr clipboard_ptr_; |
| 219 InputInstancePtr input_ptr_; | 229 InputInstancePtr input_ptr_; |
| 220 NotificationsInstancePtr notifications_ptr_; | 230 NotificationsInstancePtr notifications_ptr_; |
| 221 PowerInstancePtr power_ptr_; | 231 PowerInstancePtr power_ptr_; |
| 222 ProcessInstancePtr process_ptr_; | 232 ProcessInstancePtr process_ptr_; |
| 223 SettingsInstancePtr settings_ptr_; | 233 SettingsInstancePtr settings_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_; |
| 243 ClipboardInstancePtr temporary_clipboard_ptr_; |
| 233 InputInstancePtr temporary_input_ptr_; | 244 InputInstancePtr temporary_input_ptr_; |
| 234 NotificationsInstancePtr temporary_notifications_ptr_; | 245 NotificationsInstancePtr temporary_notifications_ptr_; |
| 235 PowerInstancePtr temporary_power_ptr_; | 246 PowerInstancePtr temporary_power_ptr_; |
| 236 ProcessInstancePtr temporary_process_ptr_; | 247 ProcessInstancePtr temporary_process_ptr_; |
| 237 SettingsInstancePtr temporary_settings_ptr_; | 248 SettingsInstancePtr temporary_settings_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 |