summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/backend_impl.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-16 19:32:06 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-16 19:32:06 +0000
commita8d8d24a94a87830253b27537cd05069a3b369b6 (patch)
treeb55701430cc0a4ff8c893bd4b352a897299fef8d /net/disk_cache/backend_impl.cc
parent557f1c9bb1c8c7f5cebbb6914a244b4b111725a6 (diff)
downloadchromium_src-a8d8d24a94a87830253b27537cd05069a3b369b6.zip
chromium_src-a8d8d24a94a87830253b27537cd05069a3b369b6.tar.gz
chromium_src-a8d8d24a94a87830253b27537cd05069a3b369b6.tar.bz2
Disk cache: remove the hard coded list from rankings.cc
The rankings module now works with any list, not just the first one. This is part of the support needed for new eviction algorithms. note: Rankings::CheckList() is basically the code that was implementing the old Rankings::SelfCheck() (moved with this cl). The disk cache behavior is not changing with this cl. Review URL: http://codereview.chromium.org/14141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7074 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/backend_impl.cc')
-rw-r--r--net/disk_cache/backend_impl.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index c9a2315..23b0f9dc 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -355,7 +355,7 @@ bool BackendImpl::CreateEntry(const std::string& key, Entry** entry) {
data_->header.num_entries++;
DCHECK(data_->header.num_entries > 0);
- rankings_.Insert(cache_entry->rankings(), true);
+ rankings_.Insert(cache_entry->rankings(), true, Rankings::NO_USE);
if (!parent.get())
data_->table[hash & mask_] = entry_address.value();
@@ -573,9 +573,10 @@ LruData* BackendImpl::GetLruData() {
return &data_->header.lru;
}
-void BackendImpl::UpdateRank(CacheRankingsBlock* node, bool modified) {
- if (!read_only_)
- rankings_.UpdateRank(node, modified);
+void BackendImpl::UpdateRank(EntryImpl* entry, bool modified) {
+ if (!read_only_) {
+ rankings_.UpdateRank(entry->rankings(), modified, Rankings::NO_USE);
+ }
}
void BackendImpl::RecoveredEntry(CacheRankingsBlock* rankings) {
@@ -603,7 +604,7 @@ void BackendImpl::InternalDoomEntry(EntryImpl* entry) {
Trace("Doom entry 0x%p", entry);
- rankings_.Remove(entry->rankings());
+ rankings_.Remove(entry->rankings(), Rankings::NO_USE);
entry->InternalDoom();
@@ -971,8 +972,9 @@ bool BackendImpl::OpenFollowingEntry(bool forward, void** iter,
Rankings::ScopedRankingsBlock rankings(&rankings_,
reinterpret_cast<CacheRankingsBlock*>(*iter));
- CacheRankingsBlock* next_block = forward ? rankings_.GetNext(rankings.get()) :
- rankings_.GetPrev(rankings.get());
+ CacheRankingsBlock* next_block = forward ?
+ rankings_.GetNext(rankings.get(), Rankings::NO_USE) :
+ rankings_.GetPrev(rankings.get(), Rankings::NO_USE);
Rankings::ScopedRankingsBlock next(&rankings_, next_block);
*next_entry = NULL;
*iter = NULL;
@@ -1018,7 +1020,7 @@ void BackendImpl::DestroyInvalidEntry(Addr address, EntryImpl* entry) {
LOG(WARNING) << "Destroying invalid entry.";
Trace("Destroying invalid entry 0x%p", entry);
- rankings_.Remove(entry->rankings());
+ rankings_.Remove(entry->rankings(), Rankings::NO_USE);
entry->SetPointerForInvalidEntry(GetCurrentEntryId());
entry->InternalDoom();
@@ -1035,13 +1037,14 @@ void BackendImpl::TrimCache(bool empty) {
Time start = Time::Now();
Rankings::ScopedRankingsBlock node(&rankings_);
- Rankings::ScopedRankingsBlock next(&rankings_, rankings_.GetPrev(node.get()));
+ Rankings::ScopedRankingsBlock next(&rankings_,
+ rankings_.GetPrev(node.get(), Rankings::NO_USE));
DCHECK(next.get());
int target_size = empty ? 0 : LowWaterAdjust(max_size_);
int deleted = 0;
while (data_->header.num_bytes > target_size && next.get()) {
node.reset(next.release());
- next.reset(rankings_.GetPrev(node.get()));
+ next.reset(rankings_.GetPrev(node.get(), Rankings::NO_USE));
if (!node->Data()->pointer || empty) {
// This entry is not being used by anybody.
EntryImpl* entry;