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 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2147 } | 2147 } |
2148 } | 2148 } |
2149 | 2149 |
2150 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 2150 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( |
2151 const RequestInfo& info, const BoundNetLog& net_log) const { | 2151 const RequestInfo& info, const BoundNetLog& net_log) const { |
2152 HostResolverFlags effective_flags = | 2152 HostResolverFlags effective_flags = |
2153 info.host_resolver_flags() | additional_resolver_flags_; | 2153 info.host_resolver_flags() | additional_resolver_flags_; |
2154 AddressFamily effective_address_family = info.address_family(); | 2154 AddressFamily effective_address_family = info.address_family(); |
2155 | 2155 |
2156 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { | 2156 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { |
2157 unsigned char ip_number[4]; | 2157 IPAddressNumber ip_number; |
2158 url::Component host_comp(0, info.hostname().size()); | |
2159 int num_components; | |
2160 if (probe_ipv6_support_ && !use_local_ipv6_ && | 2158 if (probe_ipv6_support_ && !use_local_ipv6_ && |
2161 // Don't bother IPv6 probing when resolving IPv4 literals. | 2159 // When resolving IPv4 literals, there's no need to probe for IPv6. |
2162 url::IPv4AddressToNumber(info.hostname().c_str(), host_comp, ip_number, | 2160 // When resolving IPv6 literals, there's no benefit to artificially |
2163 &num_components) != url::CanonHostInfo::IPV4) { | 2161 // limiting our resolution based on a probe. We've already |
2162 // checked that this query is UNSPECIFIED (see info.address_family() | |
2163 // check above) and that default_address_family_ is UNSPECIFIED | |
2164 // (prove_ipv6_support_ is false if default_address_family_ is | |
2165 // set) so the code requesting the resolution should be amenable to | |
2166 // receiving a IPv6 resolution. | |
2167 !ParseIPLiteralToNumber(info.hostname(), &ip_number)) { | |
mmenke
2015/04/13 16:43:51
Wonder if it'd be cleaner just to move ParseIPLite
pauljensen
2015/04/15 01:29:29
Done.
| |
2164 // Google DNS address. | 2168 // Google DNS address. |
2165 const uint8 kIPv6Address[] = | 2169 const uint8 kIPv6Address[] = |
2166 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2170 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, |
2167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; |
2168 IPAddressNumber address(kIPv6Address, | 2172 IPAddressNumber address(kIPv6Address, |
2169 kIPv6Address + arraysize(kIPv6Address)); | 2173 kIPv6Address + arraysize(kIPv6Address)); |
2170 BoundNetLog probe_net_log = BoundNetLog::Make( | 2174 BoundNetLog probe_net_log = BoundNetLog::Make( |
2171 net_log.net_log(), NetLog::SOURCE_IPV6_REACHABILITY_CHECK); | 2175 net_log.net_log(), NetLog::SOURCE_IPV6_REACHABILITY_CHECK); |
2172 probe_net_log.BeginEvent(NetLog::TYPE_IPV6_REACHABILITY_CHECK, | 2176 probe_net_log.BeginEvent(NetLog::TYPE_IPV6_REACHABILITY_CHECK, |
2173 net_log.source().ToEventParametersCallback()); | 2177 net_log.source().ToEventParametersCallback()); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2361 dns_client_->SetConfig(dns_config); | 2365 dns_client_->SetConfig(dns_config); |
2362 num_dns_failures_ = 0; | 2366 num_dns_failures_ = 0; |
2363 if (dns_client_->GetConfig()) | 2367 if (dns_client_->GetConfig()) |
2364 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2368 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2365 } | 2369 } |
2366 | 2370 |
2367 AbortDnsTasks(); | 2371 AbortDnsTasks(); |
2368 } | 2372 } |
2369 | 2373 |
2370 } // namespace net | 2374 } // namespace net |
OLD | NEW |