Chromium Code Reviews| Index: chrome/browser/extensions/api/dial/dial_registry.h |
| diff --git a/chrome/browser/extensions/api/dial/dial_registry.h b/chrome/browser/extensions/api/dial/dial_registry.h |
| index e43d207bff830aa3fbecae52d6ea9a674cc9cc01..b193b833439c9c589f9b9c5a54188653df994902 100644 |
| --- a/chrome/browser/extensions/api/dial/dial_registry.h |
| +++ b/chrome/browser/extensions/api/dial/dial_registry.h |
| @@ -16,6 +16,7 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/observer_list.h" |
| #include "base/time/time.h" |
| #include "base/timer/timer.h" |
| #include "chrome/browser/extensions/api/dial/dial_service.h" |
| @@ -57,8 +58,7 @@ class DialRegistry : public DialService::Observer, |
| // Create the DIAL registry and pass a reference to allow it to notify on |
| // DIAL device events. |
| - DialRegistry(Observer* dial_api, |
| - const base::TimeDelta& refresh_interval, |
| + DialRegistry(const base::TimeDelta& refresh_interval, |
|
imcheng
2017/03/06 20:56:30
base::TimeDelta is small enough that usually it is
zhaobin
2017/03/07 00:13:18
Done.
|
| const base::TimeDelta& expiration, |
| const size_t max_devices); |
| @@ -70,6 +70,10 @@ class DialRegistry : public DialService::Observer, |
| void OnListenerAdded(); |
| void OnListenerRemoved(); |
| + // This class does not take ownership of observer. |
| + void RegisterObserver(Observer* observer); |
| + void UnregisterObserver(Observer* observer); |
| + |
| // Called by the DIAL API to try to kickoff a discovery if there is not one |
| // already active. |
| bool DiscoverNow(); |
| @@ -111,6 +115,10 @@ class DialRegistry : public DialService::Observer, |
| void OnNetworkChanged( |
| net::NetworkChangeNotifier::ConnectionType type) override; |
| + // Notify all observers about DialDeviceEvent or DialError. |
| + void OnDialDeviceEvent(const DeviceList& devices); |
| + void OnDialError(DialErrorCode type); |
| + |
| // Starts and stops periodic discovery. Periodic discovery is done when there |
| // are registered event listeners. |
| void StartPeriodicDiscovery(); |
| @@ -178,7 +186,7 @@ class DialRegistry : public DialService::Observer, |
| // Interface from which the DIAL API is notified of DIAL device events. the |
| // DIAL API owns this DIAL registry. |
| - Observer* const dial_api_; |
| + base::ObserverList<Observer> observers_; |
| FRIEND_TEST_ALL_PREFIXES(DialRegistryTest, TestAddRemoveListeners); |
| FRIEND_TEST_ALL_PREFIXES(DialRegistryTest, TestNoDevicesDiscovered); |