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_ADDR_H_ | 8 #ifndef NET_DISK_CACHE_ADDR_H_ |
9 #define NET_DISK_CACHE_ADDR_H_ | 9 #define NET_DISK_CACHE_ADDR_H_ |
10 | 10 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 static Addr FromEntryAddress(uint32 value) { | 111 static Addr FromEntryAddress(uint32 value) { |
112 return Addr(kInitializedMask + (BLOCK_ENTRIES << kFileTypeOffset) + value); | 112 return Addr(kInitializedMask + (BLOCK_ENTRIES << kFileTypeOffset) + value); |
113 } | 113 } |
114 | 114 |
115 static Addr FromEvictedAddress(uint32 value) { | 115 static Addr FromEvictedAddress(uint32 value) { |
116 return Addr(kInitializedMask + (BLOCK_EVICTED << kFileTypeOffset) + value); | 116 return Addr(kInitializedMask + (BLOCK_EVICTED << kFileTypeOffset) + value); |
117 } | 117 } |
118 | 118 |
| 119 // Returns the part of the address that could be stored by the index. |
| 120 uint32 ToIndexEntryAddress() const { |
| 121 return value_ & (kFileSelectorMask | kStartBlockMask); |
| 122 } |
| 123 |
119 static int BlockSizeForFileType(FileType file_type) { | 124 static int BlockSizeForFileType(FileType file_type) { |
120 switch (file_type) { | 125 switch (file_type) { |
121 case RANKINGS: | 126 case RANKINGS: |
122 return 36; | 127 return 36; |
123 case BLOCK_256: | 128 case BLOCK_256: |
124 return 256; | 129 return 256; |
125 case BLOCK_1K: | 130 case BLOCK_1K: |
126 return 1024; | 131 return 1024; |
127 case BLOCK_4K: | 132 case BLOCK_4K: |
128 return 4096; | 133 return 4096; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 static const uint32 kFileSelectorOffset = 16; | 180 static const uint32 kFileSelectorOffset = 16; |
176 static const uint32 kStartBlockMask = 0x0000FFFF; | 181 static const uint32 kStartBlockMask = 0x0000FFFF; |
177 static const uint32 kFileNameMask = 0x0FFFFFFF; | 182 static const uint32 kFileNameMask = 0x0FFFFFFF; |
178 | 183 |
179 CacheAddr value_; | 184 CacheAddr value_; |
180 }; | 185 }; |
181 | 186 |
182 } // namespace disk_cache | 187 } // namespace disk_cache |
183 | 188 |
184 #endif // NET_DISK_CACHE_ADDR_H_ | 189 #endif // NET_DISK_CACHE_ADDR_H_ |
OLD | NEW |