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

Unified Diff: chrome/browser/extensions/api/mdns/mdns_api.h

Issue 2874243003: [mDns] Make DnsSdRegistry a leaky singleton (Closed)
Patch Set: resolve code review comments from Mark Created 3 years, 7 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 | « no previous file | chrome/browser/extensions/api/mdns/mdns_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/mdns/mdns_api.h
diff --git a/chrome/browser/extensions/api/mdns/mdns_api.h b/chrome/browser/extensions/api/mdns/mdns_api.h
index d5b4e051501211c0be9b2ca946736c19b0c085b2..7f882974257979184d5de6ea4e704a4b5cc0dd05 100644
--- a/chrome/browser/extensions/api/mdns/mdns_api.h
+++ b/chrome/browser/extensions/api/mdns/mdns_api.h
@@ -24,10 +24,6 @@ namespace content {
class BrowserContext;
}
-namespace media_router {
-class DnsSdRegistry;
-}
-
namespace extensions {
// MDnsAPI is instantiated with the profile and will listen for extensions that
// register listeners for the chrome.mdns extension API. It will use a registry
@@ -45,9 +41,9 @@ class MDnsAPI : public BrowserContextKeyedAPI,
// BrowserContextKeyedAPI implementation.
static BrowserContextKeyedAPIFactory<MDnsAPI>* GetFactoryInstance();
- // Used to mock out the DnsSdRegistry for testing.
- void SetDnsSdRegistryForTesting(
- std::unique_ptr<media_router::DnsSdRegistry> registry);
+ // Used to mock out the DnsSdRegistry for testing. Does not take ownership of
+ // |registry|.
+ void SetDnsSdRegistryForTesting(media_router::DnsSdRegistry* registry);
// Immediately issues a multicast DNS query for all service types.
// NOTE: Discovery queries are sent to all event handlers associated with
@@ -112,8 +108,9 @@ class MDnsAPI : public BrowserContextKeyedAPI,
// Ensure methods are only called on UI thread.
base::ThreadChecker thread_checker_;
content::BrowserContext* const browser_context_;
- // Lazily created on first access and destroyed with this API class.
- std::unique_ptr<media_router::DnsSdRegistry> dns_sd_registry_;
+ // Raw pointer to a leaky singleton. Lazily created on first access. Must
+ // outlive this object.
+ media_router::DnsSdRegistry* dns_sd_registry_;
// Count of active listeners per service type, saved from the previous
// invocation of UpdateMDnsListeners().
ServiceTypeCounts prev_service_counts_;
« no previous file with comments | « no previous file | chrome/browser/extensions/api/mdns/mdns_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698