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..fb39d420d3808edd7ac51911037978af469c5e5f 100644 |
| --- a/chrome/browser/extensions/api/dial/dial_registry.h |
| +++ b/chrome/browser/extensions/api/dial/dial_registry.h |
| @@ -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_; |
| + std::set<Observer*> observers_; |
|
mark a. foltz
2017/03/01 21:44:00
Can you use base::ObserverList?
zhaobin
2017/03/02 07:04:35
Done.
|
| FRIEND_TEST_ALL_PREFIXES(DialRegistryTest, TestAddRemoveListeners); |
| FRIEND_TEST_ALL_PREFIXES(DialRegistryTest, TestNoDevicesDiscovered); |