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/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "components/arc/common/arc_bridge.mojom.h" | 16 #include "components/arc/common/arc_bridge.mojom.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class CommandLine; | 19 class CommandLine; |
20 } // namespace base | 20 } // namespace base |
21 | 21 |
22 namespace arc { | 22 namespace arc { |
23 | 23 |
24 class ArcBridgeBootstrap; | |
25 | |
26 // The Chrome-side service that handles ARC instances and ARC bridge creation. | 24 // The Chrome-side service that handles ARC instances and ARC bridge creation. |
27 // This service handles the lifetime of ARC instances and sets up the | 25 // This service handles the lifetime of ARC instances and sets up the |
28 // communication channel (the ARC bridge) used to send and receive messages. | 26 // communication channel (the ARC bridge) used to send and receive messages. |
29 class ArcBridgeService : public mojom::ArcBridgeHost { | 27 class ArcBridgeService : public mojom::ArcBridgeHost { |
30 public: | 28 public: |
31 // The possible states of the bridge. In the normal flow, the state changes | 29 // The possible states of the bridge. In the normal flow, the state changes |
32 // in the following sequence: | 30 // in the following sequence: |
33 // | 31 // |
34 // STOPPED | 32 // STOPPED |
35 // PrerequisitesChanged() -> | 33 // PrerequisitesChanged() -> |
(...skipping 20 matching lines...) Expand all Loading... | |
56 CONNECTED, | 54 CONNECTED, |
57 | 55 |
58 // The ARC instance has finished initializing and is now ready for user | 56 // The ARC instance has finished initializing and is now ready for user |
59 // interaction. | 57 // interaction. |
60 READY, | 58 READY, |
61 | 59 |
62 // The ARC instance has started shutting down. | 60 // The ARC instance has started shutting down. |
63 STOPPING, | 61 STOPPING, |
64 }; | 62 }; |
65 | 63 |
64 // Describes the reason the bridge is being aborted. | |
65 enum class AbortReason { | |
66 // ARC instance boot failed for unknown errors. | |
Luis Héctor Chávez
2016/07/08 18:01:02
nit: it's better to say that this is just any erro
Shuhei Takahashi
2016/07/11 08:25:19
Thanks, I've updated the comment. Does it look goo
Luis Héctor Chávez
2016/07/11 22:28:50
It does, thanks!
| |
67 GENERIC_BOOT_FAILURE, | |
68 | |
69 // ARC instance has crashed. | |
70 CRASH, | |
71 }; | |
72 | |
66 // Notifies life cycle events of ArcBridgeService. | 73 // Notifies life cycle events of ArcBridgeService. |
67 class Observer { | 74 class Observer { |
68 public: | 75 public: |
69 // Called whenever the state of the bridge has changed. | 76 // Called whenever the state of the bridge has changed. |
70 // TODO(lchavez): Rename to OnStateChangedForTest | 77 // TODO(lchavez): Rename to OnStateChangedForTest |
71 virtual void OnStateChanged(State state) {} | 78 virtual void OnStateChanged(State state) {} |
79 | |
80 // Called whenever the bridge got ready. | |
Luis Héctor Chávez
2016/07/08 18:01:02
nit: the bridge is ready.
Shuhei Takahashi
2016/07/11 08:25:19
Done.
| |
72 virtual void OnBridgeReady() {} | 81 virtual void OnBridgeReady() {} |
82 | |
83 // Called whenever the bridge is being aborted due to errors. | |
84 // After this callback is invoked, the ARC instance will be stopped, so | |
85 // you do not need to call ArcBridgeServiceImpl::StopInstance() in the | |
86 // callback. | |
87 virtual void OnBridgeAborting(AbortReason reason) {} | |
88 | |
89 // Called whenever the bridge stopped. | |
Luis Héctor Chávez
2016/07/08 18:01:02
nit: the bridge is stopped.
Shuhei Takahashi
2016/07/11 08:25:19
Done.
| |
90 // When the bridge aborted due to errors, OnBridgeAborting() is called | |
91 // first, then OnBridgeStopped() is called once the instance is stopped. | |
73 virtual void OnBridgeStopped() {} | 92 virtual void OnBridgeStopped() {} |
74 | 93 |
75 // Called whenever ARC's availability has changed for this system. | 94 // Called whenever ARC's availability has changed for this system. |
76 virtual void OnAvailableChanged(bool available) {} | 95 virtual void OnAvailableChanged(bool available) {} |
77 | 96 |
78 // Called whenever the ARC app interface state changes. | 97 // Called whenever the ARC app interface state changes. |
79 virtual void OnAppInstanceReady() {} | 98 virtual void OnAppInstanceReady() {} |
80 virtual void OnAppInstanceClosed() {} | 99 virtual void OnAppInstanceClosed() {} |
81 | 100 |
82 // Called whenever the ARC audio interface state changes. | 101 // Called whenever the ARC audio interface state changes. |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 | 432 |
414 // WeakPtrFactory to use callbacks. | 433 // WeakPtrFactory to use callbacks. |
415 base::WeakPtrFactory<ArcBridgeService> weak_factory_; | 434 base::WeakPtrFactory<ArcBridgeService> weak_factory_; |
416 | 435 |
417 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); | 436 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); |
418 }; | 437 }; |
419 | 438 |
420 } // namespace arc | 439 } // namespace arc |
421 | 440 |
422 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ | 441 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ |
OLD | NEW |