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

Unified Diff: net/disk_cache/mem_backend_impl.cc

Issue 12951014: Fix bug in MemEntryImpl, which caused browser crash during clearing (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 8 months 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/backend_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/mem_backend_impl.cc
===================================================================
--- net/disk_cache/mem_backend_impl.cc (revision 194868)
+++ net/disk_cache/mem_backend_impl.cc (working copy)
@@ -250,20 +250,26 @@
DCHECK(end_time >= initial_time);
- MemEntryImpl* next = rankings_.GetNext(NULL);
+ MemEntryImpl* node = rankings_.GetNext(NULL);
+ // Last valid entry before |node|.
+ // Note, that entries after |node| may become invalid during |node| doom in
+ // case when they are child entries of it. It is guaranteed that
+ // parent node will go prior to it childs in ranking list (see
+ // InternalReadSparseData and InternalWriteSparseData).
+ MemEntryImpl* last_valid = NULL;
// rankings_ is ordered by last used, this will descend through the cache
// and start dooming items before the end_time, and will stop once it reaches
// an item used before the initial time.
- while (next) {
- MemEntryImpl* node = next;
- next = rankings_.GetNext(next);
-
+ while (node) {
if (node->GetLastUsed() < initial_time)
break;
if (node->GetLastUsed() < end_time)
node->Doom();
+ else
+ last_valid = node;
+ node = rankings_.GetNext(last_valid);
}
return true;
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698