Chromium Code Reviews| 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(); | |
|
Zhongyi Shi
2016/10/27 23:29:43
nit: I would prefer to have the default case but w
hans
2016/10/27 23:33:35
But then you won't get any compiler warning if ano
Zhongyi Shi
2016/10/28 00:01:49
What I am proposing is
case BLOCK_EVICTED:
retu
hans
2016/10/28 00:57:35
Yes, every enum needs to be handled in the switch,
Zhongyi Shi
2016/10/28 02:26:49
Alright, your argument sold, I agreed that this co
| |
| 142 return 0; | 144 return 0; |
| 143 } | 145 } |
| 144 } | 146 } |
| 145 | 147 |
| 146 static FileType RequiredFileType(int size) { | 148 static FileType RequiredFileType(int size) { |
| 147 if (size < 1024) | 149 if (size < 1024) |
| 148 return BLOCK_256; | 150 return BLOCK_256; |
| 149 else if (size < 4096) | 151 else if (size < 4096) |
| 150 return BLOCK_1K; | 152 return BLOCK_1K; |
| 151 else if (size <= 4096 * 4) | 153 else if (size <= 4096 * 4) |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 177 static const uint32_t kFileSelectorOffset = 16; | 179 static const uint32_t kFileSelectorOffset = 16; |
| 178 static const uint32_t kStartBlockMask = 0x0000FFFF; | 180 static const uint32_t kStartBlockMask = 0x0000FFFF; |
| 179 static const uint32_t kFileNameMask = 0x0FFFFFFF; | 181 static const uint32_t kFileNameMask = 0x0FFFFFFF; |
| 180 | 182 |
| 181 CacheAddr value_; | 183 CacheAddr value_; |
| 182 }; | 184 }; |
| 183 | 185 |
| 184 } // namespace disk_cache | 186 } // namespace disk_cache |
| 185 | 187 |
| 186 #endif // NET_DISK_CACHE_BLOCKFILE_ADDR_H_ | 188 #endif // NET_DISK_CACHE_BLOCKFILE_ADDR_H_ |
| OLD | NEW |