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

Unified Diff: net/disk_cache/addr.h

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 years, 1 month 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') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/addr.h
===================================================================
--- net/disk_cache/addr.h (revision 199883)
+++ net/disk_cache/addr.h (working copy)
@@ -9,22 +9,26 @@
#define NET_DISK_CACHE_ADDR_H_
#include "net/base/net_export.h"
-#include "net/disk_cache/disk_format.h"
+#include "net/disk_cache/disk_format_base.h"
namespace disk_cache {
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)
@@ -47,6 +54,18 @@
// 0000 0011 0000 0000 0000 0000 0000 0000 : number of contiguous blocks 1-4
// 0000 0000 1111 1111 0000 0000 0000 0000 : file selector 0 - 255
// 0000 0000 0000 0000 1111 1111 1111 1111 : block# 0 - 65,535 (2^16)
+//
+// Note that an Addr can be used to "point" to a variety of different objects,
+// from a given type of entry to random blobs of data. Conceptually, an Addr is
+// just a number that someone can inspect to find out how to locate the desired
+// record. Most users will not care about the specific bits inside Addr, for
+// example, what parts of it point to a file number; only the code that has to
+// select a specific file would care about those specific bits.
+//
+// From a general point of view, an Addr has a total capacity of 2^24 entities,
+// in that it has 24 bits that can identify individual records. Note that the
+// address space is bigger for independent files (2^28), but that would not be
+// the general case.
class NET_EXPORT_PRIVATE Addr {
public:
Addr() : value_(0) {}
@@ -101,6 +120,11 @@
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 int BlockSizeForFileType(FileType file_type) {
switch (file_type) {
case RANKINGS:
@@ -111,6 +135,12 @@
return 1024;
case BLOCK_4K:
return 4096;
+ case BLOCK_FILES:
+ return 8;
+ case BLOCK_ENTRIES:
+ return 104;
+ case BLOCK_EVICTED:
+ return 48;
default:
return 0;
}
@@ -127,15 +157,29 @@
return EXTERNAL;
}
+ static int RequiredBlocks(int size, FileType file_type) {
+ int block_size = BlockSizeForFileType(file_type);
+ return (size + block_size - 1) / block_size;
+ }
+
// Returns true if this address looks like a valid one.
- bool SanityCheck() const;
- bool SanityCheckForEntry() const;
+ bool SanityCheckV2() const;
+ bool SanityCheckV3() const;
+ bool SanityCheckForEntryV2() const;
+ bool SanityCheckForEntryV3() const;
bool SanityCheckForRankings() const;
private:
+ uint32 reserved_bits() const {
+ return value_ & kReservedBitsMask;
+ }
+
+ void SetFileType(FileType type);
+
static const uint32 kInitializedMask = 0x80000000;
static const uint32 kFileTypeMask = 0x70000000;
static const uint32 kFileTypeOffset = 28;
+ static const uint32 kReservedBitsMask = 0x0c000000;
static const uint32 kNumBlocksMask = 0x03000000;
static const uint32 kNumBlocksOffset = 24;
static const uint32 kFileSelectorMask = 0x00ff0000;
« no previous file with comments | « no previous file | net/disk_cache/addr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698