| 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 base::TimeTicks start_time = base::TimeTicks::Now(); | 2026 if (probe_ipv6_support_) { |
| 2027 // Google DNS address. | 2027 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 2028 const uint8 kIPv6Address[] = | 2028 // Google DNS address. |
| 2029 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2029 const uint8 kIPv6Address[] = |
| 2030 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2030 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, |
| 2031 bool rv6 = IsGloballyReachable( | 2031 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; |
| 2032 IPAddressNumber(kIPv6Address, kIPv6Address + arraysize(kIPv6Address))); | 2032 IPAddressNumber address(kIPv6Address, |
| 2033 kIPv6Address + arraysize(kIPv6Address)); |
| 2034 bool rv6 = IsGloballyReachable(address, net_log); |
| 2035 if (rv6) |
| 2036 net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_SUPPORTED); |
| 2033 | 2037 |
| 2034 UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", | 2038 UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", |
| 2035 base::TimeTicks::Now() - start_time); | 2039 base::TimeTicks::Now() - start_time); |
| 2036 if (rv6) { | 2040 if (rv6) { |
| 2037 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", | 2041 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", |
| 2038 default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); | 2042 default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); |
| 2043 } else { |
| 2044 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", |
| 2045 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); |
| 2046 |
| 2047 effective_address_family = ADDRESS_FAMILY_IPV4; |
| 2048 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; |
| 2049 } |
| 2039 } else { | 2050 } else { |
| 2040 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", | 2051 effective_address_family = default_address_family_; |
| 2041 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); | |
| 2042 } | 2052 } |
| 2043 } | 2053 } |
| 2044 | 2054 |
| 2045 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && | |
| 2046 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED) { | |
| 2047 effective_address_family = default_address_family_; | |
| 2048 if (ipv6_probe_monitoring_) | |
| 2049 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | |
| 2050 } | |
| 2051 | |
| 2052 return Key(info.hostname(), effective_address_family, effective_flags); | 2055 return Key(info.hostname(), effective_address_family, effective_flags); |
| 2053 } | 2056 } |
| 2054 | 2057 |
| 2055 void HostResolverImpl::AbortAllInProgressJobs() { | 2058 void HostResolverImpl::AbortAllInProgressJobs() { |
| 2056 // 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 |
| 2057 // first collect and remove all running jobs from |jobs_|. | 2060 // first collect and remove all running jobs from |jobs_|. |
| 2058 ScopedVector<Job> jobs_to_abort; | 2061 ScopedVector<Job> jobs_to_abort; |
| 2059 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { | 2062 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { |
| 2060 Job* job = it->second; | 2063 Job* job = it->second; |
| 2061 if (job->is_running()) { | 2064 if (job->is_running()) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 } | 2197 } |
| 2195 DnsConfig dns_config; | 2198 DnsConfig dns_config; |
| 2196 NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2199 NetworkChangeNotifier::GetDnsConfig(&dns_config); |
| 2197 dns_client_->SetConfig(dns_config); | 2200 dns_client_->SetConfig(dns_config); |
| 2198 num_dns_failures_ = 0; | 2201 num_dns_failures_ = 0; |
| 2199 if (dns_config.IsValid()) | 2202 if (dns_config.IsValid()) |
| 2200 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2203 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
| 2201 } | 2204 } |
| 2202 | 2205 |
| 2203 } // namespace net | 2206 } // namespace net |
| OLD | NEW |