| Index: net/disk_cache/addr.cc
|
| ===================================================================
|
| --- net/disk_cache/addr.cc (revision 199883)
|
| +++ net/disk_cache/addr.cc (working copy)
|
| @@ -26,32 +26,75 @@
|
| return true;
|
| }
|
|
|
| -bool Addr::SanityCheck() const {
|
| +Addr Addr::AsExternal() const {
|
| + DCHECK(file_type() == BLOCK_FILES);
|
| + Addr new_addr(value_);
|
| + new_addr.SetFileType(EXTERNAL);
|
| + return new_addr;
|
| +}
|
| +
|
| +Addr Addr::AsBlockFile() const {
|
| + DCHECK(is_separate_file());
|
| + Addr new_addr(value_);
|
| + new_addr.SetFileType(BLOCK_FILES);
|
| + return new_addr;
|
| +}
|
| +
|
| +bool Addr::SanityCheckV2() const {
|
| if (!is_initialized())
|
| return !value_;
|
|
|
| - if (((value_ & kFileTypeMask) >> kFileTypeOffset) > 4)
|
| + if (file_type() > BLOCK_4K)
|
| return false;
|
|
|
| if (is_separate_file())
|
| return true;
|
|
|
| - const uint32 kReservedBitsMask = 0x0c000000;
|
| - return !(value_ & kReservedBitsMask);
|
| + return !reserved_bits();
|
| }
|
|
|
| -bool Addr::SanityCheckForEntry() const {
|
| - if (!SanityCheck() || !is_initialized())
|
| +bool Addr::SanityCheckV3() const {
|
| + if (!is_initialized())
|
| + return !value_;
|
| +
|
| + // For actual entries, SanityCheckForEntryV3 should be used.
|
| + if (file_type() > BLOCK_FILES)
|
| return false;
|
|
|
| + if (is_separate_file())
|
| + return true;
|
| +
|
| + return !reserved_bits();
|
| +}
|
| +
|
| +bool Addr::SanityCheckForEntryV2() const {
|
| + if (!SanityCheckV2() || !is_initialized())
|
| + return false;
|
| +
|
| if (is_separate_file() || file_type() != BLOCK_256)
|
| return false;
|
|
|
| return true;
|
| }
|
|
|
| +bool Addr::SanityCheckForEntryV3() const {
|
| + if (!is_initialized())
|
| + return false;
|
| +
|
| + if (reserved_bits())
|
| + 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)
|
| @@ -60,4 +103,9 @@
|
| return true;
|
| }
|
|
|
| +void Addr::SetFileType(FileType type) {
|
| + value_ &= ~kFileTypeMask;
|
| + value_ += type << kFileTypeOffset;
|
| +}
|
| +
|
| } // namespace disk_cache
|
|
|