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

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

Issue 10148001: Disk Cache: Add more corruption tracking histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months 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) 2011 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 #pragma once 10 #pragma once
11 11
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return ((value_ & kFileSelectorMask) >> kFileSelectorOffset); 87 return ((value_ & kFileSelectorMask) >> kFileSelectorOffset);
88 } 88 }
89 89
90 int start_block() const; 90 int start_block() const;
91 int num_blocks() const; 91 int num_blocks() const;
92 bool SetFileNumber(int file_number); 92 bool SetFileNumber(int file_number);
93 int BlockSize() const { 93 int BlockSize() const {
94 return BlockSizeForFileType(file_type()); 94 return BlockSizeForFileType(file_type());
95 } 95 }
96 96
97 bool operator==(Addr other) const {
98 return value_ == other.value_;
99 }
100
101 bool operator!=(Addr other) const {
102 return value_ != other.value_;
103 }
104
97 static int BlockSizeForFileType(FileType file_type) { 105 static int BlockSizeForFileType(FileType file_type) {
98 switch (file_type) { 106 switch (file_type) {
99 case RANKINGS: 107 case RANKINGS:
100 return 36; 108 return 36;
101 case BLOCK_256: 109 case BLOCK_256:
102 return 256; 110 return 256;
103 case BLOCK_1K: 111 case BLOCK_1K:
104 return 1024; 112 return 1024;
105 case BLOCK_4K: 113 case BLOCK_4K:
106 return 4096; 114 return 4096;
107 default: 115 default:
108 return 0; 116 return 0;
109 } 117 }
110 } 118 }
111 119
112 static FileType RequiredFileType(int size) { 120 static FileType RequiredFileType(int size) {
113 if (size < 1024) 121 if (size < 1024)
114 return BLOCK_256; 122 return BLOCK_256;
115 else if (size < 4096) 123 else if (size < 4096)
116 return BLOCK_1K; 124 return BLOCK_1K;
117 else if (size <= 4096 * 4) 125 else if (size <= 4096 * 4)
118 return BLOCK_4K; 126 return BLOCK_4K;
119 else 127 else
120 return EXTERNAL; 128 return EXTERNAL;
121 } 129 }
122 130
123 // Returns true if this address looks like a valid one. 131 // Returns true if this address looks like a valid one.
124 bool SanityCheck() const; 132 bool SanityCheck() const;
133 bool SanityCheckForEntry() const;
134 bool SanityCheckForRankings() const;
125 135
126 private: 136 private:
127 static const uint32 kInitializedMask = 0x80000000; 137 static const uint32 kInitializedMask = 0x80000000;
128 static const uint32 kFileTypeMask = 0x70000000; 138 static const uint32 kFileTypeMask = 0x70000000;
129 static const uint32 kFileTypeOffset = 28; 139 static const uint32 kFileTypeOffset = 28;
130 static const uint32 kNumBlocksMask = 0x03000000; 140 static const uint32 kNumBlocksMask = 0x03000000;
131 static const uint32 kNumBlocksOffset = 24; 141 static const uint32 kNumBlocksOffset = 24;
132 static const uint32 kFileSelectorMask = 0x00ff0000; 142 static const uint32 kFileSelectorMask = 0x00ff0000;
133 static const uint32 kFileSelectorOffset = 16; 143 static const uint32 kFileSelectorOffset = 16;
134 static const uint32 kStartBlockMask = 0x0000FFFF; 144 static const uint32 kStartBlockMask = 0x0000FFFF;
135 static const uint32 kFileNameMask = 0x0FFFFFFF; 145 static const uint32 kFileNameMask = 0x0FFFFFFF;
136 146
137 CacheAddr value_; 147 CacheAddr value_;
138 }; 148 };
139 149
140 } // namespace disk_cache 150 } // namespace disk_cache
141 151
142 #endif // NET_DISK_CACHE_ADDR_H_ 152 #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