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

Unified Diff: components/arc/arc_bridge_bootstrap.h

Issue 2379223004: Switch from Delegate to Observer. (Closed)
Patch Set: Rebase Created 4 years, 2 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/BUILD.gn ('k') | components/arc/arc_bridge_bootstrap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/arc_bridge_bootstrap.h
diff --git a/components/arc/arc_bridge_bootstrap.h b/components/arc/arc_bridge_bootstrap.h
index a5666b386913791b5b9df2de61face984b6c6d46..45d2d72d0149ebb0ddd8c2cab59d7685b0009112 100644
--- a/components/arc/arc_bridge_bootstrap.h
+++ b/components/arc/arc_bridge_bootstrap.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/macros.h"
+#include "base/observer_list.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "components/arc/arc_bridge_service.h"
@@ -26,27 +27,25 @@ namespace arc {
// Rename this to ArcSession.
class ArcBridgeBootstrap {
public:
- // TODO(hidehiko): Switch to Observer style, which fits more for this design.
- class Delegate {
+ class Observer {
public:
+ Observer() = default;
+ virtual ~Observer() = default;
+
// Called when the connection with ARC instance has been established.
- // TODO(hidehiko): Moving ArcBridgeHost to the ArcBridgeBootstrapImpl
- // so that this can be replaced by OnReady() simply.
- virtual void OnConnectionEstablished(
- mojom::ArcBridgeInstancePtr instance_ptr) = 0;
+ virtual void OnReady() = 0;
// Called when ARC instance is stopped. This is called exactly once
// per instance which is Start()ed.
virtual void OnStopped(ArcBridgeService::StopReason reason) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Observer);
};
// Creates a default instance of ArcBridgeBootstrap.
static std::unique_ptr<ArcBridgeBootstrap> Create();
- virtual ~ArcBridgeBootstrap() = default;
-
- // This must be called before calling Start() or Stop(). |delegate| is owned
- // by the caller and must outlive this instance.
- void set_delegate(Delegate* delegate) { delegate_ = delegate; }
+ virtual ~ArcBridgeBootstrap();
// Starts and bootstraps a connection with the instance. The Delegate's
// OnConnectionEstablished() will be called if the bootstrapping is
@@ -58,11 +57,13 @@ class ArcBridgeBootstrap {
// The completion is notified via OnStopped() of the Delegate.
virtual void Stop() = 0;
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
protected:
- ArcBridgeBootstrap() = default;
+ ArcBridgeBootstrap();
- // Owned by the caller.
- Delegate* delegate_ = nullptr;
+ base::ObserverList<Observer> observer_list_;
private:
DISALLOW_COPY_AND_ASSIGN(ArcBridgeBootstrap);
« no previous file with comments | « components/arc/BUILD.gn ('k') | components/arc/arc_bridge_bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698