diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 00:02:12 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 00:02:12 +0000 |
commit | c2c7574634e8d77f56cb9ec11da9e6cfe78166c1 (patch) | |
tree | 00c3bd13e645c56523adc4c058cf51c8bcc29d7d /net/disk_cache | |
parent | 855adf0fa36a65f20ce3a512f1cd1a232d2d7494 (diff) | |
download | chromium_src-c2c7574634e8d77f56cb9ec11da9e6cfe78166c1.zip chromium_src-c2c7574634e8d77f56cb9ec11da9e6cfe78166c1.tar.gz chromium_src-c2c7574634e8d77f56cb9ec11da9e6cfe78166c1.tar.bz2 |
Disk Cache: Avoid discarding more deleted entries
than needed.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8540027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/eviction.cc | 22 | ||||
-rw-r--r-- | net/disk_cache/eviction.h | 1 |
2 files changed, 13 insertions, 10 deletions
diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index 07028ed..2e50db9 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -224,6 +224,16 @@ bool Eviction::ShouldTrim() { return true; } +bool Eviction::ShouldTrimDeleted() { + // Normally we use 25% for each list. The experiment doubles the number of + // deleted entries, so the total number of entries increases by 25%. Using + // 40% of that value for deleted entries leaves the size of the other three + // lists intact. + int max_length = in_experiment_ ? header_->num_entries * 2 / 5 : + header_->num_entries / 4; + return (!test_mode_ && header_->lru.sizes[Rankings::DELETED] > max_length); +} + void Eviction::ReportTrimTimes(EntryImpl* entry) { if (first_trim_) { first_trim_ = false; @@ -353,8 +363,7 @@ void Eviction::TrimCacheV2(bool empty) { if (empty) { TrimDeleted(true); - } else if (header_->lru.sizes[Rankings::DELETED] > header_->num_entries / 4 && - !test_mode_) { + } else if (ShouldTrimDeleted()) { MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&Eviction::TrimDeleted, ptr_factory_.GetWeakPtr(), empty)); } @@ -486,14 +495,7 @@ void Eviction::TrimDeleted(bool empty) { break; } - // Normally we use 25% for each list. The experiment doubles the number of - // deleted entries, so the total number of entries increases by 25%. Using - // 40% of that value for deleted entries leaves the size of the other three - // lists intact. - int max_length = in_experiment_ ? header_->num_entries * 2 / 5 : - header_->num_entries / 4; - if (deleted_entries && !empty && !test_mode_ && - header_->lru.sizes[Rankings::DELETED] > max_length) { + if (deleted_entries && !empty && ShouldTrimDeleted()) { MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&Eviction::TrimDeleted, ptr_factory_.GetWeakPtr(), false)); } diff --git a/net/disk_cache/eviction.h b/net/disk_cache/eviction.h index 227cb4a..13fd546 100644 --- a/net/disk_cache/eviction.h +++ b/net/disk_cache/eviction.h @@ -48,6 +48,7 @@ class Eviction { void PostDelayedTrim(); void DelayedTrim(); bool ShouldTrim(); + bool ShouldTrimDeleted(); void ReportTrimTimes(EntryImpl* entry); Rankings::List GetListForEntry(EntryImpl* entry); bool EvictEntry(CacheRankingsBlock* node, bool empty, Rankings::List list); |