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 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 // call OnProcTaskComplete, for example, on synchronous failure. | 1628 // call OnProcTaskComplete, for example, on synchronous failure. |
1629 proc_task_->Start(); | 1629 proc_task_->Start(); |
1630 } | 1630 } |
1631 | 1631 |
1632 // Called by ProcTask when it completes. | 1632 // Called by ProcTask when it completes. |
1633 void OnProcTaskComplete(base::TimeTicks start_time, | 1633 void OnProcTaskComplete(base::TimeTicks start_time, |
1634 int net_error, | 1634 int net_error, |
1635 const AddressList& addr_list) { | 1635 const AddressList& addr_list) { |
1636 DCHECK(is_proc_running()); | 1636 DCHECK(is_proc_running()); |
1637 | 1637 |
1638 if (!resolver_->resolved_known_ipv6_hostname_ && | |
1639 net_error == OK && | |
1640 key_.address_family == ADDRESS_FAMILY_UNSPECIFIED) { | |
1641 if (key_.hostname == "www.google.com") { | |
1642 resolver_->resolved_known_ipv6_hostname_ = true; | |
1643 bool got_ipv6_address = false; | |
1644 for (size_t i = 0; i < addr_list.size(); ++i) { | |
1645 if (addr_list[i].GetFamily() == ADDRESS_FAMILY_IPV6) { | |
1646 got_ipv6_address = true; | |
1647 break; | |
1648 } | |
1649 } | |
1650 UMA_HISTOGRAM_BOOLEAN("Net.UnspecResolvedIPv6", got_ipv6_address); | |
1651 } | |
1652 } | |
1653 | |
1654 if (dns_task_error_ != OK) { | 1638 if (dns_task_error_ != OK) { |
1655 base::TimeDelta duration = base::TimeTicks::Now() - start_time; | 1639 base::TimeDelta duration = base::TimeTicks::Now() - start_time; |
1656 if (net_error == OK) { | 1640 if (net_error == OK) { |
1657 DNS_HISTOGRAM("AsyncDNS.FallbackSuccess", duration); | 1641 DNS_HISTOGRAM("AsyncDNS.FallbackSuccess", duration); |
1658 if ((dns_task_error_ == ERR_NAME_NOT_RESOLVED) && | 1642 if ((dns_task_error_ == ERR_NAME_NOT_RESOLVED) && |
1659 ResemblesNetBIOSName(key_.hostname)) { | 1643 ResemblesNetBIOSName(key_.hostname)) { |
1660 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_SUSPECT_NETBIOS); | 1644 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_SUSPECT_NETBIOS); |
1661 } else { | 1645 } else { |
1662 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS); | 1646 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS); |
1663 } | 1647 } |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 NetLog* net_log, | 2026 NetLog* net_log, |
2043 scoped_refptr<base::TaskRunner> worker_task_runner) | 2027 scoped_refptr<base::TaskRunner> worker_task_runner) |
2044 : max_queued_jobs_(0), | 2028 : max_queued_jobs_(0), |
2045 proc_params_(NULL, options.max_retry_attempts), | 2029 proc_params_(NULL, options.max_retry_attempts), |
2046 net_log_(net_log), | 2030 net_log_(net_log), |
2047 received_dns_config_(false), | 2031 received_dns_config_(false), |
2048 num_dns_failures_(0), | 2032 num_dns_failures_(0), |
2049 assume_ipv6_failure_on_wifi_(false), | 2033 assume_ipv6_failure_on_wifi_(false), |
2050 use_local_ipv6_(false), | 2034 use_local_ipv6_(false), |
2051 last_ipv6_probe_result_(true), | 2035 last_ipv6_probe_result_(true), |
2052 resolved_known_ipv6_hostname_(false), | |
2053 additional_resolver_flags_(0), | 2036 additional_resolver_flags_(0), |
2054 fallback_to_proctask_(true), | 2037 fallback_to_proctask_(true), |
2055 worker_task_runner_(std::move(worker_task_runner)), | 2038 worker_task_runner_(std::move(worker_task_runner)), |
2056 persist_initialized_(false), | 2039 persist_initialized_(false), |
2057 weak_ptr_factory_(this), | 2040 weak_ptr_factory_(this), |
2058 probe_weak_ptr_factory_(this) { | 2041 probe_weak_ptr_factory_(this) { |
2059 if (options.enable_caching) | 2042 if (options.enable_caching) |
2060 cache_ = HostCache::CreateDefaultCache(); | 2043 cache_ = HostCache::CreateDefaultCache(); |
2061 | 2044 |
2062 PrioritizedDispatcher::Limits job_limits = options.GetDispatcherLimits(); | 2045 PrioritizedDispatcher::Limits job_limits = options.GetDispatcherLimits(); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 | 2506 |
2524 for (auto it = jobs_.begin(); self.get() && it != jobs_.end();) { | 2507 for (auto it = jobs_.begin(); self.get() && it != jobs_.end();) { |
2525 Job* job = it->second.get(); | 2508 Job* job = it->second.get(); |
2526 ++it; | 2509 ++it; |
2527 // This could remove |job| from |jobs_|, but iterator will remain valid. | 2510 // This could remove |job| from |jobs_|, but iterator will remain valid. |
2528 job->ServeFromHosts(); | 2511 job->ServeFromHosts(); |
2529 } | 2512 } |
2530 } | 2513 } |
2531 | 2514 |
2532 void HostResolverImpl::OnIPAddressChanged() { | 2515 void HostResolverImpl::OnIPAddressChanged() { |
2533 resolved_known_ipv6_hostname_ = false; | |
2534 last_ipv6_probe_time_ = base::TimeTicks(); | 2516 last_ipv6_probe_time_ = base::TimeTicks(); |
2535 // Abandon all ProbeJobs. | 2517 // Abandon all ProbeJobs. |
2536 probe_weak_ptr_factory_.InvalidateWeakPtrs(); | 2518 probe_weak_ptr_factory_.InvalidateWeakPtrs(); |
2537 if (cache_.get()) { | 2519 if (cache_.get()) { |
2538 cache_->OnNetworkChange(); | 2520 cache_->OnNetworkChange(); |
2539 cache_hit_callbacks_.clear(); | 2521 cache_hit_callbacks_.clear(); |
2540 } | 2522 } |
2541 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 2523 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
2542 RunLoopbackProbeJob(); | 2524 RunLoopbackProbeJob(); |
2543 #endif | 2525 #endif |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2717 if (job_) | 2699 if (job_) |
2718 job_->CancelRequest(this); | 2700 job_->CancelRequest(this); |
2719 } | 2701 } |
2720 | 2702 |
2721 void HostResolverImpl::RequestImpl::ChangeRequestPriority( | 2703 void HostResolverImpl::RequestImpl::ChangeRequestPriority( |
2722 RequestPriority priority) { | 2704 RequestPriority priority) { |
2723 job_->ChangeRequestPriority(this, priority); | 2705 job_->ChangeRequestPriority(this, priority); |
2724 } | 2706 } |
2725 | 2707 |
2726 } // namespace net | 2708 } // namespace net |
OLD | NEW |