summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
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) {