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

Unified Diff: net/disk_cache/mem_backend_impl.cc

Issue 120004: Introduce parent and child entries for MemEntryImpl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/mem_backend_impl.h ('k') | net/disk_cache/mem_entry_impl.h » ('j') | 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 18335)
+++ net/disk_cache/mem_backend_impl.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -128,6 +128,9 @@
}
void MemBackendImpl::InternalDoomEntry(MemEntryImpl* entry) {
+ // Only parent entries can be passed into this method.
+ DCHECK(entry->type() == MemEntryImpl::kParentEntry);
+
rankings_.Remove(entry);
EntryMap::iterator it = entries_.find(entry->GetKey());
if (it != entries_.end())
@@ -162,38 +165,33 @@
if (node->GetLastUsed() < initial_time)
break;
- if (node->GetLastUsed() < end_time) {
+ if (node->GetLastUsed() < end_time)
node->Doom();
- }
}
return true;
}
-// We use OpenNextEntry to retrieve elements from the cache, until we get
-// entries that are too old.
bool MemBackendImpl::DoomEntriesSince(const Time initial_time) {
for (;;) {
- Entry* entry;
- void* iter = NULL;
- if (!OpenNextEntry(&iter, &entry))
- return true;
+ // Get the entry in the front.
+ Entry* entry = rankings_.GetNext(NULL);
- if (initial_time > entry->GetLastUsed()) {
- entry->Close();
- EndEnumeration(&iter);
+ // Break the loop when there are no more entries or the entry is too old.
+ if (!entry || entry->GetLastUsed() < initial_time)
return true;
- }
-
entry->Doom();
- entry->Close();
- EndEnumeration(&iter); // Dooming the entry invalidates the iterator.
}
}
bool MemBackendImpl::OpenNextEntry(void** iter, Entry** next_entry) {
MemEntryImpl* current = reinterpret_cast<MemEntryImpl*>(*iter);
MemEntryImpl* node = rankings_.GetNext(current);
+ // We should never return a child entry so iterate until we hit a parent
+ // entry.
+ while (node && node->type() != MemEntryImpl::kParentEntry) {
+ node = rankings_.GetNext(node);
+ }
*next_entry = node;
*iter = node;
@@ -252,4 +250,12 @@
return max_size_ / 8;
}
+void MemBackendImpl::InsertIntoRankingList(MemEntryImpl* entry) {
+ rankings_.Insert(entry);
+}
+
+void MemBackendImpl::RemoveFromRankingList(MemEntryImpl* entry) {
+ rankings_.Remove(entry);
+}
+
} // namespace disk_cache
« no previous file with comments | « net/disk_cache/mem_backend_impl.h ('k') | net/disk_cache/mem_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698