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

Side by Side Diff: chrome/browser/local_discovery/service_discovery_host_client.cc

Issue 1062873003: Give names to all utility processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos Created 5 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/local_discovery/service_discovery_host_client.h" 5 #include "chrome/browser/local_discovery/service_discovery_host_client.h"
6 6
7 #include "chrome/common/local_discovery/local_discovery_messages.h" 7 #include "chrome/common/local_discovery/local_discovery_messages.h"
8 #include "chrome/grit/generated_resources.h"
8 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/utility_process_host.h" 10 #include "content/public/browser/utility_process_host.h"
10 #include "net/dns/mdns_client.h" 11 #include "net/dns/mdns_client.h"
11 #include "net/socket/socket_descriptor.h" 12 #include "net/socket/socket_descriptor.h"
13 #include "ui/base/l10n/l10n_util.h"
12 14
13 #if defined(OS_POSIX) 15 #if defined(OS_POSIX)
14 #include <netinet/in.h> 16 #include <netinet/in.h>
15 #include "base/file_descriptor_posix.h" 17 #include "base/file_descriptor_posix.h"
16 #endif // OS_POSIX 18 #endif // OS_POSIX
17 19
18 namespace local_discovery { 20 namespace local_discovery {
19 21
20 using content::BrowserThread; 22 using content::BrowserThread;
21 using content::UtilityProcessHost; 23 using content::UtilityProcessHost;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 FROM_HERE, 277 FROM_HERE,
276 base::Bind(&GetSocketsOnFileThread), 278 base::Bind(&GetSocketsOnFileThread),
277 base::Bind(&ServiceDiscoveryHostClient::OnSocketsReady, this)); 279 base::Bind(&ServiceDiscoveryHostClient::OnSocketsReady, this));
278 } 280 }
279 281
280 void ServiceDiscoveryHostClient::OnSocketsReady(const SocketInfoList& sockets) { 282 void ServiceDiscoveryHostClient::OnSocketsReady(const SocketInfoList& sockets) {
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
282 DCHECK(!utility_host_); 284 DCHECK(!utility_host_);
283 utility_host_ = UtilityProcessHost::Create( 285 utility_host_ = UtilityProcessHost::Create(
284 this, base::MessageLoopProxy::current().get())->AsWeakPtr(); 286 this, base::MessageLoopProxy::current().get())->AsWeakPtr();
285 if (!utility_host_) 287 utility_host_->SetName(l10n_util::GetStringUTF16(
286 return; 288 IDS_UTILITY_PROCESS_SERVICE_DISCOVERY_HANDLER_NAME));
287 utility_host_->EnableMDns(); 289 utility_host_->EnableMDns();
288 utility_host_->StartBatchMode(); 290 utility_host_->StartBatchMode();
289 if (sockets.empty()) { 291 if (sockets.empty()) {
290 ShutdownOnIOThread(); 292 ShutdownOnIOThread();
291 return; 293 return;
292 } 294 }
293 utility_host_->Send(new LocalDiscoveryMsg_SetSockets(sockets)); 295 utility_host_->Send(new LocalDiscoveryMsg_SetSockets(sockets));
294 // Send messages for requests made during network enumeration. 296 // Send messages for requests made during network enumeration.
295 for (size_t i = 0; i < delayed_messages_.size(); ++i) 297 for (size_t i = 0; i < delayed_messages_.size(); ++i)
296 utility_host_->Send(delayed_messages_[i]); 298 utility_host_->Send(delayed_messages_[i]);
297 delayed_messages_.weak_clear(); 299 delayed_messages_.weak_clear();
298 } 300 }
299 301
300 #else // OS_POSIX 302 #else // OS_POSIX
301 303
302 void ServiceDiscoveryHostClient::StartOnIOThread() { 304 void ServiceDiscoveryHostClient::StartOnIOThread() {
303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
304 DCHECK(!utility_host_); 306 DCHECK(!utility_host_);
305 utility_host_ = UtilityProcessHost::Create( 307 utility_host_ = UtilityProcessHost::Create(
306 this, base::MessageLoopProxy::current().get())->AsWeakPtr(); 308 this, base::MessageLoopProxy::current().get())->AsWeakPtr();
307 if (!utility_host_) 309 utility_host_->SetName(l10n_util::GetStringUTF16(
308 return; 310 IDS_UTILITY_PROCESS_SERVICE_DISCOVERY_HANDLER_NAME));
309 utility_host_->EnableMDns(); 311 utility_host_->EnableMDns();
310 utility_host_->StartBatchMode(); 312 utility_host_->StartBatchMode();
311 // Windows does not enumerate networks here. 313 // Windows does not enumerate networks here.
312 DCHECK(delayed_messages_.empty()); 314 DCHECK(delayed_messages_.empty());
313 } 315 }
314 316
315 #endif // OS_POSIX 317 #endif // OS_POSIX
316 318
317 void ServiceDiscoveryHostClient::ShutdownOnIOThread() { 319 void ServiceDiscoveryHostClient::ShutdownOnIOThread() {
318 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 bool success, 443 bool success,
442 const net::IPAddressNumber& ip_address_ipv4, 444 const net::IPAddressNumber& ip_address_ipv4,
443 const net::IPAddressNumber& ip_address_ipv6) { 445 const net::IPAddressNumber& ip_address_ipv6) {
444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
445 DomainResolverCallbacks::iterator it = domain_resolver_callbacks_.find(id); 447 DomainResolverCallbacks::iterator it = domain_resolver_callbacks_.find(id);
446 if (it != domain_resolver_callbacks_.end() && !it->second.is_null()) 448 if (it != domain_resolver_callbacks_.end() && !it->second.is_null())
447 it->second.Run(success, ip_address_ipv4, ip_address_ipv6); 449 it->second.Run(success, ip_address_ipv4, ip_address_ipv6);
448 } 450 }
449 451
450 } // namespace local_discovery 452 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698