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_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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 if (size < 1024) | 120 if (size < 1024) |
| 121 return BLOCK_256; | 121 return BLOCK_256; |
| 122 else if (size < 4096) | 122 else if (size < 4096) |
| 123 return BLOCK_1K; | 123 return BLOCK_1K; |
| 124 else if (size <= 4096 * 4) | 124 else if (size <= 4096 * 4) |
| 125 return BLOCK_4K; | 125 return BLOCK_4K; |
| 126 else | 126 else |
| 127 return EXTERNAL; | 127 return EXTERNAL; |
| 128 } | 128 } |
| 129 | 129 |
| 130 static int RequiredBlocks(int size, FileType file_type) { | |
|
gavinp
2013/05/23 15:32:33
This long list of inline functions seems not in ke
rvargas (doing something else)
2013/05/23 19:39:43
They are all trivial functions and I want to hint
| |
| 131 int block_size = BlockSizeForFileType(file_type); | |
| 132 return (size + block_size - 1) / block_size; | |
| 133 } | |
| 134 | |
| 130 // Returns true if this address looks like a valid one. | 135 // Returns true if this address looks like a valid one. |
| 131 bool SanityCheck() const; | 136 bool SanityCheck() const; |
| 132 bool SanityCheckForEntry() const; | 137 bool SanityCheckForEntry() const; |
| 133 bool SanityCheckForRankings() const; | 138 bool SanityCheckForRankings() const; |
| 134 | 139 |
| 135 private: | 140 private: |
| 136 static const uint32 kInitializedMask = 0x80000000; | 141 static const uint32 kInitializedMask = 0x80000000; |
| 137 static const uint32 kFileTypeMask = 0x70000000; | 142 static const uint32 kFileTypeMask = 0x70000000; |
| 138 static const uint32 kFileTypeOffset = 28; | 143 static const uint32 kFileTypeOffset = 28; |
| 139 static const uint32 kNumBlocksMask = 0x03000000; | 144 static const uint32 kNumBlocksMask = 0x03000000; |
| 140 static const uint32 kNumBlocksOffset = 24; | 145 static const uint32 kNumBlocksOffset = 24; |
| 141 static const uint32 kFileSelectorMask = 0x00ff0000; | 146 static const uint32 kFileSelectorMask = 0x00ff0000; |
| 142 static const uint32 kFileSelectorOffset = 16; | 147 static const uint32 kFileSelectorOffset = 16; |
| 143 static const uint32 kStartBlockMask = 0x0000FFFF; | 148 static const uint32 kStartBlockMask = 0x0000FFFF; |
| 144 static const uint32 kFileNameMask = 0x0FFFFFFF; | 149 static const uint32 kFileNameMask = 0x0FFFFFFF; |
| 145 | 150 |
| 146 CacheAddr value_; | 151 CacheAddr value_; |
| 147 }; | 152 }; |
| 148 | 153 |
| 149 } // namespace disk_cache | 154 } // namespace disk_cache |
| 150 | 155 |
| 151 #endif // NET_DISK_CACHE_ADDR_H_ | 156 #endif // NET_DISK_CACHE_ADDR_H_ |
| OLD | NEW |