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

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

Issue 1549233002: Convert Pass()→std::move() in //chrome/browser/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 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 <vector> 8 #include <vector>
8 9
9 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "content/public/browser/render_frame_host.h" 13 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "extensions/browser/extension_function.h" 16 #include "extensions/browser/extension_function.h"
16 #include "extensions/browser/extension_host.h" 17 #include "extensions/browser/extension_host.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 static base::LazyInstance<BrowserContextKeyedAPIFactory<MDnsAPI> > g_factory = 57 static base::LazyInstance<BrowserContextKeyedAPIFactory<MDnsAPI> > g_factory =
57 LAZY_INSTANCE_INITIALIZER; 58 LAZY_INSTANCE_INITIALIZER;
58 59
59 // static 60 // static
60 BrowserContextKeyedAPIFactory<MDnsAPI>* MDnsAPI::GetFactoryInstance() { 61 BrowserContextKeyedAPIFactory<MDnsAPI>* MDnsAPI::GetFactoryInstance() {
61 return g_factory.Pointer(); 62 return g_factory.Pointer();
62 } 63 }
63 64
64 void MDnsAPI::SetDnsSdRegistryForTesting( 65 void MDnsAPI::SetDnsSdRegistryForTesting(
65 scoped_ptr<DnsSdRegistry> dns_sd_registry) { 66 scoped_ptr<DnsSdRegistry> dns_sd_registry) {
66 dns_sd_registry_ = dns_sd_registry.Pass(); 67 dns_sd_registry_ = std::move(dns_sd_registry);
67 if (dns_sd_registry_.get()) 68 if (dns_sd_registry_.get())
68 dns_sd_registry_.get()->AddObserver(this); 69 dns_sd_registry_.get()->AddObserver(this);
69 } 70 }
70 71
71 void MDnsAPI::ForceDiscovery() { 72 void MDnsAPI::ForceDiscovery() {
72 DCHECK(thread_checker_.CalledOnValidThread()); 73 DCHECK(thread_checker_.CalledOnValidThread());
73 DnsSdRegistry* registry = dns_sd_registry(); 74 DnsSdRegistry* registry = dns_sd_registry();
74 return registry->ForceDiscovery(); 75 return registry->ForceDiscovery();
75 } 76 }
76 77
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 mdns_service->service_name = (*it).service_name; 168 mdns_service->service_name = (*it).service_name;
168 mdns_service->service_host_port = (*it).service_host_port; 169 mdns_service->service_host_port = (*it).service_host_port;
169 mdns_service->ip_address = (*it).ip_address; 170 mdns_service->ip_address = (*it).ip_address;
170 mdns_service->service_data = (*it).service_data; 171 mdns_service->service_data = (*it).service_data;
171 args.push_back(mdns_service); 172 args.push_back(mdns_service);
172 } 173 }
173 174
174 scoped_ptr<base::ListValue> results = mdns::OnServiceList::Create(args); 175 scoped_ptr<base::ListValue> results = mdns::OnServiceList::Create(args);
175 scoped_ptr<Event> event(new Event(events::MDNS_ON_SERVICE_LIST, 176 scoped_ptr<Event> event(new Event(events::MDNS_ON_SERVICE_LIST,
176 mdns::OnServiceList::kEventName, 177 mdns::OnServiceList::kEventName,
177 results.Pass())); 178 std::move(results)));
178 event->restrict_to_browser_context = browser_context_; 179 event->restrict_to_browser_context = browser_context_;
179 event->filter_info.SetServiceType(service_type); 180 event->filter_info.SetServiceType(service_type);
180 181
181 // TODO(justinlin): To avoid having listeners without filters getting all 182 // TODO(justinlin): To avoid having listeners without filters getting all
182 // events, modify API to have this event require filters. 183 // events, modify API to have this event require filters.
183 // TODO(reddaly): If event isn't on whitelist, ensure it does not get 184 // TODO(reddaly): If event isn't on whitelist, ensure it does not get
184 // broadcast to extensions. 185 // broadcast to extensions.
185 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); 186 extensions::EventRouter::Get(browser_context_)
187 ->BroadcastEvent(std::move(event));
186 } 188 }
187 189
188 const extensions::EventListenerMap::ListenerList& MDnsAPI::GetEventListeners() { 190 const extensions::EventListenerMap::ListenerList& MDnsAPI::GetEventListeners() {
189 return extensions::EventRouter::Get(browser_context_) 191 return extensions::EventRouter::Get(browser_context_)
190 ->listeners() 192 ->listeners()
191 .GetEventListenersByName(mdns::OnServiceList::kEventName); 193 .GetEventListenersByName(mdns::OnServiceList::kEventName);
192 } 194 }
193 195
194 bool MDnsAPI::IsMDnsAllowed(const std::string& extension_id, 196 bool MDnsAPI::IsMDnsAllowed(const std::string& extension_id,
195 const std::string& service_type) const { 197 const std::string& service_type) const {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 AsyncApiFunction::ResponseAction MdnsForceDiscoveryFunction::Run() { 268 AsyncApiFunction::ResponseAction MdnsForceDiscoveryFunction::Run() {
267 MDnsAPI* api = MDnsAPI::Get(browser_context()); 269 MDnsAPI* api = MDnsAPI::Get(browser_context());
268 if (!api) { 270 if (!api) {
269 return RespondNow(Error("Unknown error.")); 271 return RespondNow(Error("Unknown error."));
270 } 272 }
271 api->ForceDiscovery(); 273 api->ForceDiscovery();
272 return RespondNow(NoArguments()); 274 return RespondNow(NoArguments());
273 } 275 }
274 276
275 } // namespace extensions 277 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/mdns/dns_sd_registry.cc ('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