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 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 } | 2057 } |
2058 } | 2058 } |
2059 | 2059 |
2060 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 2060 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( |
2061 const RequestInfo& info) const { | 2061 const RequestInfo& info) const { |
2062 HostResolverFlags effective_flags = | 2062 HostResolverFlags effective_flags = |
2063 info.host_resolver_flags() | additional_resolver_flags_; | 2063 info.host_resolver_flags() | additional_resolver_flags_; |
2064 AddressFamily effective_address_family = info.address_family(); | 2064 AddressFamily effective_address_family = info.address_family(); |
2065 | 2065 |
2066 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { | 2066 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { |
2067 if (ipv6_probe_monitoring_) { | 2067 base::TimeTicks start_time = base::TimeTicks::Now(); |
2068 base::TimeTicks start_time = base::TimeTicks::Now(); | 2068 // Google DNS address. |
2069 // Google DNS address. | 2069 const uint8 kIPv6Address[] = |
2070 const uint8 kIPv6Address[] = | 2070 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, |
2071 { 0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, | 2071 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; |
2072 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88 }; | 2072 bool rv6 = IsGloballyReachable( |
2073 IPAddressNumber address(kIPv6Address, | 2073 IPAddressNumber(kIPv6Address, kIPv6Address + arraysize(kIPv6Address))); |
2074 kIPv6Address + arraysize(kIPv6Address)); | |
2075 bool rv6 = IsGloballyReachable(address); | |
2076 | 2074 |
2077 UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", | 2075 UMA_HISTOGRAM_TIMES("Net.IPv6ConnectDuration", |
2078 base::TimeTicks::Now() - start_time); | 2076 base::TimeTicks::Now() - start_time); |
2079 if (rv6) { | 2077 if (rv6) { |
2080 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", | 2078 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectSuccessMatch", |
2081 default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); | 2079 default_address_family_ == ADDRESS_FAMILY_UNSPECIFIED); |
2082 } else { | 2080 } else { |
2083 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", | 2081 UMA_HISTOGRAM_BOOLEAN("Net.IPv6ConnectFailureMatch", |
2084 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); | 2082 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED); |
| 2083 } |
| 2084 } |
2085 | 2085 |
2086 effective_address_family = ADDRESS_FAMILY_IPV4; | 2086 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && |
2087 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | 2087 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED) { |
2088 } | 2088 effective_address_family = default_address_family_; |
2089 } else { | 2089 if (ipv6_probe_monitoring_) |
2090 effective_address_family = default_address_family_; | 2090 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; |
2091 } | |
2092 } | 2091 } |
2093 | 2092 |
2094 return Key(info.hostname(), effective_address_family, effective_flags); | 2093 return Key(info.hostname(), effective_address_family, effective_flags); |
2095 } | 2094 } |
2096 | 2095 |
2097 void HostResolverImpl::AbortAllInProgressJobs() { | 2096 void HostResolverImpl::AbortAllInProgressJobs() { |
2098 // In Abort, a Request callback could spawn new Jobs with matching keys, so | 2097 // In Abort, a Request callback could spawn new Jobs with matching keys, so |
2099 // first collect and remove all running jobs from |jobs_|. | 2098 // first collect and remove all running jobs from |jobs_|. |
2100 ScopedVector<Job> jobs_to_abort; | 2099 ScopedVector<Job> jobs_to_abort; |
2101 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { | 2100 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2238 } | 2237 } |
2239 DnsConfig dns_config; | 2238 DnsConfig dns_config; |
2240 NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2239 NetworkChangeNotifier::GetDnsConfig(&dns_config); |
2241 dns_client_->SetConfig(dns_config); | 2240 dns_client_->SetConfig(dns_config); |
2242 num_dns_failures_ = 0; | 2241 num_dns_failures_ = 0; |
2243 if (dns_config.IsValid()) | 2242 if (dns_config.IsValid()) |
2244 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2243 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2245 } | 2244 } |
2246 | 2245 |
2247 } // namespace net | 2246 } // namespace net |
OLD | NEW |