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

Unified Diff: chrome/browser/media/router/discovery/mdns/dns_sd_registry.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 | « chrome/browser/media/router/BUILD.gn ('k') | chrome/browser/media/router/discovery/mdns/dns_sd_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/router/discovery/mdns/dns_sd_registry.h
diff --git a/chrome/browser/media/router/discovery/mdns/dns_sd_registry.h b/chrome/browser/media/router/discovery/mdns/dns_sd_registry.h
index 24962c98083eb87ea660ecde9ae776c66a12d04c..89cdce170145b93ccd07f3c10235ddd2ae99e812 100644
--- a/chrome/browser/media/router/discovery/mdns/dns_sd_registry.h
+++ b/chrome/browser/media/router/discovery/mdns/dns_sd_registry.h
@@ -12,7 +12,9 @@
#include <vector>
#include "base/macros.h"
+#include "base/memory/singleton.h"
#include "base/observer_list.h"
+#include "base/threading/thread_checker.h"
#include "chrome/browser/media/router/discovery/mdns/dns_sd_delegate.h"
namespace local_discovery {
@@ -38,9 +40,7 @@ class DnsSdRegistry : public DnsSdDelegate {
virtual ~DnsSdObserver() {}
};
- DnsSdRegistry();
- explicit DnsSdRegistry(local_discovery::ServiceDiscoverySharedClient* client);
- virtual ~DnsSdRegistry();
+ static DnsSdRegistry* GetInstance();
// Publishes the current device list for |service_type| to event listeners
// whose event filter matches the service type.
@@ -108,12 +108,21 @@ class DnsSdRegistry : public DnsSdDelegate {
std::map<std::string, std::unique_ptr<ServiceTypeData>> service_data_map_;
private:
+ friend struct base::DefaultSingletonTraits<DnsSdRegistry>;
+ friend class MockDnsSdRegistry;
+ friend class TestDnsSdRegistry;
+
+ DnsSdRegistry();
+ explicit DnsSdRegistry(local_discovery::ServiceDiscoverySharedClient* client);
+ virtual ~DnsSdRegistry();
+
void DispatchApiEvent(const std::string& service_type);
bool IsRegistered(const std::string& service_type);
scoped_refptr<local_discovery::ServiceDiscoverySharedClient>
service_discovery_client_;
base::ObserverList<DnsSdObserver> observers_;
+ base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(DnsSdRegistry);
};
« no previous file with comments | « chrome/browser/media/router/BUILD.gn ('k') | chrome/browser/media/router/discovery/mdns/dns_sd_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698