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

Side by Side Diff: chrome/browser/extensions/api/mdns/dns_sd_registry.h

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_REGISTRY_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_REGISTRY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "chrome/browser/extensions/api/mdns/dns_sd_delegate.h" 17 #include "chrome/browser/extensions/api/mdns/dns_sd_delegate.h"
18 18
19 namespace local_discovery { 19 namespace local_discovery {
20 class ServiceDiscoverySharedClient; 20 class ServiceDiscoverySharedClient;
21 class ServiceDiscoveryClient; 21 class ServiceDiscoveryClient;
22 } 22 }
23 23
24 namespace extensions { 24 namespace extensions {
25 25
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // DNS-SD-related discovery functionality. 59 // DNS-SD-related discovery functionality.
60 virtual void RegisterDnsSdListener(const std::string& service_type); 60 virtual void RegisterDnsSdListener(const std::string& service_type);
61 virtual void UnregisterDnsSdListener(const std::string& service_type); 61 virtual void UnregisterDnsSdListener(const std::string& service_type);
62 62
63 protected: 63 protected:
64 // Data class for managing all the resources and information related to a 64 // Data class for managing all the resources and information related to a
65 // particular service type. 65 // particular service type.
66 class ServiceTypeData { 66 class ServiceTypeData {
67 public: 67 public:
68 explicit ServiceTypeData(scoped_ptr<DnsSdDeviceLister> lister); 68 explicit ServiceTypeData(std::unique_ptr<DnsSdDeviceLister> lister);
69 virtual ~ServiceTypeData(); 69 virtual ~ServiceTypeData();
70 70
71 // Notify the data class of listeners so that it can be reference counted. 71 // Notify the data class of listeners so that it can be reference counted.
72 void ListenerAdded(); 72 void ListenerAdded();
73 // Returns true if the last listener was removed. 73 // Returns true if the last listener was removed.
74 bool ListenerRemoved(); 74 bool ListenerRemoved();
75 int GetListenerCount(); 75 int GetListenerCount();
76 76
77 // Immediately issues a multicast DNS query for the service type owned by 77 // Immediately issues a multicast DNS query for the service type owned by
78 // |this|. 78 // |this|.
79 void ForceDiscovery(); 79 void ForceDiscovery();
80 80
81 // Methods for adding, updating or removing services for this service type. 81 // Methods for adding, updating or removing services for this service type.
82 bool UpdateService(bool added, const DnsSdService& service); 82 bool UpdateService(bool added, const DnsSdService& service);
83 bool RemoveService(const std::string& service_name); 83 bool RemoveService(const std::string& service_name);
84 // Called when the discovery service was restarted. 84 // Called when the discovery service was restarted.
85 // Clear the local cache and initiate rediscovery. 85 // Clear the local cache and initiate rediscovery.
86 bool ClearServices(); 86 bool ClearServices();
87 87
88 const DnsSdRegistry::DnsSdServiceList& GetServiceList(); 88 const DnsSdRegistry::DnsSdServiceList& GetServiceList();
89 89
90 private: 90 private:
91 int ref_count; 91 int ref_count;
92 scoped_ptr<DnsSdDeviceLister> lister_; 92 std::unique_ptr<DnsSdDeviceLister> lister_;
93 DnsSdRegistry::DnsSdServiceList service_list_; 93 DnsSdRegistry::DnsSdServiceList service_list_;
94 DISALLOW_COPY_AND_ASSIGN(ServiceTypeData); 94 DISALLOW_COPY_AND_ASSIGN(ServiceTypeData);
95 }; 95 };
96 96
97 // Maps service types to associated data such as listers and service lists. 97 // Maps service types to associated data such as listers and service lists.
98 typedef std::map<std::string, linked_ptr<ServiceTypeData> > 98 typedef std::map<std::string, linked_ptr<ServiceTypeData> >
99 DnsSdServiceTypeDataMap; 99 DnsSdServiceTypeDataMap;
100 100
101 virtual DnsSdDeviceLister* CreateDnsSdDeviceLister( 101 virtual DnsSdDeviceLister* CreateDnsSdDeviceLister(
102 DnsSdDelegate* delegate, 102 DnsSdDelegate* delegate,
(...skipping 17 matching lines...) Expand all
120 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> 120 scoped_refptr<local_discovery::ServiceDiscoverySharedClient>
121 service_discovery_client_; 121 service_discovery_client_;
122 base::ObserverList<DnsSdObserver> observers_; 122 base::ObserverList<DnsSdObserver> observers_;
123 123
124 DISALLOW_COPY_AND_ASSIGN(DnsSdRegistry); 124 DISALLOW_COPY_AND_ASSIGN(DnsSdRegistry);
125 }; 125 };
126 126
127 } // namespace extensions 127 } // namespace extensions
128 128
129 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_REGISTRY_H_ 129 #endif // CHROME_BROWSER_EXTENSIONS_API_MDNS_DNS_SD_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698