Chromium Code Reviews| 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..01fdc19c6da17a4c88018e1f2bb452ef852b32c0 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,14 +27,10 @@ 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: |
|
Luis Héctor Chávez
2016/10/03 18:05:32
hmmm looks like we (I?) missed adding a virtual de
hidehiko
2016/10/04 05:34:45
Good catch. Done.
|
| // 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. |
| @@ -42,11 +39,7 @@ class ArcBridgeBootstrap { |
| // 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 +51,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); |