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

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

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

Powered by Google App Engine
This is Rietveld 408576698