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) |