OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This is an internal class that handles the address of a cache record. | 5 // This is an internal class that handles the address of a cache record. |
6 // See net/disk_cache/disk_cache.h for the public interface of the cache. | 6 // See net/disk_cache/disk_cache.h for the public interface of the cache. |
7 | 7 |
8 #ifndef NET_DISK_CACHE_BLOCKFILE_ADDR_H_ | 8 #ifndef NET_DISK_CACHE_BLOCKFILE_ADDR_H_ |
9 #define NET_DISK_CACHE_BLOCKFILE_ADDR_H_ | 9 #define NET_DISK_CACHE_BLOCKFILE_ADDR_H_ |
10 | 10 |
| 11 #include <stddef.h> |
| 12 #include <stdint.h> |
| 13 |
11 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
12 #include "net/disk_cache/blockfile/disk_format_base.h" | 15 #include "net/disk_cache/blockfile/disk_format_base.h" |
13 | 16 |
14 namespace disk_cache { | 17 namespace disk_cache { |
15 | 18 |
16 enum FileType { | 19 enum FileType { |
17 EXTERNAL = 0, | 20 EXTERNAL = 0, |
18 RANKINGS = 1, | 21 RANKINGS = 1, |
19 BLOCK_256 = 2, | 22 BLOCK_256 = 2, |
20 BLOCK_1K = 3, | 23 BLOCK_1K = 3, |
21 BLOCK_4K = 4, | 24 BLOCK_4K = 4, |
22 BLOCK_FILES = 5, | 25 BLOCK_FILES = 5, |
23 BLOCK_ENTRIES = 6, | 26 BLOCK_ENTRIES = 6, |
24 BLOCK_EVICTED = 7 | 27 BLOCK_EVICTED = 7 |
25 }; | 28 }; |
26 | 29 |
27 const int kMaxBlockSize = 4096 * 4; | 30 const int kMaxBlockSize = 4096 * 4; |
28 const int16 kMaxBlockFile = 255; | 31 const int16_t kMaxBlockFile = 255; |
29 const int kMaxNumBlocks = 4; | 32 const int kMaxNumBlocks = 4; |
30 const int16 kFirstAdditionalBlockFile = 4; | 33 const int16_t kFirstAdditionalBlockFile = 4; |
31 const size_t kFirstAdditionalBlockFileV3 = 7; | 34 const size_t kFirstAdditionalBlockFileV3 = 7; |
32 | 35 |
33 // Defines a storage address for a cache record | 36 // Defines a storage address for a cache record |
34 // | 37 // |
35 // Header: | 38 // Header: |
36 // 1000 0000 0000 0000 0000 0000 0000 0000 : initialized bit | 39 // 1000 0000 0000 0000 0000 0000 0000 0000 : initialized bit |
37 // 0111 0000 0000 0000 0000 0000 0000 0000 : file type | 40 // 0111 0000 0000 0000 0000 0000 0000 0000 : file type |
38 // | 41 // |
39 // File type values: | 42 // File type values: |
40 // 0 = separate file on disk | 43 // 0 = separate file on disk |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 161 } |
159 | 162 |
160 // Returns true if this address looks like a valid one. | 163 // Returns true if this address looks like a valid one. |
161 bool SanityCheckV2() const; | 164 bool SanityCheckV2() const; |
162 bool SanityCheckV3() const; | 165 bool SanityCheckV3() const; |
163 bool SanityCheckForEntryV2() const; | 166 bool SanityCheckForEntryV2() const; |
164 bool SanityCheckForEntryV3() const; | 167 bool SanityCheckForEntryV3() const; |
165 bool SanityCheckForRankings() const; | 168 bool SanityCheckForRankings() const; |
166 | 169 |
167 private: | 170 private: |
168 uint32 reserved_bits() const { | 171 uint32_t reserved_bits() const { return value_ & kReservedBitsMask; } |
169 return value_ & kReservedBitsMask; | |
170 } | |
171 | 172 |
172 static const uint32 kInitializedMask = 0x80000000; | 173 static const uint32_t kInitializedMask = 0x80000000; |
173 static const uint32 kFileTypeMask = 0x70000000; | 174 static const uint32_t kFileTypeMask = 0x70000000; |
174 static const uint32 kFileTypeOffset = 28; | 175 static const uint32_t kFileTypeOffset = 28; |
175 static const uint32 kReservedBitsMask = 0x0c000000; | 176 static const uint32_t kReservedBitsMask = 0x0c000000; |
176 static const uint32 kNumBlocksMask = 0x03000000; | 177 static const uint32_t kNumBlocksMask = 0x03000000; |
177 static const uint32 kNumBlocksOffset = 24; | 178 static const uint32_t kNumBlocksOffset = 24; |
178 static const uint32 kFileSelectorMask = 0x00ff0000; | 179 static const uint32_t kFileSelectorMask = 0x00ff0000; |
179 static const uint32 kFileSelectorOffset = 16; | 180 static const uint32_t kFileSelectorOffset = 16; |
180 static const uint32 kStartBlockMask = 0x0000FFFF; | 181 static const uint32_t kStartBlockMask = 0x0000FFFF; |
181 static const uint32 kFileNameMask = 0x0FFFFFFF; | 182 static const uint32_t kFileNameMask = 0x0FFFFFFF; |
182 | 183 |
183 CacheAddr value_; | 184 CacheAddr value_; |
184 }; | 185 }; |
185 | 186 |
186 } // namespace disk_cache | 187 } // namespace disk_cache |
187 | 188 |
188 #endif // NET_DISK_CACHE_BLOCKFILE_ADDR_H_ | 189 #endif // NET_DISK_CACHE_BLOCKFILE_ADDR_H_ |
OLD | NEW |