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

Unified Diff: chrome/browser/extensions/api/dial/dial_registry.h

Issue 2702503003: [Dial] Refactor DialRegistry and DeviceDescriptionFetcher so they can be used by MediaSinkService (Closed)
Patch Set: resolve code review comments from Derek Created 3 years, 9 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 | « chrome/browser/extensions/api/dial/dial_api.cc ('k') | chrome/browser/extensions/api/dial/dial_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f0597e024d2b264f74de3cc41f5871ce21033874 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,9 +58,8 @@ 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,
- const base::TimeDelta& expiration,
+ DialRegistry(base::TimeDelta refresh_interval,
+ base::TimeDelta expiration,
const size_t max_devices);
~DialRegistry() override;
@@ -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);
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_api.cc ('k') | chrome/browser/extensions/api/dial/dial_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698