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 // 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_ADDR_H_ | 8 #ifndef NET_DISK_CACHE_ADDR_H_ |
9 #define NET_DISK_CACHE_ADDR_H_ | 9 #define NET_DISK_CACHE_ADDR_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include "net/base/net_api.h" | 12 #include "net/base/net_export.h" |
13 #include "net/disk_cache/disk_format.h" | 13 #include "net/disk_cache/disk_format.h" |
14 | 14 |
15 namespace disk_cache { | 15 namespace disk_cache { |
16 | 16 |
17 enum FileType { | 17 enum FileType { |
18 EXTERNAL = 0, | 18 EXTERNAL = 0, |
19 RANKINGS = 1, | 19 RANKINGS = 1, |
20 BLOCK_256, | 20 BLOCK_256, |
21 BLOCK_1K, | 21 BLOCK_1K, |
22 BLOCK_4K, | 22 BLOCK_4K, |
(...skipping 18 matching lines...) Expand all Loading... |
41 // 4 = 4k byte block file | 41 // 4 = 4k byte block file |
42 // | 42 // |
43 // If separate file: | 43 // If separate file: |
44 // 0000 1111 1111 1111 1111 1111 1111 1111 : file# 0 - 268,435,456 (2^28) | 44 // 0000 1111 1111 1111 1111 1111 1111 1111 : file# 0 - 268,435,456 (2^28) |
45 // | 45 // |
46 // If block file: | 46 // If block file: |
47 // 0000 1100 0000 0000 0000 0000 0000 0000 : reserved bits | 47 // 0000 1100 0000 0000 0000 0000 0000 0000 : reserved bits |
48 // 0000 0011 0000 0000 0000 0000 0000 0000 : number of contiguous blocks 1-4 | 48 // 0000 0011 0000 0000 0000 0000 0000 0000 : number of contiguous blocks 1-4 |
49 // 0000 0000 1111 1111 0000 0000 0000 0000 : file selector 0 - 255 | 49 // 0000 0000 1111 1111 0000 0000 0000 0000 : file selector 0 - 255 |
50 // 0000 0000 0000 0000 1111 1111 1111 1111 : block# 0 - 65,535 (2^16) | 50 // 0000 0000 0000 0000 1111 1111 1111 1111 : block# 0 - 65,535 (2^16) |
51 class NET_TEST Addr { | 51 class NET_EXPORT_PRIVATE Addr { |
52 public: | 52 public: |
53 Addr() : value_(0) {} | 53 Addr() : value_(0) {} |
54 explicit Addr(CacheAddr address) : value_(address) {} | 54 explicit Addr(CacheAddr address) : value_(address) {} |
55 Addr(FileType file_type, int max_blocks, int block_file, int index) { | 55 Addr(FileType file_type, int max_blocks, int block_file, int index) { |
56 value_ = ((file_type << kFileTypeOffset) & kFileTypeMask) | | 56 value_ = ((file_type << kFileTypeOffset) & kFileTypeMask) | |
57 (((max_blocks - 1) << kNumBlocksOffset) & kNumBlocksMask) | | 57 (((max_blocks - 1) << kNumBlocksOffset) & kNumBlocksMask) | |
58 ((block_file << kFileSelectorOffset) & kFileSelectorMask) | | 58 ((block_file << kFileSelectorOffset) & kFileSelectorMask) | |
59 (index & kStartBlockMask) | kInitializedMask; | 59 (index & kStartBlockMask) | kInitializedMask; |
60 } | 60 } |
61 | 61 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 static const uint32 kFileSelectorOffset = 16; | 133 static const uint32 kFileSelectorOffset = 16; |
134 static const uint32 kStartBlockMask = 0x0000FFFF; | 134 static const uint32 kStartBlockMask = 0x0000FFFF; |
135 static const uint32 kFileNameMask = 0x0FFFFFFF; | 135 static const uint32 kFileNameMask = 0x0FFFFFFF; |
136 | 136 |
137 CacheAddr value_; | 137 CacheAddr value_; |
138 }; | 138 }; |
139 | 139 |
140 } // namespace disk_cache | 140 } // namespace disk_cache |
141 | 141 |
142 #endif // NET_DISK_CACHE_ADDR_H_ | 142 #endif // NET_DISK_CACHE_ADDR_H_ |
OLD | NEW |