Chromium Code Reviews| Index: net/disk_cache/addr.h |
| =================================================================== |
| --- net/disk_cache/addr.h (revision 205902) |
| +++ net/disk_cache/addr.h (working copy) |
| @@ -16,15 +16,19 @@ |
| enum FileType { |
| EXTERNAL = 0, |
| RANKINGS = 1, |
| - BLOCK_256, |
| - BLOCK_1K, |
| - BLOCK_4K, |
| + BLOCK_256 = 2, |
| + BLOCK_1K = 3, |
| + BLOCK_4K = 4, |
| + BLOCK_FILES = 5, |
| + BLOCK_ENTRIES = 6, |
| + BLOCK_EVICTED = 7 |
| }; |
| const int kMaxBlockSize = 4096 * 4; |
| const int kMaxBlockFile = 255; |
| const int kMaxNumBlocks = 4; |
| const int kFirstAdditionalBlockFile = 4; |
| +const int kFirstAdditionalBlockFileV3 = 7; |
| // Defines a storage address for a cache record |
| // |
| @@ -38,6 +42,9 @@ |
| // 2 = 256 byte block file |
| // 3 = 1k byte block file |
| // 4 = 4k byte block file |
| +// 5 = external files block file |
| +// 6 = active entries block file |
| +// 7 = evicted entries block file |
| // |
| // If separate file: |
| // 0000 1111 1111 1111 1111 1111 1111 1111 : file# 0 - 268,435,456 (2^28) |
| @@ -101,6 +108,19 @@ |
| return value_ != other.value_; |
| } |
| + // Conversions between the address of an external file and the address of the |
| + // control block of that external file. |
| + Addr AsExternal() const; |
| + Addr AsBlockFile() const; |
| + |
| + static Addr FromEntryAddress(uint32 value) { |
| + return Addr(((8 + BLOCK_ENTRIES) << kFileTypeOffset) + value); |
|
gavinp
2013/06/13 13:10:58
8?
rvargas (doing something else)
2013/06/13 19:07:25
Rewrote it on a more explicit way.
|
| + } |
| + |
| + static Addr FromEvictedAddress(uint32 value) { |
| + return Addr(((8 + BLOCK_EVICTED) << kFileTypeOffset) + value); |
| + } |
| + |
| static int BlockSizeForFileType(FileType file_type) { |
| switch (file_type) { |
| case RANKINGS: |
| @@ -111,6 +131,12 @@ |
| return 1024; |
| case BLOCK_4K: |
| return 4096; |
| + case BLOCK_FILES: |
| + return 8; |
| + case BLOCK_ENTRIES: |
| + return 104; |
|
gavinp
2013/06/13 13:10:58
These magic numbers are killing me. Why 104?
rvargas (doing something else)
2013/06/13 19:07:25
Because there is a COMPILE_ASSERT(sizeof(EntryReco
|
| + case BLOCK_EVICTED: |
| + return 48; |
| default: |
| return 0; |
| } |
| @@ -133,8 +159,10 @@ |
| } |
| // Returns true if this address looks like a valid one. |
| - bool SanityCheck() const; |
| + bool SanityCheckV2() const; |
| + bool SanityCheckV3() const; |
| bool SanityCheckForEntryV2() const; |
| + bool SanityCheckForEntryV3() const; |
| bool SanityCheckForRankings() const; |
| private: |