OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/dns/host_resolver_impl.h" | 5 #include "net/dns/host_resolver_impl.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <Winsock2.h> | 8 #include <Winsock2.h> |
9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
10 #include <netdb.h> | 10 #include <netdb.h> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
43 #include "net/dns/address_sorter.h" | 43 #include "net/dns/address_sorter.h" |
44 #include "net/dns/dns_client.h" | 44 #include "net/dns/dns_client.h" |
45 #include "net/dns/dns_config_service.h" | 45 #include "net/dns/dns_config_service.h" |
46 #include "net/dns/dns_protocol.h" | 46 #include "net/dns/dns_protocol.h" |
47 #include "net/dns/dns_response.h" | 47 #include "net/dns/dns_response.h" |
48 #include "net/dns/dns_transaction.h" | 48 #include "net/dns/dns_transaction.h" |
49 #include "net/dns/host_resolver_proc.h" | 49 #include "net/dns/host_resolver_proc.h" |
50 #include "net/socket/client_socket_factory.h" | 50 #include "net/socket/client_socket_factory.h" |
51 #include "net/udp/datagram_client_socket.h" | 51 #include "net/udp/datagram_client_socket.h" |
| 52 #include "url/url_canon_ip.h" |
52 | 53 |
53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
54 #include "net/base/winsock_init.h" | 55 #include "net/base/winsock_init.h" |
55 #endif | 56 #endif |
56 | 57 |
57 namespace net { | 58 namespace net { |
58 | 59 |
59 namespace { | 60 namespace { |
60 | 61 |
61 // Limit the size of hostnames that will be resolved to combat issues in | 62 // Limit the size of hostnames that will be resolved to combat issues in |
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2147 } | 2148 } |
2148 } | 2149 } |
2149 | 2150 |
2150 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 2151 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( |
2151 const RequestInfo& info, const BoundNetLog& net_log) const { | 2152 const RequestInfo& info, const BoundNetLog& net_log) const { |
2152 HostResolverFlags effective_flags = | 2153 HostResolverFlags effective_flags = |
2153 info.host_resolver_flags() | additional_resolver_flags_; | 2154 info.host_resolver_flags() | additional_resolver_flags_; |
2154 AddressFamily effective_address_family = info.address_family(); | 2155 AddressFamily effective_address_family = info.address_family(); |
2155 | 2156 |
2156 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { | 2157 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { |
2157 if (probe_ipv6_support_ && !use_local_ipv6_) { | 2158 unsigned char ip_number[4]; |
| 2159 url::Component host_comp(0, info.hostname().size()); |
| 2160 int num_components; |
| 2161 if (probe_ipv6_support_ && !use_local_ipv6_ && |
| 2162 // Don't bother IPv6 probing when resolving IPv4 literals. |
| 2163 url::IPv4AddressToNumber(info.hostname().c_str(), host_comp, ip_number, |
| 2164 &num_components) != url::CanonHostInfo::IPV4) { |
2158 // Google DNS address. | 2165 // Google DNS address. |
2159 const uint8 kIPv6Address[] = | 2166 const uint8 kIPv6Address[] = |
2160 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2167 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, |
2161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2168 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; |
2162 IPAddressNumber address(kIPv6Address, | 2169 IPAddressNumber address(kIPv6Address, |
2163 kIPv6Address + arraysize(kIPv6Address)); | 2170 kIPv6Address + arraysize(kIPv6Address)); |
2164 BoundNetLog probe_net_log = BoundNetLog::Make( | 2171 BoundNetLog probe_net_log = BoundNetLog::Make( |
2165 net_log.net_log(), NetLog::SOURCE_IPV6_REACHABILITY_CHECK); | 2172 net_log.net_log(), NetLog::SOURCE_IPV6_REACHABILITY_CHECK); |
2166 probe_net_log.BeginEvent(NetLog::TYPE_IPV6_REACHABILITY_CHECK, | 2173 probe_net_log.BeginEvent(NetLog::TYPE_IPV6_REACHABILITY_CHECK, |
2167 net_log.source().ToEventParametersCallback()); | 2174 net_log.source().ToEventParametersCallback()); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 dns_client_->SetConfig(dns_config); | 2363 dns_client_->SetConfig(dns_config); |
2357 num_dns_failures_ = 0; | 2364 num_dns_failures_ = 0; |
2358 if (dns_client_->GetConfig()) | 2365 if (dns_client_->GetConfig()) |
2359 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2366 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2360 } | 2367 } |
2361 | 2368 |
2362 AbortDnsTasks(); | 2369 AbortDnsTasks(); |
2363 } | 2370 } |
2364 | 2371 |
2365 } // namespace net | 2372 } // namespace net |
OLD | NEW |