Chromium Code Reviews| Index: components/arc/arc_bridge_service.h |
| diff --git a/components/arc/arc_bridge_service.h b/components/arc/arc_bridge_service.h |
| index 3d719694314ee0219463b873144255e23136cbde..15f435a9ff35c652bb8e6046393a7443d9eaec2f 100644 |
| --- a/components/arc/arc_bridge_service.h |
| +++ b/components/arc/arc_bridge_service.h |
| @@ -21,8 +21,6 @@ class CommandLine; |
| namespace arc { |
| -class ArcBridgeBootstrap; |
| - |
| // The Chrome-side service that handles ARC instances and ARC bridge creation. |
| // This service handles the lifetime of ARC instances and sets up the |
| // communication channel (the ARC bridge) used to send and receive messages. |
| @@ -63,14 +61,32 @@ class ArcBridgeService : public mojom::ArcBridgeHost { |
| STOPPING, |
| }; |
| + // Describes the reason the bridge is stopped. |
| + enum class StopReason { |
| + // No error. |
| + NO_ERROR, |
|
Luis Héctor Chávez
2016/07/11 22:28:50
nit: I'd rename this to SHUTDOWN (and the descript
Shuhei Takahashi
2016/07/12 06:13:57
Sure, done.
|
| + |
| + // Errors occurred during the ARC instance boot. This includes any failures |
| + // before the instance is actually attempted to be started, and also |
| + // failures on bootstrapping IPC channels with Android. |
| + GENERIC_BOOT_FAILURE, |
| + |
| + // ARC instance has crashed. |
| + CRASH, |
| + }; |
| + |
| // Notifies life cycle events of ArcBridgeService. |
| class Observer { |
| public: |
| // Called whenever the state of the bridge has changed. |
| // TODO(lchavez): Rename to OnStateChangedForTest |
| virtual void OnStateChanged(State state) {} |
| + |
| + // Called whenever the bridge is ready. |
| virtual void OnBridgeReady() {} |
| - virtual void OnBridgeStopped() {} |
| + |
| + // Called whenever the bridge is stopped. |
| + virtual void OnBridgeStopped(StopReason reason) {} |
| // Called whenever ARC's availability has changed for this system. |
| virtual void OnAvailableChanged(bool available) {} |
| @@ -298,6 +314,11 @@ class ArcBridgeService : public mojom::ArcBridgeHost { |
| // Changes the current availability and notifies all observers. |
| void SetAvailable(bool availability); |
| + // Sets the reason the bridge is stopped. This function must be always called |
| + // before SetState(State::STOPPED) to report a correct reason with |
| + // Observer::OnBridgeStopped(). |
| + void SetStopReason(StopReason stop_reason); |
| + |
| base::ObserverList<Observer>& observer_list() { return observer_list_; } |
| bool CalledOnValidThread(); |
| @@ -311,6 +332,8 @@ class ArcBridgeService : public mojom::ArcBridgeHost { |
| FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
| FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
| FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); |
| + FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, BootFailure); |
| + FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Crash); |
| // Called when one of the individual channels is closed. |
| void CloseAppChannel(); |
| @@ -411,6 +434,9 @@ class ArcBridgeService : public mojom::ArcBridgeHost { |
| // The current state of the bridge. |
| ArcBridgeService::State state_; |
| + // The reason the bridge is stopped. |
| + StopReason stop_reason_; |
| + |
| // WeakPtrFactory to use callbacks. |
| base::WeakPtrFactory<ArcBridgeService> weak_factory_; |