| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // For a general description of the files used by the cache see file_format.h. | 5 // For a general description of the files used by the cache see file_format.h. |
| 6 // | 6 // |
| 7 // A block file is a file designed to store blocks of data of a given size. It | 7 // A block file is a file designed to store blocks of data of a given size. It |
| 8 // is able to store data that spans from one to four consecutive "blocks", and | 8 // is able to store data that spans from one to four consecutive "blocks", and |
| 9 // it grows as needed to store up to approximately 65000 blocks. It has a fixed | 9 // it grows as needed to store up to approximately 65000 blocks. It has a fixed |
| 10 // size header used for book keeping such as tracking free of blocks on the | 10 // size header used for book keeping such as tracking free of blocks on the |
| 11 // file. For example, a block-file for 1KB blocks will grow from 8KB when | 11 // file. For example, a block-file for 1KB blocks will grow from 8KB when |
| 12 // totally empty to about 64MB when completely full. At that point, data blocks | 12 // totally empty to about 64MB when completely full. At that point, data blocks |
| 13 // of 1KB will be stored on a second block file that will store the next set of | 13 // of 1KB will be stored on a second block file that will store the next set of |
| 14 // 65000 blocks. The first file contains the number of the second file, and the | 14 // 65000 blocks. The first file contains the number of the second file, and the |
| 15 // second file contains the number of a third file, created when the second file | 15 // second file contains the number of a third file, created when the second file |
| 16 // reaches its limit. It is important to remember that no matter how long the | 16 // reaches its limit. It is important to remember that no matter how long the |
| 17 // chain of files is, any given block can be located directly by its address, | 17 // chain of files is, any given block can be located directly by its address, |
| 18 // which contains the file number and starting block inside the file. | 18 // which contains the file number and starting block inside the file. |
| 19 | 19 |
| 20 #ifndef NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ | 20 #ifndef NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ |
| 21 #define NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ | 21 #define NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ |
| 22 | 22 |
| 23 #include <stdint.h> | 23 #include <stdint.h> |
| 24 | 24 |
| 25 #include "net/base/net_export.h" | |
| 26 | |
| 27 namespace disk_cache { | 25 namespace disk_cache { |
| 28 | 26 |
| 29 typedef uint32_t CacheAddr; | 27 typedef uint32_t CacheAddr; |
| 30 | 28 |
| 31 const uint32_t kBlockVersion2 = 0x20000; // Version 2.0. | 29 const uint32_t kBlockVersion2 = 0x20000; // Version 2.0. |
| 32 const uint32_t kBlockCurrentVersion = 0x30000; // Version 3.0. | 30 const uint32_t kBlockCurrentVersion = 0x30000; // Version 3.0. |
| 33 | 31 |
| 34 const uint32_t kBlockMagic = 0xC104CAC3; | 32 const uint32_t kBlockMagic = 0xC104CAC3; |
| 35 const int kBlockHeaderSize = 8192; // Two pages: almost 64k entries | 33 const int kBlockHeaderSize = 8192; // Two pages: almost 64k entries |
| 36 const int kMaxBlocks = (kBlockHeaderSize - 80) * 8; | 34 const int kMaxBlocks = (kBlockHeaderSize - 80) * 8; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 }; | 122 }; |
| 125 | 123 |
| 126 // The number of blocks stored by a child entry. | 124 // The number of blocks stored by a child entry. |
| 127 const int kNumSparseBits = 1024; | 125 const int kNumSparseBits = 1024; |
| 128 static_assert(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8, | 126 static_assert(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8, |
| 129 "invalid SparseData bitmap"); | 127 "invalid SparseData bitmap"); |
| 130 | 128 |
| 131 } // namespace disk_cache | 129 } // namespace disk_cache |
| 132 | 130 |
| 133 #endif // NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ | 131 #endif // NET_DISK_CACHE_BLOCKFILE_DISK_FORMAT_BASE_H_ |
| OLD | NEW |