| Index: net/dns/host_resolver_impl.cc
|
| diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
|
| index a224b8c4e38a87d943fef29f7494c738186e1096..0cc8c683d864666a7f35971f9e81d36bc8a8a377 100644
|
| --- a/net/dns/host_resolver_impl.cc
|
| +++ b/net/dns/host_resolver_impl.cc
|
| @@ -1949,7 +1949,8 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
|
| // outstanding jobs map.
|
| Key key = GetEffectiveKeyForRequest(info, ip_address_ptr, source_net_log);
|
|
|
| - int rv = ResolveHelper(key, info, ip_address_ptr, addresses, source_net_log);
|
| + int rv = ResolveHelper(key, info, ip_address_ptr, addresses, nullptr,
|
| + source_net_log);
|
| if (rv != ERR_DNS_CACHE_MISS) {
|
| LogFinishRequest(source_net_log, info, rv);
|
| RecordTotalTime(HaveDnsConfig(), info.is_speculative(), base::TimeDelta());
|
| @@ -1997,6 +1998,7 @@ int HostResolverImpl::ResolveHelper(const Key& key,
|
| const RequestInfo& info,
|
| const IPAddress* ip_address,
|
| AddressList* addresses,
|
| + HostCache::StaleEntryInfo* stale_info,
|
| const BoundNetLog& source_net_log) {
|
| // The result of |getaddrinfo| for empty hosts is inconsistent across systems.
|
| // On Windows it gives the default interface's address, whereas on Linux it
|
| @@ -2007,7 +2009,7 @@ int HostResolverImpl::ResolveHelper(const Key& key,
|
| int net_error = ERR_UNEXPECTED;
|
| if (ResolveAsIP(key, info, ip_address, &net_error, addresses))
|
| return net_error;
|
| - if (ServeFromCache(key, info, &net_error, addresses)) {
|
| + if (ServeFromCache(key, info, &net_error, addresses, stale_info)) {
|
| source_net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CACHE_HIT);
|
| return net_error;
|
| }
|
| @@ -2027,6 +2029,14 @@ int HostResolverImpl::ResolveHelper(const Key& key,
|
| int HostResolverImpl::ResolveFromCache(const RequestInfo& info,
|
| AddressList* addresses,
|
| const BoundNetLog& source_net_log) {
|
| + return ResolveStaleFromCache(info, addresses, nullptr, source_net_log);
|
| +}
|
| +
|
| +int HostResolverImpl::ResolveStaleFromCache(
|
| + const RequestInfo& info,
|
| + AddressList* addresses,
|
| + HostCache::StaleEntryInfo* stale_info,
|
| + const BoundNetLog& source_net_log) {
|
| DCHECK(CalledOnValidThread());
|
| DCHECK(addresses);
|
|
|
| @@ -2040,7 +2050,8 @@ int HostResolverImpl::ResolveFromCache(const RequestInfo& info,
|
|
|
| Key key = GetEffectiveKeyForRequest(info, ip_address_ptr, source_net_log);
|
|
|
| - int rv = ResolveHelper(key, info, ip_address_ptr, addresses, source_net_log);
|
| + int rv = ResolveHelper(key, info, ip_address_ptr, addresses, stale_info,
|
| + source_net_log);
|
| LogFinishRequest(source_net_log, info, rv);
|
| return rv;
|
| }
|
| @@ -2110,14 +2121,18 @@ bool HostResolverImpl::ResolveAsIP(const Key& key,
|
| bool HostResolverImpl::ServeFromCache(const Key& key,
|
| const RequestInfo& info,
|
| int* net_error,
|
| - AddressList* addresses) {
|
| + AddressList* addresses,
|
| + HostCache::StaleEntryInfo* stale_info) {
|
| DCHECK(addresses);
|
| DCHECK(net_error);
|
| if (!info.allow_cached_response() || !cache_.get())
|
| return false;
|
|
|
| - const HostCache::Entry* cache_entry = cache_->Lookup(
|
| - key, base::TimeTicks::Now());
|
| + const HostCache::Entry* cache_entry;
|
| + if (stale_info)
|
| + cache_entry = cache_->LookupStale(key, base::TimeTicks::Now(), stale_info);
|
| + else
|
| + cache_entry = cache_->Lookup(key, base::TimeTicks::Now());
|
| if (!cache_entry)
|
| return false;
|
|
|
|
|