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

Unified Diff: net/base/host_resolver_impl.cc

Issue 9197009: Adds custom ttl argument to HostCache::Set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 11 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
« no previous file with comments | « net/base/host_cache_unittest.cc ('k') | net/base/mock_host_resolver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_resolver_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 217f1e1329e678e0500a337fbc45cf9a33e165e1..94d6aa72510713fad7562cd8417ef467d6ec0412 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -50,6 +50,9 @@ namespace {
// some platform's resolvers.
const size_t kMaxHostLength = 4096;
+// Default TTL for successful resolutions with ProcTask.
+const base::TimeDelta kCacheEntryTTL = base::TimeDelta::FromMinutes(1);
mmenke 2012/01/20 22:02:16 The constants up here should just be the times as
+
// Helper to mutate the linked list contained by AddressList to the given
// port. Note that in general this is dangerous since the AddressList's
// data might be shared (and you should use AddressList::SetPort).
@@ -1353,9 +1356,14 @@ void HostResolverImpl::OnJobComplete(Job* job,
RemoveOutstandingJob(job);
// Write result to the cache.
- if (cache_.get())
- cache_->Set(job->key(), net_error, addrlist, base::TimeTicks::Now());
-
+ if (cache_.get()) {
+ base::TimeDelta ttl = base::TimeDelta::FromSeconds(0);
+ if (net_error == OK)
+ ttl = kCacheEntryTTL;
+ cache_->Set(job->key(), net_error, addrlist,
+ base::TimeTicks::Now(),
+ ttl);
+ }
OnJobCompleteInternal(job, net_error, os_error, addrlist);
}
« no previous file with comments | « net/base/host_cache_unittest.cc ('k') | net/base/mock_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698