Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: components/arc/arc_session_runner.h

Issue 2720303002: Do nothing on OnSessionStopped if ARC is being restarted. (Closed)
Patch Set: Address comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/arc/arc_session_observer.cc ('k') | components/arc/arc_session_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5de7585de266ebab3e79e1532399383c454d1fcf 100644
--- a/components/arc/arc_session_runner.h
+++ b/components/arc/arc_session_runner.h
@@ -11,18 +11,29 @@
#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:
+ // Observer to notify events across multiple ARC session runs.
+ class Observer {
+ 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:
+ virtual ~Observer() = default;
+ };
+
// This is the factory interface to inject ArcSession instance
// for testing purpose.
using ArcSessionFactory = base::Callback<std::unique_ptr<ArcSession>()>;
@@ -31,8 +42,8 @@ class ArcSessionRunner : public ArcSessionObserver {
~ArcSessionRunner() override;
// 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 +79,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 +108,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;
« no previous file with comments | « components/arc/arc_session_observer.cc ('k') | components/arc/arc_session_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698