diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 23:57:07 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 23:57:07 +0000 |
commit | d9fac60990a817c7ef7f1a7beef90dc319bf299b (patch) | |
tree | 97aa53708de3ee8cd33bcc7a1504442561244994 /net | |
parent | 89dbe690980344162fffc84c15a5f18e096b5981 (diff) | |
download | chromium_src-d9fac60990a817c7ef7f1a7beef90dc319bf299b.zip chromium_src-d9fac60990a817c7ef7f1a7beef90dc319bf299b.tar.gz chromium_src-d9fac60990a817c7ef7f1a7beef90dc319bf299b.tar.bz2 |
Disk cache: Avoid recursion when trimming entries.
TrimCacheV2() calls EvictEntry() to move a given entry to
the "deleted" list. EvictEntry() deletes the actual data,
and that may end up calling ModifyStorageSize() and
TrimCacheV2() again.
BUG=b/1909376
TEST=none
Review URL: http://codereview.chromium.org/121002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/backend_impl.cc | 2 | ||||
-rw-r--r-- | net/disk_cache/eviction.cc | 9 | ||||
-rw-r--r-- | net/disk_cache/eviction.h | 1 |
3 files changed, 9 insertions, 3 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 63db6b1..be7292d 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -713,7 +713,7 @@ int BackendImpl::MaxFileSize() const { } void BackendImpl::ModifyStorageSize(int32 old_size, int32 new_size) { - if (disabled_) + if (disabled_ || old_size == new_size) return; if (old_size > new_size) SubstractStorageSize(old_size - new_size); diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index cae5702..f4e74b2 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -65,6 +65,7 @@ void Eviction::Init(BackendImpl* backend) { max_size_ = LowWaterAdjust(backend_->max_size_); new_eviction_ = backend->new_eviction_; first_trim_ = true; + trimming_ = false; } void Eviction::TrimCache(bool empty) { @@ -72,9 +73,10 @@ void Eviction::TrimCache(bool empty) { return TrimCacheV2(empty); Trace("*** Trim Cache ***"); - if (backend_->disabled_) + if (backend_->disabled_ || trimming_) return; + trimming_ = true; Time start = Time::Now(); Rankings::ScopedRankingsBlock node(rankings_); Rankings::ScopedRankingsBlock next(rankings_, @@ -103,6 +105,7 @@ void Eviction::TrimCache(bool empty) { } CACHE_UMA(AGE_MS, "TotalTrimTime", 0, start); + trimming_ = false; Trace("*** Trim Cache end ***"); return; } @@ -204,9 +207,10 @@ bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) { void Eviction::TrimCacheV2(bool empty) { Trace("*** Trim Cache ***"); - if (backend_->disabled_) + if (backend_->disabled_ || trimming_) return; + trimming_ = true; Time start = Time::Now(); const int kListsToSearch = 3; @@ -274,6 +278,7 @@ void Eviction::TrimCacheV2(bool empty) { CACHE_UMA(AGE_MS, "TotalTrimTime", 0, start); Trace("*** Trim Cache end ***"); + trimming_ = false; return; } diff --git a/net/disk_cache/eviction.h b/net/disk_cache/eviction.h index 6526cff..3392680 100644 --- a/net/disk_cache/eviction.h +++ b/net/disk_cache/eviction.h @@ -67,6 +67,7 @@ class Eviction { int max_size_; bool new_eviction_; bool first_trim_; + bool trimming_; ScopedRunnableMethodFactory<Eviction> factory_; DISALLOW_COPY_AND_ASSIGN(Eviction); |