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 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 } | 2047 } |
2048 } | 2048 } |
2049 | 2049 |
2050 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 2050 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( |
2051 const RequestInfo& info) const { | 2051 const RequestInfo& info) const { |
2052 HostResolverFlags effective_flags = | 2052 HostResolverFlags effective_flags = |
2053 info.host_resolver_flags() | additional_resolver_flags_; | 2053 info.host_resolver_flags() | additional_resolver_flags_; |
2054 AddressFamily effective_address_family = info.address_family(); | 2054 AddressFamily effective_address_family = info.address_family(); |
2055 | 2055 |
2056 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { | 2056 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { |
2057 base::TimeTicks start_time = base::TimeTicks::Now(); | 2057 if (ipv6_probe_monitoring_) { |
2058 // Google DNS address. | 2058 base::TimeTicks start_time = base::TimeTicks::Now(); |
2059 const uint8 kIPv6Address[] = | 2059 // Google DNS address. |
2060 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2060 const uint8 kIPv6Address[] = |
2061 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2061 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, |
2062 bool rv6 = IsGloballyReachable( | 2062 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; |
2063 IPAddressNumber(kIPv6Address, kIPv6Address + arraysize(kIPv6Address))); | 2063 IPAddressNumber address(kIPv6Address, |
| 2064 kIPv6Address + arraysize(kIPv6Address)); |
| 2065 bool rv6 = IsGloballyReachable(address); |
2064 | 2066 |
2065 UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", | 2067 UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", |
2066 base::TimeTicks::Now() - start_time); | 2068 base::TimeTicks::Now() - start_time); |
2067 if (rv6) { | 2069 if (rv6) { |
2068 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", | 2070 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", |
2069 default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); | 2071 default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); |
| 2072 } else { |
| 2073 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", |
| 2074 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); |
| 2075 |
| 2076 effective_address_family = ADDRESS_FAMILY_IPV4; |
| 2077 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; |
| 2078 } |
2070 } else { | 2079 } else { |
2071 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", | 2080 effective_address_family = default_address_family_; |
2072 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); | |
2073 } | 2081 } |
2074 } | 2082 } |
2075 | 2083 |
2076 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && | |
2077 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED) { | |
2078 effective_address_family = default_address_family_; | |
2079 if (ipv6_probe_monitoring_) | |
2080 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | |
2081 } | |
2082 | |
2083 return Key(info.hostname(), effective_address_family, effective_flags); | 2084 return Key(info.hostname(), effective_address_family, effective_flags); |
2084 } | 2085 } |
2085 | 2086 |
2086 void HostResolverImpl::AbortAllInProgressJobs() { | 2087 void HostResolverImpl::AbortAllInProgressJobs() { |
2087 // In Abort, a Request callback could spawn new Jobs with matching keys, so | 2088 // In Abort, a Request callback could spawn new Jobs with matching keys, so |
2088 // first collect and remove all running jobs from |jobs_|. | 2089 // first collect and remove all running jobs from |jobs_|. |
2089 ScopedVector<Job> jobs_to_abort; | 2090 ScopedVector<Job> jobs_to_abort; |
2090 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { | 2091 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { |
2091 Job* job = it->second; | 2092 Job* job = it->second; |
2092 if (job->is_running()) { | 2093 if (job->is_running()) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 } | 2229 } |
2229 DnsConfig dns_config; | 2230 DnsConfig dns_config; |
2230 NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2231 NetworkChangeNotifier::GetDnsConfig(&dns_config); |
2231 dns_client_->SetConfig(dns_config); | 2232 dns_client_->SetConfig(dns_config); |
2232 num_dns_failures_ = 0; | 2233 num_dns_failures_ = 0; |
2233 if (dns_config.IsValid()) | 2234 if (dns_config.IsValid()) |
2234 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2235 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2235 } | 2236 } |
2236 | 2237 |
2237 } // namespace net | 2238 } // namespace net |
OLD | NEW |