| 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 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2016   } | 2016   } | 
| 2017 } | 2017 } | 
| 2018 | 2018 | 
| 2019 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 2019 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 
| 2020     const RequestInfo& info, const BoundNetLog& net_log) const { | 2020     const RequestInfo& info, const BoundNetLog& net_log) const { | 
| 2021   HostResolverFlags effective_flags = | 2021   HostResolverFlags effective_flags = | 
| 2022       info.host_resolver_flags() | additional_resolver_flags_; | 2022       info.host_resolver_flags() | additional_resolver_flags_; | 
| 2023   AddressFamily effective_address_family = info.address_family(); | 2023   AddressFamily effective_address_family = info.address_family(); | 
| 2024 | 2024 | 
| 2025   if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { | 2025   if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { | 
| 2026     if (probe_ipv6_support_) { | 2026     base::TimeTicks start_time = base::TimeTicks::Now(); | 
| 2027       base::TimeTicks start_time = base::TimeTicks::Now(); | 2027     // Google DNS address. | 
| 2028       // Google DNS address. | 2028     const uint8 kIPv6Address[] = | 
| 2029       const uint8 kIPv6Address[] = | 2029         { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 
| 2030           { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2030           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 
| 2031             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2031     IPAddressNumber address(kIPv6Address, | 
| 2032       IPAddressNumber address(kIPv6Address, | 2032                             kIPv6Address + arraysize(kIPv6Address)); | 
| 2033                               kIPv6Address + arraysize(kIPv6Address)); | 2033     bool rv6 = IsGloballyReachable(address, net_log); | 
| 2034       bool rv6 = IsGloballyReachable(address, net_log); | 2034     if (rv6) | 
| 2035       if (rv6) | 2035       net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_SUPPORTED); | 
| 2036         net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_SUPPORTED); |  | 
| 2037 | 2036 | 
| 2038       UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", | 2037     UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", | 
| 2039                           base::TimeTicks::Now() - start_time); | 2038                         base::TimeTicks::Now() - start_time); | 
| 2040       if (rv6) { | 2039     if (rv6) { | 
| 2041         UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", | 2040       UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", | 
| 2042             default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); | 2041           default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); | 
| 2043       } else { | 2042     } else { | 
| 2044         UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", | 2043       UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", | 
| 2045             default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); | 2044           default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); | 
|  | 2045     } | 
|  | 2046   } | 
| 2046 | 2047 | 
| 2047         effective_address_family = ADDRESS_FAMILY_IPV4; | 2048   if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && | 
| 2048         effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | 2049       default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED) { | 
| 2049       } | 2050     effective_address_family = default_address_family_; | 
| 2050     } else { | 2051     if (probe_ipv6_support_) | 
| 2051       effective_address_family = default_address_family_; | 2052       effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | 
| 2052     } |  | 
| 2053   } | 2053   } | 
| 2054 | 2054 | 
| 2055   return Key(info.hostname(), effective_address_family, effective_flags); | 2055   return Key(info.hostname(), effective_address_family, effective_flags); | 
| 2056 } | 2056 } | 
| 2057 | 2057 | 
| 2058 void HostResolverImpl::AbortAllInProgressJobs() { | 2058 void HostResolverImpl::AbortAllInProgressJobs() { | 
| 2059   // In Abort, a Request callback could spawn new Jobs with matching keys, so | 2059   // In Abort, a Request callback could spawn new Jobs with matching keys, so | 
| 2060   // first collect and remove all running jobs from |jobs_|. | 2060   // first collect and remove all running jobs from |jobs_|. | 
| 2061   ScopedVector<Job> jobs_to_abort; | 2061   ScopedVector<Job> jobs_to_abort; | 
| 2062   for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { | 2062   for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2197   } | 2197   } | 
| 2198   DnsConfig dns_config; | 2198   DnsConfig dns_config; | 
| 2199   NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2199   NetworkChangeNotifier::GetDnsConfig(&dns_config); | 
| 2200   dns_client_->SetConfig(dns_config); | 2200   dns_client_->SetConfig(dns_config); | 
| 2201   num_dns_failures_ = 0; | 2201   num_dns_failures_ = 0; | 
| 2202   if (dns_config.IsValid()) | 2202   if (dns_config.IsValid()) | 
| 2203     UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2203     UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 
| 2204 } | 2204 } | 
| 2205 | 2205 | 
| 2206 }  // namespace net | 2206 }  // namespace net | 
| OLD | NEW | 
|---|