Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/utility/local_discovery/service_discovery_message_handler.h" | 5 #include "chrome/utility/local_discovery/service_discovery_message_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "chrome/common/local_discovery/local_discovery_messages.h" | 14 #include "chrome/common/local_discovery/local_discovery_messages.h" |
| 15 #include "chrome/common/local_discovery/service_discovery_client_impl.h" | 15 #include "chrome/common/local_discovery/service_discovery_client_impl.h" |
| 16 #include "content/public/utility/utility_thread.h" | 16 #include "content/public/utility/utility_thread.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/ip_address.h" |
| 18 #include "net/socket/socket_descriptor.h" | 18 #include "net/socket/socket_descriptor.h" |
| 19 #include "net/udp/datagram_server_socket.h" | 19 #include "net/udp/datagram_server_socket.h" |
| 20 | 20 |
| 21 namespace local_discovery { | 21 namespace local_discovery { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 void ClosePlatformSocket(net::SocketDescriptor socket); | 25 void ClosePlatformSocket(net::SocketDescriptor socket); |
| 26 | 26 |
| 27 // Sets socket factory used by |net::CreatePlatformSocket|. Implemetation | 27 // Sets socket factory used by |net::CreatePlatformSocket|. Implemetation |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 << ", status=" << ResolverStatusToString(status) | 455 << ", status=" << ResolverStatusToString(status) |
| 456 << ", name=" << description.service_name; | 456 << ", name=" << description.service_name; |
| 457 | 457 |
| 458 DCHECK(service_discovery_client_); | 458 DCHECK(service_discovery_client_); |
| 459 Send(new LocalDiscoveryHostMsg_ResolverCallback(id, status, description)); | 459 Send(new LocalDiscoveryHostMsg_ResolverCallback(id, status, description)); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void ServiceDiscoveryMessageHandler::OnLocalDomainResolved( | 462 void ServiceDiscoveryMessageHandler::OnLocalDomainResolved( |
| 463 uint64 id, | 463 uint64 id, |
| 464 bool success, | 464 bool success, |
| 465 const net::IPAddressNumber& address_ipv4, | 465 const net::IPAddress& address_ipv4, |
| 466 const net::IPAddressNumber& address_ipv6) { | 466 const net::IPAddress& address_ipv6) { |
| 467 VLOG(1) << "OnLocalDomainResolved, id=" << id | 467 VLOG(1) << "OnLocalDomainResolved, id=" << id |
| 468 << ", IPv4=" << (address_ipv4.empty() ? "" : | 468 << ", IPv4=" << (address_ipv4.IsIPv4() ? address_ipv4.ToString() : "") |
|
eroman
2015/12/21 20:47:33
This is not a direct translation. Prefer to use an
martijnc
2016/01/27 22:50:52
(This code has been removed.)
| |
| 469 net::IPAddressToString(address_ipv4)) | 469 << ", IPv6=" |
| 470 << ", IPv6=" << (address_ipv6.empty() ? "" : | 470 << (address_ipv6.IsIPv6() ? address_ipv6.ToString() : ""); |
| 471 net::IPAddressToString(address_ipv6)); | |
| 472 | 471 |
| 473 DCHECK(service_discovery_client_); | 472 DCHECK(service_discovery_client_); |
| 474 Send(new LocalDiscoveryHostMsg_LocalDomainResolverCallback( | 473 Send(new LocalDiscoveryHostMsg_LocalDomainResolverCallback( |
| 475 id, success, address_ipv4, address_ipv6)); | 474 id, success, address_ipv4, address_ipv6)); |
| 476 } | 475 } |
| 477 | 476 |
| 478 void ServiceDiscoveryMessageHandler::Send(IPC::Message* msg) { | 477 void ServiceDiscoveryMessageHandler::Send(IPC::Message* msg) { |
| 479 utility_task_runner_->PostTask(FROM_HERE, | 478 utility_task_runner_->PostTask(FROM_HERE, |
| 480 base::Bind(&SendHostMessageOnUtilityThread, | 479 base::Bind(&SendHostMessageOnUtilityThread, |
| 481 msg)); | 480 msg)); |
| 482 } | 481 } |
| 483 | 482 |
| 484 } // namespace local_discovery | 483 } // namespace local_discovery |
| OLD | NEW |