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 |
11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "components/arc/common/arc_bridge.mojom.h" | 17 #include "components/arc/common/arc_bridge.mojom.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class CommandLine; | 20 class CommandLine; |
21 } // namespace base | 21 } // namespace base |
22 | 22 |
23 namespace arc { | 23 namespace arc { |
24 | 24 |
25 class ArcBridgeBootstrap; | 25 class ArcBridgeBootstrap; |
26 | 26 |
27 // The Chrome-side service that handles ARC instances and ARC bridge creation. | 27 // The Chrome-side service that handles ARC instances and ARC bridge creation. |
28 // This service handles the lifetime of ARC instances and sets up the | 28 // This service handles the lifetime of ARC instances and sets up the |
29 // communication channel (the ARC bridge) used to send and receive messages. | 29 // communication channel (the ARC bridge) used to send and receive messages. |
30 class ArcBridgeService : public ArcBridgeHost { | 30 class ArcBridgeService : public mojom::ArcBridgeHost { |
31 public: | 31 public: |
32 // The possible states of the bridge. In the normal flow, the state changes | 32 // The possible states of the bridge. In the normal flow, the state changes |
33 // in the following sequence: | 33 // in the following sequence: |
34 // | 34 // |
35 // STOPPED | 35 // STOPPED |
36 // PrerequisitesChanged() -> | 36 // PrerequisitesChanged() -> |
37 // CONNECTING | 37 // CONNECTING |
38 // OnConnectionEstablished() -> | 38 // OnConnectionEstablished() -> |
39 // READY | 39 // READY |
40 // | 40 // |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 // Adds or removes observers. This can only be called on the thread that this | 164 // Adds or removes observers. This can only be called on the thread that this |
165 // class was created on. | 165 // class was created on. |
166 void AddObserver(Observer* observer); | 166 void AddObserver(Observer* observer); |
167 void RemoveObserver(Observer* observer); | 167 void RemoveObserver(Observer* observer); |
168 | 168 |
169 // Gets the Mojo interface for all the instance services. This will return | 169 // Gets the Mojo interface for all the instance services. This will return |
170 // nullptr if that particular service is not ready yet. Use an Observer if | 170 // nullptr if that particular service is not ready yet. Use an Observer if |
171 // you want to be notified when this is ready. This can only be called on the | 171 // you want to be notified when this is ready. This can only be called on the |
172 // thread that this class was created on. | 172 // thread that this class was created on. |
173 AppInstance* app_instance() { return app_ptr_.get(); } | 173 mojom::AppInstance* app_instance() { return app_ptr_.get(); } |
174 AudioInstance* audio_instance() { return audio_ptr_.get(); } | 174 mojom::AudioInstance* audio_instance() { return audio_ptr_.get(); } |
175 AuthInstance* auth_instance() { return auth_ptr_.get(); } | 175 mojom::AuthInstance* auth_instance() { return auth_ptr_.get(); } |
176 BluetoothInstance* bluetooth_instance() { return bluetooth_ptr_.get(); } | 176 mojom::BluetoothInstance* bluetooth_instance() { |
177 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); } | 177 return bluetooth_ptr_.get(); |
178 CrashCollectorInstance* crash_collector_instance() { | 178 } |
| 179 mojom::ClipboardInstance* clipboard_instance() { |
| 180 return clipboard_ptr_.get(); |
| 181 } |
| 182 mojom::CrashCollectorInstance* crash_collector_instance() { |
179 return crash_collector_ptr_.get(); | 183 return crash_collector_ptr_.get(); |
180 } | 184 } |
181 ImeInstance* ime_instance() { return ime_ptr_.get(); } | 185 mojom::ImeInstance* ime_instance() { return ime_ptr_.get(); } |
182 InputInstance* input_instance() { return input_ptr_.get(); } | 186 mojom::InputInstance* input_instance() { return input_ptr_.get(); } |
183 IntentHelperInstance* intent_helper_instance() { | 187 mojom::IntentHelperInstance* intent_helper_instance() { |
184 return intent_helper_ptr_.get(); | 188 return intent_helper_ptr_.get(); |
185 } | 189 } |
186 NetInstance* net_instance() { return net_ptr_.get(); } | 190 mojom::NetInstance* net_instance() { return net_ptr_.get(); } |
187 NotificationsInstance* notifications_instance() { | 191 mojom::NotificationsInstance* notifications_instance() { |
188 return notifications_ptr_.get(); | 192 return notifications_ptr_.get(); |
189 } | 193 } |
190 PolicyInstance* policy_instance() { return policy_ptr_.get(); } | 194 mojom::PolicyInstance* policy_instance() { return policy_ptr_.get(); } |
191 PowerInstance* power_instance() { return power_ptr_.get(); } | 195 mojom::PowerInstance* power_instance() { return power_ptr_.get(); } |
192 ProcessInstance* process_instance() { return process_ptr_.get(); } | 196 mojom::ProcessInstance* process_instance() { return process_ptr_.get(); } |
193 VideoInstance* video_instance() { return video_ptr_.get(); } | 197 mojom::VideoInstance* video_instance() { return video_ptr_.get(); } |
194 | 198 |
195 int32_t app_version() const { return app_ptr_.version(); } | 199 int32_t app_version() const { return app_ptr_.version(); } |
196 int32_t audio_version() const { return audio_ptr_.version(); } | 200 int32_t audio_version() const { return audio_ptr_.version(); } |
197 int32_t bluetooth_version() const { return bluetooth_ptr_.version(); } | 201 int32_t bluetooth_version() const { return bluetooth_ptr_.version(); } |
198 int32_t auth_version() const { return auth_ptr_.version(); } | 202 int32_t auth_version() const { return auth_ptr_.version(); } |
199 int32_t clipboard_version() const { return clipboard_ptr_.version(); } | 203 int32_t clipboard_version() const { return clipboard_ptr_.version(); } |
200 int32_t crash_collector_version() const { | 204 int32_t crash_collector_version() const { |
201 return crash_collector_ptr_.version(); | 205 return crash_collector_ptr_.version(); |
202 } | 206 } |
203 int32_t ime_version() const { return ime_ptr_.version(); } | 207 int32_t ime_version() const { return ime_ptr_.version(); } |
204 int32_t input_version() const { return input_ptr_.version(); } | 208 int32_t input_version() const { return input_ptr_.version(); } |
205 int32_t intent_helper_version() const { return intent_helper_ptr_.version(); } | 209 int32_t intent_helper_version() const { return intent_helper_ptr_.version(); } |
206 int32_t net_version() const { return net_ptr_.version(); } | 210 int32_t net_version() const { return net_ptr_.version(); } |
207 int32_t notifications_version() const { return notifications_ptr_.version(); } | 211 int32_t notifications_version() const { return notifications_ptr_.version(); } |
208 int32_t policy_version() const { return policy_ptr_.version(); } | 212 int32_t policy_version() const { return policy_ptr_.version(); } |
209 int32_t power_version() const { return power_ptr_.version(); } | 213 int32_t power_version() const { return power_ptr_.version(); } |
210 int32_t process_version() const { return process_ptr_.version(); } | 214 int32_t process_version() const { return process_ptr_.version(); } |
211 int32_t video_version() const { return video_ptr_.version(); } | 215 int32_t video_version() const { return video_ptr_.version(); } |
212 | 216 |
213 // ArcHost: | 217 // ArcHost: |
214 void OnAppInstanceReady(AppInstancePtr app_ptr) override; | 218 void OnAppInstanceReady(mojom::AppInstancePtr app_ptr) override; |
215 void OnAudioInstanceReady(AudioInstancePtr audio_ptr) override; | 219 void OnAudioInstanceReady(mojom::AudioInstancePtr audio_ptr) override; |
216 void OnAuthInstanceReady(AuthInstancePtr auth_ptr) override; | 220 void OnAuthInstanceReady(mojom::AuthInstancePtr auth_ptr) override; |
217 void OnBluetoothInstanceReady(BluetoothInstancePtr bluetooth_ptr) override; | 221 void OnBluetoothInstanceReady( |
218 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override; | 222 mojom::BluetoothInstancePtr bluetooth_ptr) override; |
| 223 void OnClipboardInstanceReady( |
| 224 mojom::ClipboardInstancePtr clipboard_ptr) override; |
219 void OnCrashCollectorInstanceReady( | 225 void OnCrashCollectorInstanceReady( |
220 CrashCollectorInstancePtr crash_collector_ptr) override; | 226 mojom::CrashCollectorInstancePtr crash_collector_ptr) override; |
221 void OnImeInstanceReady(ImeInstancePtr ime_ptr) override; | 227 void OnImeInstanceReady(mojom::ImeInstancePtr ime_ptr) override; |
222 void OnInputInstanceReady(InputInstancePtr input_ptr) override; | 228 void OnInputInstanceReady(mojom::InputInstancePtr input_ptr) override; |
223 void OnIntentHelperInstanceReady( | 229 void OnIntentHelperInstanceReady( |
224 IntentHelperInstancePtr intent_helper_ptr) override; | 230 mojom::IntentHelperInstancePtr intent_helper_ptr) override; |
225 void OnNetInstanceReady(NetInstancePtr net_ptr) override; | 231 void OnNetInstanceReady(mojom::NetInstancePtr net_ptr) override; |
226 void OnNotificationsInstanceReady( | 232 void OnNotificationsInstanceReady( |
227 NotificationsInstancePtr notifications_ptr) override; | 233 mojom::NotificationsInstancePtr notifications_ptr) override; |
228 void OnPolicyInstanceReady(PolicyInstancePtr policy_ptr) override; | 234 void OnPolicyInstanceReady(mojom::PolicyInstancePtr policy_ptr) override; |
229 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; | 235 void OnPowerInstanceReady(mojom::PowerInstancePtr power_ptr) override; |
230 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; | 236 void OnProcessInstanceReady(mojom::ProcessInstancePtr process_ptr) override; |
231 void OnVideoInstanceReady(VideoInstancePtr video_ptr) override; | 237 void OnVideoInstanceReady(mojom::VideoInstancePtr video_ptr) override; |
232 | 238 |
233 // Gets the current state of the bridge service. | 239 // Gets the current state of the bridge service. |
234 State state() const { return state_; } | 240 State state() const { return state_; } |
235 | 241 |
236 // Gets if ARC is available in this system. | 242 // Gets if ARC is available in this system. |
237 bool available() const { return available_; } | 243 bool available() const { return available_; } |
238 | 244 |
239 protected: | 245 protected: |
240 ArcBridgeService(); | 246 ArcBridgeService(); |
241 | 247 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 void OnInputVersionReady(int32_t version); | 293 void OnInputVersionReady(int32_t version); |
288 void OnIntentHelperVersionReady(int32_t version); | 294 void OnIntentHelperVersionReady(int32_t version); |
289 void OnNetVersionReady(int32_t version); | 295 void OnNetVersionReady(int32_t version); |
290 void OnNotificationsVersionReady(int32_t version); | 296 void OnNotificationsVersionReady(int32_t version); |
291 void OnPolicyVersionReady(int32_t version); | 297 void OnPolicyVersionReady(int32_t version); |
292 void OnPowerVersionReady(int32_t version); | 298 void OnPowerVersionReady(int32_t version); |
293 void OnProcessVersionReady(int32_t version); | 299 void OnProcessVersionReady(int32_t version); |
294 void OnVideoVersionReady(int32_t version); | 300 void OnVideoVersionReady(int32_t version); |
295 | 301 |
296 // Mojo interfaces. | 302 // Mojo interfaces. |
297 AppInstancePtr app_ptr_; | 303 mojom::AppInstancePtr app_ptr_; |
298 AudioInstancePtr audio_ptr_; | 304 mojom::AudioInstancePtr audio_ptr_; |
299 AuthInstancePtr auth_ptr_; | 305 mojom::AuthInstancePtr auth_ptr_; |
300 BluetoothInstancePtr bluetooth_ptr_; | 306 mojom::BluetoothInstancePtr bluetooth_ptr_; |
301 ClipboardInstancePtr clipboard_ptr_; | 307 mojom::ClipboardInstancePtr clipboard_ptr_; |
302 CrashCollectorInstancePtr crash_collector_ptr_; | 308 mojom::CrashCollectorInstancePtr crash_collector_ptr_; |
303 ImeInstancePtr ime_ptr_; | 309 mojom::ImeInstancePtr ime_ptr_; |
304 InputInstancePtr input_ptr_; | 310 mojom::InputInstancePtr input_ptr_; |
305 IntentHelperInstancePtr intent_helper_ptr_; | 311 mojom::IntentHelperInstancePtr intent_helper_ptr_; |
306 NetInstancePtr net_ptr_; | 312 mojom::NetInstancePtr net_ptr_; |
307 NotificationsInstancePtr notifications_ptr_; | 313 mojom::NotificationsInstancePtr notifications_ptr_; |
308 PolicyInstancePtr policy_ptr_; | 314 mojom::PolicyInstancePtr policy_ptr_; |
309 PowerInstancePtr power_ptr_; | 315 mojom::PowerInstancePtr power_ptr_; |
310 ProcessInstancePtr process_ptr_; | 316 mojom::ProcessInstancePtr process_ptr_; |
311 VideoInstancePtr video_ptr_; | 317 mojom::VideoInstancePtr video_ptr_; |
312 | 318 |
313 // Temporary Mojo interfaces. After a Mojo interface pointer has been | 319 // Temporary Mojo interfaces. After a Mojo interface pointer has been |
314 // received from the other endpoint, we still need to asynchronously query | 320 // received from the other endpoint, we still need to asynchronously query |
315 // its version. While that is going on, we should still return nullptr on | 321 // its version. While that is going on, we should still return nullptr on |
316 // the xxx_instance() functions. | 322 // the xxx_instance() functions. |
317 // To keep the xxx_instance() functions being trivial, store the instance | 323 // To keep the xxx_instance() functions being trivial, store the instance |
318 // pointer in a temporary variable to avoid losing its reference. | 324 // pointer in a temporary variable to avoid losing its reference. |
319 AppInstancePtr temporary_app_ptr_; | 325 mojom::AppInstancePtr temporary_app_ptr_; |
320 AudioInstancePtr temporary_audio_ptr_; | 326 mojom::AudioInstancePtr temporary_audio_ptr_; |
321 AuthInstancePtr temporary_auth_ptr_; | 327 mojom::AuthInstancePtr temporary_auth_ptr_; |
322 BluetoothInstancePtr temporary_bluetooth_ptr_; | 328 mojom::BluetoothInstancePtr temporary_bluetooth_ptr_; |
323 ClipboardInstancePtr temporary_clipboard_ptr_; | 329 mojom::ClipboardInstancePtr temporary_clipboard_ptr_; |
324 CrashCollectorInstancePtr temporary_crash_collector_ptr_; | 330 mojom::CrashCollectorInstancePtr temporary_crash_collector_ptr_; |
325 ImeInstancePtr temporary_ime_ptr_; | 331 mojom::ImeInstancePtr temporary_ime_ptr_; |
326 InputInstancePtr temporary_input_ptr_; | 332 mojom::InputInstancePtr temporary_input_ptr_; |
327 IntentHelperInstancePtr temporary_intent_helper_ptr_; | 333 mojom::IntentHelperInstancePtr temporary_intent_helper_ptr_; |
328 NetInstancePtr temporary_net_ptr_; | 334 mojom::NetInstancePtr temporary_net_ptr_; |
329 NotificationsInstancePtr temporary_notifications_ptr_; | 335 mojom::NotificationsInstancePtr temporary_notifications_ptr_; |
330 PolicyInstancePtr temporary_policy_ptr_; | 336 mojom::PolicyInstancePtr temporary_policy_ptr_; |
331 PowerInstancePtr temporary_power_ptr_; | 337 mojom::PowerInstancePtr temporary_power_ptr_; |
332 ProcessInstancePtr temporary_process_ptr_; | 338 mojom::ProcessInstancePtr temporary_process_ptr_; |
333 VideoInstancePtr temporary_video_ptr_; | 339 mojom::VideoInstancePtr temporary_video_ptr_; |
334 | 340 |
335 base::ObserverList<Observer> observer_list_; | 341 base::ObserverList<Observer> observer_list_; |
336 | 342 |
337 base::ThreadChecker thread_checker_; | 343 base::ThreadChecker thread_checker_; |
338 | 344 |
339 // If the ARC instance service is available. | 345 // If the ARC instance service is available. |
340 bool available_; | 346 bool available_; |
341 | 347 |
342 // The current state of the bridge. | 348 // The current state of the bridge. |
343 ArcBridgeService::State state_; | 349 ArcBridgeService::State state_; |
344 | 350 |
345 // WeakPtrFactory to use callbacks. | 351 // WeakPtrFactory to use callbacks. |
346 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 352 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
347 | 353 |
348 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 354 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
349 }; | 355 }; |
350 | 356 |
351 } // namespace arc | 357 } // namespace arc |
352 | 358 |
353 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 359 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
OLD | NEW |