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

Side by Side Diff: chrome/browser/extensions/api/mdns/mdns_api.cc

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 #include "chrome/browser/extensions/api/mdns/mdns_api.h" 5 #include "chrome/browser/extensions/api/mdns/mdns_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 static base::LazyInstance<BrowserContextKeyedAPIFactory<MDnsAPI> > g_factory = 57 static base::LazyInstance<BrowserContextKeyedAPIFactory<MDnsAPI> > g_factory =
58 LAZY_INSTANCE_INITIALIZER; 58 LAZY_INSTANCE_INITIALIZER;
59 59
60 // static 60 // static
61 BrowserContextKeyedAPIFactory<MDnsAPI>* MDnsAPI::GetFactoryInstance() { 61 BrowserContextKeyedAPIFactory<MDnsAPI>* MDnsAPI::GetFactoryInstance() {
62 return g_factory.Pointer(); 62 return g_factory.Pointer();
63 } 63 }
64 64
65 void MDnsAPI::SetDnsSdRegistryForTesting( 65 void MDnsAPI::SetDnsSdRegistryForTesting(
66 scoped_ptr<DnsSdRegistry> dns_sd_registry) { 66 std::unique_ptr<DnsSdRegistry> dns_sd_registry) {
67 dns_sd_registry_ = std::move(dns_sd_registry); 67 dns_sd_registry_ = std::move(dns_sd_registry);
68 if (dns_sd_registry_.get()) 68 if (dns_sd_registry_.get())
69 dns_sd_registry_.get()->AddObserver(this); 69 dns_sd_registry_.get()->AddObserver(this);
70 } 70 }
71 71
72 void MDnsAPI::ForceDiscovery() { 72 void MDnsAPI::ForceDiscovery() {
73 DCHECK(thread_checker_.CalledOnValidThread()); 73 DCHECK(thread_checker_.CalledOnValidThread());
74 DnsSdRegistry* registry = dns_sd_registry(); 74 DnsSdRegistry* registry = dns_sd_registry();
75 return registry->ForceDiscovery(); 75 return registry->ForceDiscovery();
76 } 76 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 break; 163 break;
164 } 164 }
165 mdns::MDnsService mdns_service; 165 mdns::MDnsService mdns_service;
166 mdns_service.service_name = service.service_name; 166 mdns_service.service_name = service.service_name;
167 mdns_service.service_host_port = service.service_host_port; 167 mdns_service.service_host_port = service.service_host_port;
168 mdns_service.ip_address = service.ip_address; 168 mdns_service.ip_address = service.ip_address;
169 mdns_service.service_data = service.service_data; 169 mdns_service.service_data = service.service_data;
170 args.push_back(std::move(mdns_service)); 170 args.push_back(std::move(mdns_service));
171 } 171 }
172 172
173 scoped_ptr<base::ListValue> results = mdns::OnServiceList::Create(args); 173 std::unique_ptr<base::ListValue> results = mdns::OnServiceList::Create(args);
174 scoped_ptr<Event> event(new Event(events::MDNS_ON_SERVICE_LIST, 174 std::unique_ptr<Event> event(new Event(events::MDNS_ON_SERVICE_LIST,
175 mdns::OnServiceList::kEventName, 175 mdns::OnServiceList::kEventName,
176 std::move(results))); 176 std::move(results)));
177 event->restrict_to_browser_context = browser_context_; 177 event->restrict_to_browser_context = browser_context_;
178 event->filter_info.SetServiceType(service_type); 178 event->filter_info.SetServiceType(service_type);
179 179
180 // TODO(justinlin): To avoid having listeners without filters getting all 180 // TODO(justinlin): To avoid having listeners without filters getting all
181 // events, modify API to have this event require filters. 181 // events, modify API to have this event require filters.
182 // TODO(reddaly): If event isn't on whitelist, ensure it does not get 182 // TODO(reddaly): If event isn't on whitelist, ensure it does not get
183 // broadcast to extensions. 183 // broadcast to extensions.
184 extensions::EventRouter::Get(browser_context_) 184 extensions::EventRouter::Get(browser_context_)
185 ->BroadcastEvent(std::move(event)); 185 ->BroadcastEvent(std::move(event));
186 } 186 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 AsyncApiFunction::ResponseAction MdnsForceDiscoveryFunction::Run() { 266 AsyncApiFunction::ResponseAction MdnsForceDiscoveryFunction::Run() {
267 MDnsAPI* api = MDnsAPI::Get(browser_context()); 267 MDnsAPI* api = MDnsAPI::Get(browser_context());
268 if (!api) { 268 if (!api) {
269 return RespondNow(Error("Unknown error.")); 269 return RespondNow(Error("Unknown error."));
270 } 270 }
271 api->ForceDiscovery(); 271 api->ForceDiscovery();
272 return RespondNow(NoArguments()); 272 return RespondNow(NoArguments());
273 } 273 }
274 274
275 } // namespace extensions 275 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/mdns/mdns_api.h ('k') | chrome/browser/extensions/api/mdns/mdns_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698