summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/disk_cache/eviction.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc
index 1a4a0f1..2086bd3 100644
--- a/net/disk_cache/eviction.cc
+++ b/net/disk_cache/eviction.cc
@@ -57,6 +57,10 @@ int LowWaterAdjust(int high_water) {
return high_water - kCleanUpMargin;
}
+bool FallingBehind(int current_size, int max_size) {
+ return current_size > max_size - kCleanUpMargin * 20;
+}
+
} // namespace
namespace disk_cache {
@@ -219,8 +223,10 @@ void Eviction::DelayedTrim() {
}
bool Eviction::ShouldTrim() {
- if (trim_delays_ < kMaxDelayedTrims && backend_->IsLoaded())
+ if (!FallingBehind(header_->num_bytes, max_size_) &&
+ trim_delays_ < kMaxDelayedTrims && backend_->IsLoaded()) {
return false;
+ }
UMA_HISTOGRAM_COUNTS("DiskCache.TrimDelays", trim_delays_);
trim_delays_ = 0;