Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: net/disk_cache/addr.h

Issue 17507006: Disk cache v3 ref2 Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Incl IndexTable cl Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/disk_cache/addr.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 bool operator==(Addr other) const { 103 bool operator==(Addr other) const {
104 return value_ == other.value_; 104 return value_ == other.value_;
105 } 105 }
106 106
107 bool operator!=(Addr other) const { 107 bool operator!=(Addr other) const {
108 return value_ != other.value_; 108 return value_ != other.value_;
109 } 109 }
110 110
111 // Conversions between the address of an external file and the address of the
112 // control block of that external file.
113 Addr AsExternal() const;
114 Addr AsBlockFile() const;
115
111 static Addr FromEntryAddress(uint32 value) { 116 static Addr FromEntryAddress(uint32 value) {
112 return Addr(kInitializedMask + (BLOCK_ENTRIES << kFileTypeOffset) + value); 117 return Addr(kInitializedMask + (BLOCK_ENTRIES << kFileTypeOffset) + value);
113 } 118 }
114 119
115 static Addr FromEvictedAddress(uint32 value) { 120 static Addr FromEvictedAddress(uint32 value) {
116 return Addr(kInitializedMask + (BLOCK_EVICTED << kFileTypeOffset) + value); 121 return Addr(kInitializedMask + (BLOCK_EVICTED << kFileTypeOffset) + value);
117 } 122 }
118 123
124 // Returns the part of the address that could be stored by the index.
125 uint32 ToIndexEntryAddress() const {
126 return value_ & (kFileSelectorMask | kStartBlockMask);
127 }
128
119 static int BlockSizeForFileType(FileType file_type) { 129 static int BlockSizeForFileType(FileType file_type) {
120 switch (file_type) { 130 switch (file_type) {
121 case RANKINGS: 131 case RANKINGS:
122 return 36; 132 return 36;
123 case BLOCK_256: 133 case BLOCK_256:
124 return 256; 134 return 256;
125 case BLOCK_1K: 135 case BLOCK_1K:
126 return 1024; 136 return 1024;
127 case BLOCK_4K: 137 case BLOCK_4K:
128 return 4096; 138 return 4096;
(...skipping 29 matching lines...) Expand all
158 bool SanityCheckV3() const; 168 bool SanityCheckV3() const;
159 bool SanityCheckForEntryV2() const; 169 bool SanityCheckForEntryV2() const;
160 bool SanityCheckForEntryV3() const; 170 bool SanityCheckForEntryV3() const;
161 bool SanityCheckForRankings() const; 171 bool SanityCheckForRankings() const;
162 172
163 private: 173 private:
164 uint32 reserved_bits() const { 174 uint32 reserved_bits() const {
165 return value_ & kReservedBitsMask; 175 return value_ & kReservedBitsMask;
166 } 176 }
167 177
178 void SetFileType(FileType type);
179
168 static const uint32 kInitializedMask = 0x80000000; 180 static const uint32 kInitializedMask = 0x80000000;
169 static const uint32 kFileTypeMask = 0x70000000; 181 static const uint32 kFileTypeMask = 0x70000000;
170 static const uint32 kFileTypeOffset = 28; 182 static const uint32 kFileTypeOffset = 28;
171 static const uint32 kReservedBitsMask = 0x0c000000; 183 static const uint32 kReservedBitsMask = 0x0c000000;
172 static const uint32 kNumBlocksMask = 0x03000000; 184 static const uint32 kNumBlocksMask = 0x03000000;
173 static const uint32 kNumBlocksOffset = 24; 185 static const uint32 kNumBlocksOffset = 24;
174 static const uint32 kFileSelectorMask = 0x00ff0000; 186 static const uint32 kFileSelectorMask = 0x00ff0000;
175 static const uint32 kFileSelectorOffset = 16; 187 static const uint32 kFileSelectorOffset = 16;
176 static const uint32 kStartBlockMask = 0x0000FFFF; 188 static const uint32 kStartBlockMask = 0x0000FFFF;
177 static const uint32 kFileNameMask = 0x0FFFFFFF; 189 static const uint32 kFileNameMask = 0x0FFFFFFF;
178 190
179 CacheAddr value_; 191 CacheAddr value_;
180 }; 192 };
181 193
182 } // namespace disk_cache 194 } // namespace disk_cache
183 195
184 #endif // NET_DISK_CACHE_ADDR_H_ 196 #endif // NET_DISK_CACHE_ADDR_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/addr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698