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/base/host_resolver_impl.h" | 5 #include "net/base/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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1398 // call OnProcTaskComplete, for example, on synchronous failure. | 1398 // call OnProcTaskComplete, for example, on synchronous failure. |
1399 proc_task_->Start(); | 1399 proc_task_->Start(); |
1400 } | 1400 } |
1401 | 1401 |
1402 // Called by ProcTask when it completes. | 1402 // Called by ProcTask when it completes. |
1403 void OnProcTaskComplete(base::TimeTicks start_time, | 1403 void OnProcTaskComplete(base::TimeTicks start_time, |
1404 int net_error, | 1404 int net_error, |
1405 const AddressList& addr_list) { | 1405 const AddressList& addr_list) { |
1406 DCHECK(is_proc_running()); | 1406 DCHECK(is_proc_running()); |
1407 | 1407 |
1408 if (!resolver_->resolved_known_ipv6_hostname_ && | |
1409 key_.address_family == ADDRESS_FAMILY_UNSPECIFIED) { | |
1410 if (key_.hostname == "www.google.com") { | |
1411 resolver_->resolved_known_ipv6_hostname_ = true; | |
mmenke
2013/01/29 16:10:27
This seems like the wrong way to track this. I th
mmenke
2013/01/29 16:10:27
If there's an error, should we even be logging a h
szym
2013/01/29 16:55:12
Good catch. I previously had this code in HostReso
szym
2013/01/29 16:55:12
We want it once per "network configuration". If we
mmenke
2013/01/29 17:00:46
Good point, though that's at the cost of overrepre
| |
1412 bool got_ipv6_address = false; | |
1413 for (size_t i = 0; i < addr_list.size(); ++i) { | |
1414 if (addr_list[i].GetFamily() == ADDRESS_FAMILY_IPV6) | |
1415 got_ipv6_address = true; | |
1416 } | |
1417 UMA_HISTOGRAM_BOOLEAN("Net.UnspecResolvedIPv6", got_ipv6_address); | |
1418 } | |
1419 } | |
1420 | |
1408 if (dns_task_error_ != OK) { | 1421 if (dns_task_error_ != OK) { |
1409 base::TimeDelta duration = base::TimeTicks::Now() - start_time; | 1422 base::TimeDelta duration = base::TimeTicks::Now() - start_time; |
1410 if (net_error == OK) { | 1423 if (net_error == OK) { |
1411 DNS_HISTOGRAM("AsyncDNS.FallbackSuccess", duration); | 1424 DNS_HISTOGRAM("AsyncDNS.FallbackSuccess", duration); |
1412 if ((dns_task_error_ == ERR_NAME_NOT_RESOLVED) && | 1425 if ((dns_task_error_ == ERR_NAME_NOT_RESOLVED) && |
1413 ResemblesNetBIOSName(key_.hostname)) { | 1426 ResemblesNetBIOSName(key_.hostname)) { |
1414 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_SUSPECT_NETBIOS); | 1427 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_SUSPECT_NETBIOS); |
1415 } else { | 1428 } else { |
1416 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS); | 1429 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS); |
1417 } | 1430 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1652 | 1665 |
1653 HostResolverImpl::HostResolverImpl( | 1666 HostResolverImpl::HostResolverImpl( |
1654 scoped_ptr<HostCache> cache, | 1667 scoped_ptr<HostCache> cache, |
1655 const PrioritizedDispatcher::Limits& job_limits, | 1668 const PrioritizedDispatcher::Limits& job_limits, |
1656 const ProcTaskParams& proc_params, | 1669 const ProcTaskParams& proc_params, |
1657 NetLog* net_log) | 1670 NetLog* net_log) |
1658 : cache_(cache.Pass()), | 1671 : cache_(cache.Pass()), |
1659 dispatcher_(job_limits), | 1672 dispatcher_(job_limits), |
1660 max_queued_jobs_(job_limits.total_jobs * 100u), | 1673 max_queued_jobs_(job_limits.total_jobs * 100u), |
1661 proc_params_(proc_params), | 1674 proc_params_(proc_params), |
1675 net_log_(net_log), | |
1662 default_address_family_(ADDRESS_FAMILY_UNSPECIFIED), | 1676 default_address_family_(ADDRESS_FAMILY_UNSPECIFIED), |
1663 weak_ptr_factory_(this), | 1677 weak_ptr_factory_(this), |
1664 probe_weak_ptr_factory_(this), | 1678 probe_weak_ptr_factory_(this), |
1665 received_dns_config_(false), | 1679 received_dns_config_(false), |
1666 num_dns_failures_(0), | 1680 num_dns_failures_(0), |
1667 ipv6_probe_monitoring_(false), | 1681 ipv6_probe_monitoring_(false), |
1668 additional_resolver_flags_(0), | 1682 resolved_known_ipv6_hostname_(false), |
1669 net_log_(net_log) { | 1683 additional_resolver_flags_(0) { |
1670 | 1684 |
1671 DCHECK_GE(dispatcher_.num_priorities(), static_cast<size_t>(NUM_PRIORITIES)); | 1685 DCHECK_GE(dispatcher_.num_priorities(), static_cast<size_t>(NUM_PRIORITIES)); |
1672 | 1686 |
1673 // Maximum of 4 retry attempts for host resolution. | 1687 // Maximum of 4 retry attempts for host resolution. |
1674 static const size_t kDefaultMaxRetryAttempts = 4u; | 1688 static const size_t kDefaultMaxRetryAttempts = 4u; |
1675 | 1689 |
1676 if (proc_params_.max_retry_attempts == HostResolver::kDefaultRetryAttempts) | 1690 if (proc_params_.max_retry_attempts == HostResolver::kDefaultRetryAttempts) |
1677 proc_params_.max_retry_attempts = kDefaultMaxRetryAttempts; | 1691 proc_params_.max_retry_attempts = kDefaultMaxRetryAttempts; |
1678 | 1692 |
1679 #if defined(OS_WIN) | 1693 #if defined(OS_WIN) |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2052 | 2066 |
2053 for (JobMap::iterator it = jobs_.begin(); self && it != jobs_.end(); ) { | 2067 for (JobMap::iterator it = jobs_.begin(); self && it != jobs_.end(); ) { |
2054 Job* job = it->second; | 2068 Job* job = it->second; |
2055 ++it; | 2069 ++it; |
2056 // This could remove |job| from |jobs_|, but iterator will remain valid. | 2070 // This could remove |job| from |jobs_|, but iterator will remain valid. |
2057 job->ServeFromHosts(); | 2071 job->ServeFromHosts(); |
2058 } | 2072 } |
2059 } | 2073 } |
2060 | 2074 |
2061 void HostResolverImpl::OnIPAddressChanged() { | 2075 void HostResolverImpl::OnIPAddressChanged() { |
2076 resolved_known_ipv6_hostname_ = false; | |
2062 // Abandon all ProbeJobs. | 2077 // Abandon all ProbeJobs. |
2063 probe_weak_ptr_factory_.InvalidateWeakPtrs(); | 2078 probe_weak_ptr_factory_.InvalidateWeakPtrs(); |
2064 if (cache_.get()) | 2079 if (cache_.get()) |
2065 cache_->clear(); | 2080 cache_->clear(); |
2066 if (ipv6_probe_monitoring_) | 2081 if (ipv6_probe_monitoring_) |
2067 new IPv6ProbeJob(probe_weak_ptr_factory_.GetWeakPtr(), net_log_); | 2082 new IPv6ProbeJob(probe_weak_ptr_factory_.GetWeakPtr(), net_log_); |
2068 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 2083 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
2069 new LoopbackProbeJob(probe_weak_ptr_factory_.GetWeakPtr()); | 2084 new LoopbackProbeJob(probe_weak_ptr_factory_.GetWeakPtr()); |
2070 #endif | 2085 #endif |
2071 AbortAllInProgressJobs(); | 2086 AbortAllInProgressJobs(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2148 } | 2163 } |
2149 DnsConfig dns_config; | 2164 DnsConfig dns_config; |
2150 NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2165 NetworkChangeNotifier::GetDnsConfig(&dns_config); |
2151 dns_client_->SetConfig(dns_config); | 2166 dns_client_->SetConfig(dns_config); |
2152 num_dns_failures_ = 0; | 2167 num_dns_failures_ = 0; |
2153 if (dns_config.IsValid()) | 2168 if (dns_config.IsValid()) |
2154 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2169 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2155 } | 2170 } |
2156 | 2171 |
2157 } // namespace net | 2172 } // namespace net |
OLD | NEW |