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

Unified Diff: chrome/browser/media/router/discovery/dial/dial_registry.h

Issue 2754703005: [Device Discovery] Make DialRegistry a Singleton (Closed)
Patch Set: 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
Index: chrome/browser/media/router/discovery/dial/dial_registry.h
diff --git a/chrome/browser/media/router/discovery/dial/dial_registry.h b/chrome/browser/media/router/discovery/dial/dial_registry.h
index 12250ff40a657b40705dbfbf4a0aaa3614210aac..e7e4eb685d83d0093c94661a0110bc93950643a6 100644
--- a/chrome/browser/media/router/discovery/dial/dial_registry.h
+++ b/chrome/browser/media/router/discovery/dial/dial_registry.h
@@ -21,6 +21,7 @@
#include "base/timer/timer.h"
#include "chrome/browser/media/router/discovery/dial/dial_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "components/keyed_service/core/refcounted_keyed_service.h"
#include "net/base/network_change_notifier.h"
namespace media_router {
@@ -29,7 +30,8 @@ namespace media_router {
// the observer with an updated, complete set of active devices. The registry's
// observer (i.e., the Dial API) owns the registry instance.
// DialRegistry lives on the IO thread.
-class DialRegistry : public DialService::Observer,
+class DialRegistry : public RefcountedKeyedService,
mark a. foltz 2017/03/18 18:04:58 I don't think the DialRegistry needs to be a keyed
zhaobin 2017/03/22 02:48:45 Code removed.
+ public DialService::Observer,
public net::NetworkChangeNotifier::NetworkChangeObserver {
public:
using DeviceList = std::vector<DialDeviceData>;
@@ -60,8 +62,6 @@ class DialRegistry : public DialService::Observer,
base::TimeDelta expiration,
const size_t max_devices);
- ~DialRegistry() override;
-
// Called by the DIAL API when event listeners are added or removed. The dial
// service is started after the first listener is added and stopped after the
// last listener is removed.
@@ -86,6 +86,8 @@ class DialRegistry : public DialService::Observer,
void AddDeviceForTest(const DialDeviceData& device_data);
protected:
+ ~DialRegistry() override;
+
// Returns a new instance of the DIAL service. Overridden by tests.
virtual std::unique_ptr<DialService> CreateDialService();
virtual void ClearDialService();
@@ -101,6 +103,9 @@ class DialRegistry : public DialService::Observer,
base::hash_map<std::string, std::unique_ptr<DialDeviceData>>;
using DeviceByLabelMap = std::map<std::string, DialDeviceData*>;
+ // RefcountedKeyedService:
+ void ShutdownOnUIThread() override;
+
// DialService::Observer:
void OnDiscoveryRequest(DialService* service) override;
void OnDeviceDiscovered(DialService* service,

Powered by Google App Engine
This is Rietveld 408576698