| 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> | 11 #include <stddef.h> |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include "base/logging.h" |
| 14 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 15 #include "net/disk_cache/blockfile/disk_format_base.h" | 16 #include "net/disk_cache/blockfile/disk_format_base.h" |
| 16 | 17 |
| 17 namespace disk_cache { | 18 namespace disk_cache { |
| 18 | 19 |
| 19 enum FileType { | 20 enum FileType { |
| 20 EXTERNAL = 0, | 21 EXTERNAL = 0, |
| 21 RANKINGS = 1, | 22 RANKINGS = 1, |
| 22 BLOCK_256 = 2, | 23 BLOCK_256 = 2, |
| 23 BLOCK_1K = 3, | 24 BLOCK_1K = 3, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 case BLOCK_1K: | 132 case BLOCK_1K: |
| 132 return 1024; | 133 return 1024; |
| 133 case BLOCK_4K: | 134 case BLOCK_4K: |
| 134 return 4096; | 135 return 4096; |
| 135 case BLOCK_FILES: | 136 case BLOCK_FILES: |
| 136 return 8; | 137 return 8; |
| 137 case BLOCK_ENTRIES: | 138 case BLOCK_ENTRIES: |
| 138 return 104; | 139 return 104; |
| 139 case BLOCK_EVICTED: | 140 case BLOCK_EVICTED: |
| 140 return 48; | 141 return 48; |
| 141 default: | 142 case EXTERNAL: |
| 143 NOTREACHED(); |
| 142 return 0; | 144 return 0; |
| 143 } | 145 } |
| 146 return 0; |
| 144 } | 147 } |
| 145 | 148 |
| 146 static FileType RequiredFileType(int size) { | 149 static FileType RequiredFileType(int size) { |
| 147 if (size < 1024) | 150 if (size < 1024) |
| 148 return BLOCK_256; | 151 return BLOCK_256; |
| 149 else if (size < 4096) | 152 else if (size < 4096) |
| 150 return BLOCK_1K; | 153 return BLOCK_1K; |
| 151 else if (size <= 4096 * 4) | 154 else if (size <= 4096 * 4) |
| 152 return BLOCK_4K; | 155 return BLOCK_4K; |
| 153 else | 156 else |
| (...skipping 23 matching lines...) Expand all Loading... |
| 177 static const uint32_t kFileSelectorOffset = 16; | 180 static const uint32_t kFileSelectorOffset = 16; |
| 178 static const uint32_t kStartBlockMask = 0x0000FFFF; | 181 static const uint32_t kStartBlockMask = 0x0000FFFF; |
| 179 static const uint32_t kFileNameMask = 0x0FFFFFFF; | 182 static const uint32_t kFileNameMask = 0x0FFFFFFF; |
| 180 | 183 |
| 181 CacheAddr value_; | 184 CacheAddr value_; |
| 182 }; | 185 }; |
| 183 | 186 |
| 184 } // namespace disk_cache | 187 } // namespace disk_cache |
| 185 | 188 |
| 186 #endif // NET_DISK_CACHE_BLOCKFILE_ADDR_H_ | 189 #endif // NET_DISK_CACHE_BLOCKFILE_ADDR_H_ |
| OLD | NEW |