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

Unified Diff: chrome/browser/extensions/api/dial/dial_api.cc

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/extensions/api/dial/dial_api.cc
diff --git a/chrome/browser/extensions/api/dial/dial_api.cc b/chrome/browser/extensions/api/dial/dial_api.cc
index 415ae15dce5e13b6b05ebc49be296b64fb4c74cd..6e3936c56b8d26e15205842195307a5d14cfceea 100644
--- a/chrome/browser/extensions/api/dial/dial_api.cc
+++ b/chrome/browser/extensions/api/dial/dial_api.cc
@@ -13,6 +13,7 @@
#include "base/time/time.h"
#include "chrome/browser/extensions/api/dial/dial_api_factory.h"
#include "chrome/browser/media/router/discovery/dial/device_description_fetcher.h"
+#include "chrome/browser/media/router/discovery/dial/dial_registry_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/dial.h"
#include "content/public/browser/browser_thread.h"
@@ -29,19 +30,6 @@ using media_router::DialRegistry;
namespace extensions {
-namespace {
-
-// How often to poll for devices.
-const int kDialRefreshIntervalSecs = 120;
-
-// We prune a device if it does not respond after this time.
-const int kDialExpirationSecs = 240;
-
-// The maximum number of devices retained at once in the registry.
-const size_t kDialMaxDevices = 256;
-
-} // namespace
-
DialAPI::DialAPI(Profile* profile)
: RefcountedKeyedService(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)),
@@ -54,10 +42,10 @@ DialAPI::~DialAPI() {}
DialRegistry* DialAPI::dial_registry() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (!dial_registry_.get()) {
- dial_registry_.reset(new DialRegistry(
- TimeDelta::FromSeconds(kDialRefreshIntervalSecs),
- TimeDelta::FromSeconds(kDialExpirationSecs), kDialMaxDevices));
+ if (!dial_registry_) {
+ dial_registry_ =
+ media_router::DialRegistryFactory::GetInstance()->GetForBrowserContext(
+ profile_);
dial_registry_->RegisterObserver(this);
if (test_device_data_) {
dial_registry_->AddDeviceForTest(*test_device_data_);

Powered by Google App Engine
This is Rietveld 408576698