| 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 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 effective_address_family = ADDRESS_FAMILY_IPV4; | 2329 effective_address_family = ADDRESS_FAMILY_IPV4; |
| 2330 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | 2330 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; |
| 2331 } | 2331 } |
| 2332 } | 2332 } |
| 2333 } | 2333 } |
| 2334 | 2334 |
| 2335 return Key(info.hostname(), effective_address_family, effective_flags); | 2335 return Key(info.hostname(), effective_address_family, effective_flags); |
| 2336 } | 2336 } |
| 2337 | 2337 |
| 2338 bool HostResolverImpl::IsIPv6Reachable(const NetLogWithSource& net_log) { | 2338 bool HostResolverImpl::IsIPv6Reachable(const NetLogWithSource& net_log) { |
| 2339 base::TimeTicks now = base::TimeTicks::Now(); | 2339 // Cache the result for kIPv6ProbePeriodMs (measured from after |
| 2340 // IsGloballyReachable() completes). |
| 2340 bool cached = true; | 2341 bool cached = true; |
| 2341 if ((now - last_ipv6_probe_time_).InMilliseconds() > kIPv6ProbePeriodMs) { | 2342 if ((base::TimeTicks::Now() - last_ipv6_probe_time_).InMilliseconds() > |
| 2343 kIPv6ProbePeriodMs) { |
| 2342 last_ipv6_probe_result_ = | 2344 last_ipv6_probe_result_ = |
| 2343 IsGloballyReachable(IPAddress(kIPv6ProbeAddress), net_log); | 2345 IsGloballyReachable(IPAddress(kIPv6ProbeAddress), net_log); |
| 2344 last_ipv6_probe_time_ = now; | 2346 last_ipv6_probe_time_ = base::TimeTicks::Now(); |
| 2345 cached = false; | 2347 cached = false; |
| 2346 } | 2348 } |
| 2347 net_log.AddEvent(NetLogEventType::HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK, | 2349 net_log.AddEvent(NetLogEventType::HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK, |
| 2348 base::Bind(&NetLogIPv6AvailableCallback, | 2350 base::Bind(&NetLogIPv6AvailableCallback, |
| 2349 last_ipv6_probe_result_, cached)); | 2351 last_ipv6_probe_result_, cached)); |
| 2350 return last_ipv6_probe_result_; | 2352 return last_ipv6_probe_result_; |
| 2351 } | 2353 } |
| 2352 | 2354 |
| 2353 void HostResolverImpl::RunLoopbackProbeJob() { | 2355 void HostResolverImpl::RunLoopbackProbeJob() { |
| 2354 new LoopbackProbeJob(weak_ptr_factory_.GetWeakPtr(), | 2356 new LoopbackProbeJob(weak_ptr_factory_.GetWeakPtr(), |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 if (job_) | 2612 if (job_) |
| 2611 job_->CancelRequest(this); | 2613 job_->CancelRequest(this); |
| 2612 } | 2614 } |
| 2613 | 2615 |
| 2614 void HostResolverImpl::RequestImpl::ChangeRequestPriority( | 2616 void HostResolverImpl::RequestImpl::ChangeRequestPriority( |
| 2615 RequestPriority priority) { | 2617 RequestPriority priority) { |
| 2616 job_->ChangeRequestPriority(this, priority); | 2618 job_->ChangeRequestPriority(this, priority); |
| 2617 } | 2619 } |
| 2618 | 2620 |
| 2619 } // namespace net | 2621 } // namespace net |
| OLD | NEW |