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

Unified Diff: net/disk_cache/addr.h

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
« no previous file with comments | « no previous file | net/disk_cache/addr.cc » ('j') | net/disk_cache/addr.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | net/disk_cache/addr.cc » ('j') | net/disk_cache/addr.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698