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

Unified Diff: net/base/host_cache.cc

Issue 9197009: Adds custom ttl argument to HostCache::Set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo change for when TTL == 0. 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
« net/base/host_cache.h ('K') | « net/base/host_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/host_cache.cc
diff --git a/net/base/host_cache.cc b/net/base/host_cache.cc
index 03eb23a01c1c97e65a3da0916041073d082eec19..dbf3bba3814f9ff983282f2a80bffef64c5cbd08 100644
--- a/net/base/host_cache.cc
+++ b/net/base/host_cache.cc
@@ -53,13 +53,16 @@ const HostCache::Entry* HostCache::Lookup(const Key& key,
HostCache::Entry* HostCache::Set(const Key& key,
int error,
const AddressList& addrlist,
+ base::TimeDelta ttl,
base::TimeTicks now) {
DCHECK(CalledOnValidThread());
if (caching_is_disabled())
return NULL;
- base::TimeTicks expiration = now +
- (error == OK ? success_entry_ttl_ : failure_entry_ttl_);
+ if (ttl == base::TimeDelta())
+ ttl = (error == OK ? success_entry_ttl_ : failure_entry_ttl_);
+
+ base::TimeTicks expiration = now + ttl;
scoped_refptr<Entry>& entry = entries_[key];
if (!entry) {
@@ -81,6 +84,13 @@ HostCache::Entry* HostCache::Set(const Key& key,
}
}
+HostCache::Entry* HostCache::Set(const Key& key,
+ int error,
+ const AddressList& addrlist,
+ base::TimeTicks now) {
+ return Set(key, error, addrlist, base::TimeDelta(), now);
+}
+
void HostCache::clear() {
DCHECK(CalledOnValidThread());
entries_.clear();
« net/base/host_cache.h ('K') | « net/base/host_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698