diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 23:37:25 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 23:37:25 +0000 |
commit | 09ad77a8faf8896f0214e9c33958ad40f517c913 (patch) | |
tree | ad74937da5fa67b670dbfe7457f53f2d8e76b31c /net/disk_cache/rankings.cc | |
parent | 0cde05a0ecca163cc63aa68ae848aba9c469f45b (diff) | |
download | chromium_src-09ad77a8faf8896f0214e9c33958ad40f517c913.zip chromium_src-09ad77a8faf8896f0214e9c33958ad40f517c913.tar.gz chromium_src-09ad77a8faf8896f0214e9c33958ad40f517c913.tar.bz2 |
Disk cache: Add a hash to the entry's internal data.
EntryStore and RankingsNode now have a new member that
verifies that whatever we read from disk is what we
wrote before.
BUG=100125
TEST=none
Review URL: http://codereview.chromium.org/8658001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112336 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/rankings.cc')
-rw-r--r-- | net/disk_cache/rankings.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc index d478d92..4d936f3 100644 --- a/net/disk_cache/rankings.cc +++ b/net/disk_cache/rankings.cc @@ -494,6 +494,9 @@ int Rankings::SelfCheck() { } bool Rankings::SanityCheck(CacheRankingsBlock* node, bool from_list) const { + if (!node->VerifyHash()) + return false; + const RankingsNode* data = node->Data(); if ((!data->next && data->prev) || (data->next && !data->prev)) @@ -572,17 +575,14 @@ bool Rankings::GetRanking(CacheRankingsBlock* rankings) { backend_->OnEvent(Stats::OPEN_RANKINGS); - // "dummy" is the old "pointer" value, so it has to be 0. - if (!rankings->Data()->dirty && !rankings->Data()->dummy) + if (!rankings->Data()->dirty) return true; EntryImpl* entry = backend_->GetOpenEntry(rankings); if (!entry) { // We cannot trust this entry, but we cannot initiate a cleanup from this - // point (we may be in the middle of a cleanup already). Just get rid of - // the invalid pointer and continue; the entry will be deleted when detected - // from a regular open/create path. - rankings->Data()->dummy = 0; + // point (we may be in the middle of a cleanup already). The entry will be + // deleted when detected from a regular open/create path. rankings->Data()->dirty = backend_->GetCurrentEntryId() - 1; if (!rankings->Data()->dirty) rankings->Data()->dirty--; @@ -623,7 +623,6 @@ void Rankings::CompleteTransaction() { if (!node.Load()) return; - node.Data()->dummy = 0; node.Store(); Addr& my_head = heads_[control_data_->operation_list]; @@ -720,7 +719,7 @@ void Rankings::RevertRemove(CacheRankingsBlock* node) { } bool Rankings::CheckEntry(CacheRankingsBlock* rankings) { - if (!rankings->Data()->dummy) + if (rankings->VerifyHash()) return true; // If this entry is not dirty, it is a serious problem. |