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

Unified Diff: components/arc/arc_bridge_bootstrap.h

Issue 2194193002: Fix ArcBridgeBootstrap race issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ArcBridgeBootstrap race issues. Created 4 years, 5 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
Index: components/arc/arc_bridge_bootstrap.h
diff --git a/components/arc/arc_bridge_bootstrap.h b/components/arc/arc_bridge_bootstrap.h
index 25a59f88dbfe29926e0c741787b1dbade6fb4921..8aef4cd01d94963b8410b7a0db3934d0a2388c06 100644
--- a/components/arc/arc_bridge_bootstrap.h
+++ b/components/arc/arc_bridge_bootstrap.h
@@ -18,15 +18,25 @@ namespace arc {
// Starts the ARC instance and bootstraps the bridge connection.
// Clients should implement the Delegate to be notified upon communications
// being available.
+// The instance can be safely removed 1) before Start() is called, or 2) after
+// OnStopped() is called.
+// The number of instances must be at most one. Otherwise, ARC instances will
+// conflict.
+// TODO(hidehiko): This class manages more than "bootstrap" procedure now.
+// Rename this to ArcSession.
class ArcBridgeBootstrap {
public:
+ // TODO(hidehiko): Switch to Observer style, which fits more for this design.
class Delegate {
public:
// Called when the connection with ARC instance has been established.
- virtual void OnConnectionEstablished(
- mojom::ArcBridgeInstancePtr instance_ptr) = 0;
+ // This can be called after Start() at most once.
+ // On error case, OnStopped() below is called, and OnReady() may not
+ // called.
+ virtual void OnReady() = 0;
- // Called when ARC instance is stopped.
+ // Called when ARC instance is stopped. This is called exactly once
+ // per instance which is Start()ed.
virtual void OnStopped(ArcBridgeService::StopReason reason) = 0;
};
@@ -39,11 +49,13 @@ class ArcBridgeBootstrap {
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
// Starts and bootstraps a connection with the instance. The Delegate's
- // OnConnectionEstablished() will be called if the bootstrapping is
- // successful, or OnStopped() if it is not.
+ // OnReady() will be called if the bootstrapping is successful, or
+ // OnStopped() if it is not.
+ // Start() cannot be called twice or more.
Luis Héctor Chávez 2016/08/01 17:47:38 nit: s/cannot/should not/
hidehiko 2016/08/02 11:36:22 Done.
virtual void Start() = 0;
- // Stops the currently-running instance.
+ // Requests to stop the currently-running instance.
+ // The completion is notified via OnStopped() of the Delegate.
virtual void Stop() = 0;
protected:

Powered by Google App Engine
This is Rietveld 408576698