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

Unified Diff: net/disk_cache/eviction.cc

Issue 8540027: Disk Cache: Avoid discarding more deleted entries (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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/disk_cache/eviction.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/eviction.cc
===================================================================
--- net/disk_cache/eviction.cc (revision 109680)
+++ net/disk_cache/eviction.cc (working copy)
@@ -224,6 +224,16 @@
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 @@
if (empty) {
TrimDeleted(true);
- } else if (header_->lru.sizes[Rankings::DELETED] > header_->num_entries / 4 &&
- !test_mode_) {
+ } else if (ShouldTrimDeleted()) {
gavinp 2011/11/15 16:17:56 Good catch.
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&Eviction::TrimDeleted, ptr_factory_.GetWeakPtr(), empty));
}
@@ -486,14 +495,7 @@
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));
}
« no previous file with comments | « net/disk_cache/eviction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698