Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: net/dns/host_resolver_impl.cc

Issue 1903263002: DNS: Expose stale results through HostResolverImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dns_stale1
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/dns/host_resolver_impl.h ('K') | « net/dns/host_resolver_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f6adc4b604751d5cf727169876db116da505aecb 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::EntryStaleness* 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::EntryStaleness* 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::EntryStaleness* 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;
« net/dns/host_resolver_impl.h ('K') | « net/dns/host_resolver_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698