| 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 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace disk_cache { | 26 namespace disk_cache { |
| 27 | 27 |
| 28 typedef uint32 CacheAddr; | 28 typedef uint32 CacheAddr; |
| 29 | 29 |
| 30 const uint32 kBlockVersion2 = 0x20000; // Version 2.0. | 30 const uint32 kBlockVersion2 = 0x20000; // Version 2.0. |
| 31 const uint32 kBlockCurrentVersion = 0x30000; // Version 3.0. | 31 const uint32 kBlockCurrentVersion = 0x30000; // Version 3.0. |
| 32 | 32 |
| 33 const uint32 kBlockMagic = 0xC104CAC3; | 33 const uint32 kBlockMagic = 0xC104CAC3; |
| 34 const int kBlockHeaderSize = 8192; // Two pages: almost 64k entries | 34 const int kBlockHeaderSize = 8192; // Two pages: almost 64k entries |
| 35 const int kMaxBlocks = (kBlockHeaderSize - 80) * 8; | 35 const int kMaxBlocks = (kBlockHeaderSize - 80) * 8; |
| 36 const int kNumExtraBlocks = 1024; |
| 36 | 37 |
| 37 // Bitmap to track used blocks on a block-file. | 38 // Bitmap to track used blocks on a block-file. |
| 38 typedef uint32 AllocBitmap[kMaxBlocks / 32]; | 39 typedef uint32 AllocBitmap[kMaxBlocks / 32]; |
| 39 | 40 |
| 40 // A block-file is the file used to store information in blocks (could be | 41 // A block-file is the file used to store information in blocks (could be |
| 41 // EntryStore blocks, RankingsNode blocks or user-data blocks). | 42 // EntryStore blocks, RankingsNode blocks or user-data blocks). |
| 42 // We store entries that can expand for up to 4 consecutive blocks, and keep | 43 // We store entries that can expand for up to 4 consecutive blocks, and keep |
| 43 // counters of the number of blocks available for each type of entry. For | 44 // counters of the number of blocks available for each type of entry. For |
| 44 // instance, an entry of 3 blocks is an entry of type 3. We also keep track of | 45 // instance, an entry of 3 blocks is an entry of type 3. We also keep track of |
| 45 // where did we find the last entry of that type (to avoid searching the bitmap | 46 // where did we find the last entry of that type (to avoid searching the bitmap |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 // The number of blocks stored by a child entry. | 125 // The number of blocks stored by a child entry. |
| 125 const int kNumSparseBits = 1024; | 126 const int kNumSparseBits = 1024; |
| 126 COMPILE_ASSERT(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8, | 127 COMPILE_ASSERT(sizeof(SparseData) == sizeof(SparseHeader) + kNumSparseBits / 8, |
| 127 Invalid_SparseData_bitmap); | 128 Invalid_SparseData_bitmap); |
| 128 | 129 |
| 129 } // namespace disk_cache | 130 } // namespace disk_cache |
| 130 | 131 |
| 131 #endif // NET_DISK_CACHE_DISK_FORMAT_BASE_H_ | 132 #endif // NET_DISK_CACHE_DISK_FORMAT_BASE_H_ |
| OLD | NEW |