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

Side by Side Diff: net/disk_cache/rankings.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, 8 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
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 // See net/disk_cache/disk_cache.h for the public interface. 5 // See net/disk_cache/disk_cache.h for the public interface.
6 6
7 #ifndef NET_DISK_CACHE_RANKINGS_H_ 7 #ifndef NET_DISK_CACHE_RANKINGS_H_
8 #define NET_DISK_CACHE_RANKINGS_H_ 8 #define NET_DISK_CACHE_RANKINGS_H_
9 #pragma once 9 #pragma once
10 10
11 #include <list> 11 #include <list>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 bool SanityCheck(CacheRankingsBlock* node, bool from_list) const; 139 bool SanityCheck(CacheRankingsBlock* node, bool from_list) const;
140 bool DataSanityCheck(CacheRankingsBlock* node, bool from_list) const; 140 bool DataSanityCheck(CacheRankingsBlock* node, bool from_list) const;
141 141
142 // Sets the |contents| field of |node| to |address|. 142 // Sets the |contents| field of |node| to |address|.
143 void SetContents(CacheRankingsBlock* node, CacheAddr address); 143 void SetContents(CacheRankingsBlock* node, CacheAddr address);
144 144
145 private: 145 private:
146 typedef std::pair<CacheAddr, CacheRankingsBlock*> IteratorPair; 146 typedef std::pair<CacheAddr, CacheRankingsBlock*> IteratorPair;
147 typedef std::list<IteratorPair> IteratorList; 147 typedef std::list<IteratorPair> IteratorList;
148 148
149 enum ListDirection {
gavinp 2012/04/26 15:46:54 Maybe name this ForwardsOrBackwards ?
rvargas (doing something else) 2012/04/27 00:18:10 The name of a type should express what the type is
150 FORWARD,
151 BACKWARD
152 };
153
149 void ReadHeads(); 154 void ReadHeads();
150 void ReadTails(); 155 void ReadTails();
151 void WriteHead(List list); 156 void WriteHead(List list);
152 void WriteTail(List list); 157 void WriteTail(List list);
153 158
154 // Gets the rankings information for a given rankings node. We may end up 159 // Gets the rankings information for a given rankings node. We may end up
155 // sharing the actual memory with a loaded entry, but we are not taking a 160 // sharing the actual memory with a loaded entry, but we are not taking a
156 // reference to that entry, so |rankings| must be short lived. 161 // reference to that entry, so |rankings| must be short lived.
157 bool GetRanking(CacheRankingsBlock* rankings); 162 bool GetRanking(CacheRankingsBlock* rankings);
158 163
159 // Makes |rankings| suitable to live a long life. 164 // Makes |rankings| suitable to live a long life.
160 void ConvertToLongLived(CacheRankingsBlock* rankings); 165 void ConvertToLongLived(CacheRankingsBlock* rankings);
161 166
162 // Finishes a list modification after a crash. 167 // Finishes a list modification after a crash.
163 void CompleteTransaction(); 168 void CompleteTransaction();
164 void FinishInsert(CacheRankingsBlock* rankings); 169 void FinishInsert(CacheRankingsBlock* rankings);
165 void RevertRemove(CacheRankingsBlock* rankings); 170 void RevertRemove(CacheRankingsBlock* rankings);
166 171
167 // Returns false if this entry will not be recognized as dirty (called during
168 // selfcheck).
169 bool CheckEntry(CacheRankingsBlock* rankings);
170
171 // Returns false if node is not properly linked. This method may change the 172 // Returns false if node is not properly linked. This method may change the
172 // provided |list| to reflect the list where this node is actually stored. 173 // provided |list| to reflect the list where this node is actually stored.
173 bool CheckLinks(CacheRankingsBlock* node, CacheRankingsBlock* prev, 174 bool CheckLinks(CacheRankingsBlock* node, CacheRankingsBlock* prev,
174 CacheRankingsBlock* next, List* list); 175 CacheRankingsBlock* next, List* list);
175 176
176 // Checks the links between two consecutive nodes. 177 // Checks the links between two consecutive nodes.
177 bool CheckSingleLink(CacheRankingsBlock* prev, CacheRankingsBlock* next); 178 bool CheckSingleLink(CacheRankingsBlock* prev, CacheRankingsBlock* next);
178 179
179 // Peforms a simple check of the list, and returns the number of items or an 180 // Peforms a simple check of the list, and returns the number of items or an
180 // error code (negative value). 181 // error code (negative value).
181 int CheckList(List list); 182 int CheckList(List list);
182 183
184 // Walks a list in the desired direction until |stop1| or |stop2| nodes are
gavinp 2012/04/26 15:46:54 I like "end", as it's used in the standard library
185 // reached. Returns an error code (0 on success), the number of items verified
186 // and the addresses of the last nodes visited (|last2| was seen before
gavinp 2012/04/26 15:46:54 how about |second_last| and |last|?
187 // |last1|).
188 int CheckListSection(List list, Addr stop1, Addr stop2, ListDirection dir,
189 Addr* last1, Addr* last2, int* num_items);
190
183 // Returns true if addr is the head or tail of any list. When there is a 191 // Returns true if addr is the head or tail of any list. When there is a
184 // match |list| will contain the list number for |addr|. 192 // match |list| will contain the list number for |addr|.
185 bool IsHead(CacheAddr addr, List* list) const; 193 bool IsHead(CacheAddr addr, List* list) const;
186 bool IsTail(CacheAddr addr, List* list) const; 194 bool IsTail(CacheAddr addr, List* list) const;
187 195
188 // Updates the iterators whenever node is being changed. 196 // Updates the iterators whenever node is being changed.
189 void UpdateIterators(CacheRankingsBlock* node); 197 void UpdateIterators(CacheRankingsBlock* node);
190 198
191 // Invalidates the iterators pointing to this node. 199 // Invalidates the iterators pointing to this node.
192 void InvalidateIterators(CacheRankingsBlock* node); 200 void InvalidateIterators(CacheRankingsBlock* node);
193 201
194 // Keeps track of the number of entries on a list. 202 // Keeps track of the number of entries on a list.
195 void IncrementCounter(List list); 203 void IncrementCounter(List list);
196 void DecrementCounter(List list); 204 void DecrementCounter(List list);
197 205
198 bool init_; 206 bool init_;
199 bool count_lists_; 207 bool count_lists_;
200 Addr heads_[LAST_ELEMENT]; 208 Addr heads_[LAST_ELEMENT];
201 Addr tails_[LAST_ELEMENT]; 209 Addr tails_[LAST_ELEMENT];
202 BackendImpl* backend_; 210 BackendImpl* backend_;
203 LruData* control_data_; // Data related to the LRU lists. 211 LruData* control_data_; // Data related to the LRU lists.
204 IteratorList iterators_; 212 IteratorList iterators_;
205 213
206 DISALLOW_COPY_AND_ASSIGN(Rankings); 214 DISALLOW_COPY_AND_ASSIGN(Rankings);
207 }; 215 };
208 216
209 } // namespace disk_cache 217 } // namespace disk_cache
210 218
211 #endif // NET_DISK_CACHE_RANKINGS_H_ 219 #endif // NET_DISK_CACHE_RANKINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698