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

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: 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
Index: net/base/host_cache.cc
diff --git a/net/base/host_cache.cc b/net/base/host_cache.cc
index 03eb23a01c1c97e65a3da0916041073d082eec19..252e457e267bd5c5100516e227796c7f1da650e0 100644
--- a/net/base/host_cache.cc
+++ b/net/base/host_cache.cc
@@ -22,12 +22,8 @@ HostCache::Entry::~Entry() {
//-----------------------------------------------------------------------------
-HostCache::HostCache(size_t max_entries,
- base::TimeDelta success_entry_ttl,
- base::TimeDelta failure_entry_ttl)
- : max_entries_(max_entries),
- success_entry_ttl_(success_entry_ttl),
- failure_entry_ttl_(failure_entry_ttl) {
+HostCache::HostCache(size_t max_entries)
+ : max_entries_(max_entries) {
}
HostCache::~HostCache() {
@@ -53,13 +49,13 @@ const HostCache::Entry* HostCache::Lookup(const Key& key,
HostCache::Entry* HostCache::Set(const Key& key,
int error,
const AddressList& addrlist,
- base::TimeTicks now) {
+ base::TimeTicks now,
+ base::TimeDelta ttl) {
DCHECK(CalledOnValidThread());
if (caching_is_disabled())
return NULL;
- base::TimeTicks expiration = now +
- (error == OK ? success_entry_ttl_ : failure_entry_ttl_);
+ base::TimeTicks expiration = now + ttl;
scoped_refptr<Entry>& entry = entries_[key];
if (!entry) {
@@ -96,16 +92,6 @@ size_t HostCache::max_entries() const {
return max_entries_;
}
-base::TimeDelta HostCache::success_entry_ttl() const {
- DCHECK(CalledOnValidThread());
- return success_entry_ttl_;
-}
-
-base::TimeDelta HostCache::failure_entry_ttl() const {
- DCHECK(CalledOnValidThread());
- return failure_entry_ttl_;
-}
-
// Note that this map may contain expired entries.
const HostCache::EntryMap& HostCache::entries() const {
DCHECK(CalledOnValidThread());
@@ -120,13 +106,7 @@ bool HostCache::CanUseEntry(const Entry* entry, const base::TimeTicks now) {
// static
HostCache* HostCache::CreateDefaultCache() {
static const size_t kMaxHostCacheEntries = 100;
-
- HostCache* cache = new HostCache(
- kMaxHostCacheEntries,
- base::TimeDelta::FromMinutes(1),
- base::TimeDelta::FromSeconds(0)); // Disable caching of failed DNS.
-
- return cache;
+ return new HostCache(kMaxHostCacheEntries);
}
void HostCache::Compact(base::TimeTicks now, const Entry* pinned_entry) {

Powered by Google App Engine
This is Rietveld 408576698