Chromium Code Reviews| Index: components/arc/arc_session_runner.h |
| diff --git a/components/arc/arc_session_runner.h b/components/arc/arc_session_runner.h |
| index 8eeeabd14dc3f2d85d442feb662bdb9f92a9a5b1..2bed010ab93281f1fba497be4be359df89827d17 100644 |
| --- a/components/arc/arc_session_runner.h |
| +++ b/components/arc/arc_session_runner.h |
| @@ -11,28 +11,40 @@ |
| #include "base/macros.h" |
| #include "base/time/time.h" |
| #include "base/timer/timer.h" |
| -#include "components/arc/arc_bridge_service.h" |
| -#include "components/arc/arc_session_observer.h" |
| +#include "components/arc/arc_session.h" |
| +#include "components/arc/arc_stop_reason.h" |
| namespace arc { |
| -class ArcSession; |
| - |
| // Accept requests to start/stop ARC instance. Also supports automatic |
| // restarting on unexpected ARC instance crash. |
| -// TODO(hidehiko): Get rid of ArcBridgeService inheritance. |
| -class ArcSessionRunner : public ArcSessionObserver { |
| +class ArcSessionRunner : public ArcSession::Observer { |
| public: |
| + class Observer { |
|
Yusuke Sato
2017/03/01 15:51:01
same?
hidehiko
2017/03/01 17:28:03
Done.
|
| + public: |
| + // Called when ARC instance is stopped. If |restarting| is true, another |
| + // ARC session is being restarted (practically after certain delay). |
| + // Note: this is called once per ARC session, including unexpected |
| + // CRASH on ARC container, and expected SHUTDOWN of ARC triggered by |
| + // RequestStop(), so may be called multiple times for one RequestStart(). |
| + virtual void OnSessionStopped(ArcStopReason reason, bool restarting) = 0; |
| + |
| + protected: |
| + // Do not directly create/destroy the instance via the interface. |
| + Observer() = default; |
| + ~Observer() = default; |
| + }; |
| + |
| // This is the factory interface to inject ArcSession instance |
| // for testing purpose. |
| using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>; |
| explicit ArcSessionRunner(const ArcSessionFactory& factory); |
| - ~ArcSessionRunner() override; |
| + ~ArcSessionRunner(); |
| // Add/Remove an observer. |
| - void AddObserver(ArcSessionObserver* observer); |
| - void RemoveObserver(ArcSessionObserver* observer); |
| + void AddObserver(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| // Starts the ARC service, then it will connect the Mojo channel. When the |
| // bridge becomes ready, registered Observer's OnSessionReady() is called. |
| @@ -68,7 +80,7 @@ class ArcSessionRunner : public ArcSessionObserver { |
| // RequestStart() -> |
| // STARTING |
| // OnSessionReady() -> |
| - // READY |
| + // RUNNING |
| // |
| // The ArcSession state machine can be thought of being substates of |
| // ArcBridgeService's STARTING state. |
| @@ -97,14 +109,14 @@ class ArcSessionRunner : public ArcSessionObserver { |
| // Starts to run an ARC instance. |
| void StartArcSession(); |
| - // ArcSessionObserver: |
| + // ArcSession::Observer: |
| void OnSessionReady() override; |
| - void OnSessionStopped(StopReason reason) override; |
| + void OnSessionStopped(ArcStopReason reason) override; |
| base::ThreadChecker thread_checker_; |
| // Observers for the ARC instance state change events. |
| - base::ObserverList<ArcSessionObserver> observer_list_; |
| + base::ObserverList<Observer> observer_list_; |
| // Whether a client requests to run session or not. |
| bool run_requested_ = false; |