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

Unified Diff: net/disk_cache/addr.cc

Issue 16837003: Disk cache: Update Addr to handle file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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
Index: net/disk_cache/addr.cc
===================================================================
--- net/disk_cache/addr.cc (revision 205902)
+++ net/disk_cache/addr.cc (working copy)
@@ -26,7 +26,19 @@
return true;
}
-bool Addr::SanityCheck() const {
+Addr Addr::AsExternal() const {
+ DCHECK(file_type() == BLOCK_FILES);
+ CacheAddr new_value = value() & ~kFileTypeMask;
+ return Addr(new_value);
+}
+
+Addr Addr::AsBlockFile() const {
+ DCHECK(is_separate_file());
+ CacheAddr new_value = value() + (BLOCK_FILES << kFileTypeOffset);
+ return Addr(new_value);
+}
+
+bool Addr::SanityCheckV2() const {
if (!is_initialized())
return !value_;
@@ -40,8 +52,22 @@
return !(value_ & kReservedBitsMask);
}
+bool Addr::SanityCheckV3() const {
+ if (!is_initialized())
+ return !value_;
rvargas (doing something else) 2013/06/13 19:07:25 Just so that I understand your comment, are you sa
gavinp 2013/06/13 19:49:00 No, and this is probably one of the few uses of va
+
+ if (((value_ & kFileTypeMask) >> kFileTypeOffset) > BLOCK_FILES)
gavinp 2013/06/13 13:10:58 I don't understand this.
rvargas (doing something else) 2013/06/13 19:07:25 This is exactly the same check of SanityCheckV2 th
+ return false;
+
+ if (is_separate_file())
+ return true;
+
+ const uint32 kReservedBitsMask = 0x0c000000;
gavinp 2013/06/13 13:10:58 What's 0x0c000000?
rvargas (doing something else) 2013/06/13 19:07:25 That's the mask for the reserved bits of the value
gavinp 2013/06/13 19:49:00 Yeah, I saw that. But why not reserved_bits() == 0
+ return !(value_ & kReservedBitsMask);
+}
+
bool Addr::SanityCheckForEntryV2() const {
- if (!SanityCheck() || !is_initialized())
+ if (!SanityCheckV2() || !is_initialized())
return false;
if (is_separate_file() || file_type() != BLOCK_256)
@@ -50,8 +76,25 @@
return true;
}
+bool Addr::SanityCheckForEntryV3() const {
+ if (!is_initialized())
+ return false;
+
+ const uint32 kReservedBitsMask = 0x0c000000;
+ if (value_ & kReservedBitsMask)
+ return false;
+
+ if (file_type() != BLOCK_ENTRIES && file_type() != BLOCK_EVICTED)
+ return false;
+
+ if (num_blocks() != 1)
+ return false;
+
+ return true;
+}
+
bool Addr::SanityCheckForRankings() const {
- if (!SanityCheck() || !is_initialized())
+ if (!SanityCheckV2() || !is_initialized())
return false;
if (is_separate_file() || file_type() != RANKINGS || num_blocks() != 1)

Powered by Google App Engine
This is Rietveld 408576698