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 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2182 // (|prove_ipv6_support_| is false if |default_address_family_| is | 2182 // (|prove_ipv6_support_| is false if |default_address_family_| is |
2183 // set) so the code requesting the resolution should be amenable to | 2183 // set) so the code requesting the resolution should be amenable to |
2184 // receiving a IPv6 resolution. | 2184 // receiving a IPv6 resolution. |
2185 ip_number == nullptr) { | 2185 ip_number == nullptr) { |
2186 // Google DNS address. | 2186 // Google DNS address. |
2187 const uint8 kIPv6Address[] = | 2187 const uint8 kIPv6Address[] = |
2188 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2188 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, |
2189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; |
2190 IPAddressNumber address(kIPv6Address, | 2190 IPAddressNumber address(kIPv6Address, |
2191 kIPv6Address + arraysize(kIPv6Address)); | 2191 kIPv6Address + arraysize(kIPv6Address)); |
2192 BoundNetLog probe_net_log = BoundNetLog::Make( | 2192 bool rv6 = IsGloballyReachable(address, net_log); |
2193 net_log.net_log(), NetLog::SOURCE_IPV6_REACHABILITY_CHECK); | 2193 net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK, |
2194 probe_net_log.BeginEvent(NetLog::TYPE_IPV6_REACHABILITY_CHECK, | 2194 NetLog::BoolCallback("ipv6_available", rv6)); |
2195 net_log.source().ToEventParametersCallback()); | 2195 if (!rv6) { |
2196 bool rv6 = IsGloballyReachable(address, probe_net_log); | |
2197 probe_net_log.EndEvent(NetLog::TYPE_IPV6_REACHABILITY_CHECK); | |
2198 if (rv6) { | |
2199 net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_SUPPORTED); | |
2200 } else { | |
2201 effective_address_family = ADDRESS_FAMILY_IPV4; | 2196 effective_address_family = ADDRESS_FAMILY_IPV4; |
2202 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | 2197 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; |
2203 } | 2198 } |
2204 } else { | 2199 } else { |
2205 effective_address_family = default_address_family_; | 2200 effective_address_family = default_address_family_; |
2206 } | 2201 } |
2207 } | 2202 } |
2208 | 2203 |
2209 std::string hostname = info.hostname(); | 2204 std::string hostname = info.hostname(); |
2210 // Redirect .localhost queries to "localhost." to make sure that they | 2205 // Redirect .localhost queries to "localhost." to make sure that they |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 dns_client_->SetConfig(dns_config); | 2392 dns_client_->SetConfig(dns_config); |
2398 num_dns_failures_ = 0; | 2393 num_dns_failures_ = 0; |
2399 if (dns_client_->GetConfig()) | 2394 if (dns_client_->GetConfig()) |
2400 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2395 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2401 } | 2396 } |
2402 | 2397 |
2403 AbortDnsTasks(); | 2398 AbortDnsTasks(); |
2404 } | 2399 } |
2405 | 2400 |
2406 } // namespace net | 2401 } // namespace net |
OLD | NEW |