OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/endpoint_resolver.h" | 5 #include "chrome/browser/local_discovery/endpoint_resolver.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/dump_without_crashing.h" | 8 #include "base/debug/dump_without_crashing.h" |
| 9 #include "build/build_config.h" |
9 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 10 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
12 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
13 | 14 |
14 namespace local_discovery { | 15 namespace local_discovery { |
15 | 16 |
16 EndpointResolver::EndpointResolver() { | 17 EndpointResolver::EndpointResolver() { |
17 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); | 18 service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance(); |
18 } | 19 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 domain_resolver_ = service_discovery_client_->CreateLocalDomainResolver( | 61 domain_resolver_ = service_discovery_client_->CreateLocalDomainResolver( |
61 address.host(), address_family, | 62 address.host(), address_family, |
62 base::Bind(&EndpointResolver::DomainResolveComplete, | 63 base::Bind(&EndpointResolver::DomainResolveComplete, |
63 base::Unretained(this), address.port(), callback)); | 64 base::Unretained(this), address.port(), callback)); |
64 domain_resolver_->Start(); | 65 domain_resolver_->Start(); |
65 #endif // OS_MACOSX | 66 #endif // OS_MACOSX |
66 } | 67 } |
67 | 68 |
68 void EndpointResolver::DomainResolveComplete( | 69 void EndpointResolver::DomainResolveComplete( |
69 uint16 port, | 70 uint16_t port, |
70 const ResultCallback& callback, | 71 const ResultCallback& callback, |
71 bool success, | 72 bool success, |
72 const net::IPAddressNumber& address_ipv4, | 73 const net::IPAddressNumber& address_ipv4, |
73 const net::IPAddressNumber& address_ipv6) { | 74 const net::IPAddressNumber& address_ipv6) { |
74 if (!success) | 75 if (!success) |
75 return callback.Run(net::IPEndPoint()); | 76 return callback.Run(net::IPEndPoint()); |
76 | 77 |
77 net::IPAddressNumber address = address_ipv4; | 78 net::IPAddressNumber address = address_ipv4; |
78 if (address.empty()) | 79 if (address.empty()) |
79 address = address_ipv6; | 80 address = address_ipv6; |
80 | 81 |
81 DCHECK(!address.empty()); | 82 DCHECK(!address.empty()); |
82 | 83 |
83 callback.Run(net::IPEndPoint(address, port)); | 84 callback.Run(net::IPEndPoint(address, port)); |
84 } | 85 } |
85 | 86 |
86 } // namespace local_discovery | 87 } // namespace local_discovery |
OLD | NEW |