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

Side by Side Diff: net/disk_cache/disk_format.h

Issue 155590: Disk cache: Add support for having a sparse entry block that... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The cache is stored on disk as a collection of block-files, plus an index 5 // The cache is stored on disk as a collection of block-files, plus an index
6 // file plus a collection of external files. 6 // file plus a collection of external files.
7 // 7 //
8 // Any data blob bigger than kMaxBlockSize (net/addr.h) will be stored on a 8 // Any data blob bigger than kMaxBlockSize (net/addr.h) will be stored on a
9 // separate file named f_xxx where x is a hexadecimal number. Shorter data will 9 // separate file named f_xxx where x is a hexadecimal number. Shorter data will
10 // be stored as a series of blocks on a block-file. In any case, CacheAddr 10 // be stored as a series of blocks on a block-file. In any case, CacheAddr
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // 226 //
227 // Each child entry keeps track of all the 1 KB blocks that have been written 227 // Each child entry keeps track of all the 1 KB blocks that have been written
228 // to the entry, but being a regular entry, it will happily return zeros for any 228 // to the entry, but being a regular entry, it will happily return zeros for any
229 // read that spans data not written before. The actual sparse data is stored in 229 // read that spans data not written before. The actual sparse data is stored in
230 // one of the data streams of the child entry (at index 1), while the control 230 // one of the data streams of the child entry (at index 1), while the control
231 // information is stored in another stream (at index 2), both by parents and 231 // information is stored in another stream (at index 2), both by parents and
232 // the children. 232 // the children.
233 233
234 // This structure contains the control information for parent and child entries. 234 // This structure contains the control information for parent and child entries.
235 // It is stored at offset 0 of the data stream with index 2. 235 // It is stored at offset 0 of the data stream with index 2.
236 // It is possible to write to a child entry in a way that causes the last block
237 // to be only partialy filled. In that case, last_block and last_block_len will
238 // keep track of that block.
236 struct SparseHeader { 239 struct SparseHeader {
237 int64 signature; // The parent and children signature. 240 int64 signature; // The parent and children signature.
238 uint32 magic; // Structure identifier (equal to kIndexMagic). 241 uint32 magic; // Structure identifier (equal to kIndexMagic).
239 int32 parent_key_len; // Key length for the parent entry. 242 int32 parent_key_len; // Key length for the parent entry.
240 int32 dummy[4]; 243 int32 last_block; // Index of the last written block.
244 int32 last_block_len; // Lenght of the last written block.
245 int32 dummy[10];
241 }; 246 };
242 247
243 // The SparseHeader will be followed by a bitmap, as described by this 248 // The SparseHeader will be followed by a bitmap, as described by this
244 // structure. 249 // structure.
245 struct SparseData { 250 struct SparseData {
246 SparseHeader header; 251 SparseHeader header;
247 uint32 bitmap[32]; // Bitmap representation of known children (if this 252 uint32 bitmap[32]; // Bitmap representation of known children (if this
248 // is a parent entry), or used blocks (for child 253 // is a parent entry), or used blocks (for child
249 // entries. The size is fixed for child entries but 254 // entries. The size is fixed for child entries but
250 // not for parents; it can be as small as 4 bytes 255 // not for parents; it can be as small as 4 bytes
251 // and as large as 8 KB. 256 // and as large as 8 KB.
252 }; 257 };
253 258
254 // The number of blocks stored by a child entry. 259 // The number of blocks stored by a child entry.
255 const int kNumSparseBits = 1024; 260 const int kNumSparseBits = 1024;
256 COMPILE_ASSERT(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8, 261 COMPILE_ASSERT(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8,
257 Invalid_SparseData_bitmap); 262 Invalid_SparseData_bitmap);
258 263
259 } // namespace disk_cache 264 } // namespace disk_cache
260 265
261 #endif // NET_DISK_CACHE_DISK_FORMAT_H_ 266 #endif // NET_DISK_CACHE_DISK_FORMAT_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/entry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698