summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 23:49:28 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 23:49:28 +0000
commitcffa2055808bf2149ce48118dcacde477b7ead60 (patch)
tree20c0588b85a3baa06437b0836821e295bea7cc20 /net/disk_cache
parentced6953a1ba5203dfbab30fa42c35702b45d3525 (diff)
downloadchromium_src-cffa2055808bf2149ce48118dcacde477b7ead60.zip
chromium_src-cffa2055808bf2149ce48118dcacde477b7ead60.tar.gz
chromium_src-cffa2055808bf2149ce48118dcacde477b7ead60.tar.bz2
Disk cache: Make sure that we don't oveload the IO message
loop when there are (active) doomed entries that we want to remove from the "deleted" list. BUG=32119 TEST=unittests Review URL: http://codereview.chromium.org/969002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/backend_unittest.cc3
-rw-r--r--net/disk_cache/eviction.cc9
2 files changed, 9 insertions, 3 deletions
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index 9d4194b..07d9735 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -1458,6 +1458,9 @@ void DiskCacheBackendTest::BackendDoomAll() {
EXPECT_TRUE(cache_->DoomAllEntries());
ASSERT_EQ(0, cache_->GetEntryCount());
+ // We should stop posting tasks at some point (if we post any).
+ MessageLoop::current()->RunAllPending();
+
disk_cache::Entry *entry3, *entry4;
ASSERT_TRUE(cache_->CreateEntry("third", &entry3));
ASSERT_TRUE(cache_->CreateEntry("fourth", &entry4));
diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc
index 0d92935..0122b7a 100644
--- a/net/disk_cache/eviction.cc
+++ b/net/disk_cache/eviction.cc
@@ -420,13 +420,15 @@ void Eviction::TrimDeleted(bool empty) {
Rankings::ScopedRankingsBlock node(rankings_);
Rankings::ScopedRankingsBlock next(rankings_,
rankings_->GetPrev(node.get(), Rankings::DELETED));
+ bool deleted = false;
for (int i = 0; (i < 4 || empty) && next.get(); i++) {
node.reset(next.release());
next.reset(rankings_->GetPrev(node.get(), Rankings::DELETED));
- RemoveDeletedNode(node.get());
+ deleted |= RemoveDeletedNode(node.get());
}
- if (header_->lru.sizes[Rankings::DELETED] > header_->num_entries / 4)
+ if (deleted && !empty &&
+ header_->lru.sizes[Rankings::DELETED] > header_->num_entries / 4)
MessageLoop::current()->PostTask(FROM_HERE,
factory_.NewRunnableMethod(&Eviction::TrimDeleted, false));
@@ -449,10 +451,11 @@ bool Eviction::RemoveDeletedNode(CacheRankingsBlock* node) {
// We ignore the failure; we're removing the entry anyway.
entry->Update();
}
+ bool doomed = (entry->entry()->Data()->state == ENTRY_DOOMED);
entry->entry()->Data()->state = ENTRY_DOOMED;
entry->Doom();
entry->Release();
- return true;
+ return !doomed;
}
bool Eviction::NodeIsOldEnough(CacheRankingsBlock* node, int list) {