OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void Remove(CacheRankingsBlock* node, List list); | 120 void Remove(CacheRankingsBlock* node, List list); |
121 | 121 |
122 // Moves a given entry to the head. | 122 // Moves a given entry to the head. |
123 void UpdateRank(CacheRankingsBlock* node, bool modified, List list); | 123 void UpdateRank(CacheRankingsBlock* node, bool modified, List list); |
124 | 124 |
125 // Iterates through the list. | 125 // Iterates through the list. |
126 CacheRankingsBlock* GetNext(CacheRankingsBlock* node, List list); | 126 CacheRankingsBlock* GetNext(CacheRankingsBlock* node, List list); |
127 CacheRankingsBlock* GetPrev(CacheRankingsBlock* node, List list); | 127 CacheRankingsBlock* GetPrev(CacheRankingsBlock* node, List list); |
128 void FreeRankingsBlock(CacheRankingsBlock* node); | 128 void FreeRankingsBlock(CacheRankingsBlock* node); |
129 | 129 |
| 130 // Controls tracking of nodes used for enumerations. |
| 131 void TrackRankingsBlock(CacheRankingsBlock* node, bool start_tracking); |
| 132 |
130 // Peforms a simple self-check of the lists, and returns the number of items | 133 // Peforms a simple self-check of the lists, and returns the number of items |
131 // or an error code (negative value). | 134 // or an error code (negative value). |
132 int SelfCheck(); | 135 int SelfCheck(); |
133 | 136 |
134 // Returns false if the entry is clearly invalid. from_list is true if the | 137 // Returns false if the entry is clearly invalid. from_list is true if the |
135 // node comes from the LRU list. | 138 // node comes from the LRU list. |
136 bool SanityCheck(CacheRankingsBlock* node, bool from_list); | 139 bool SanityCheck(CacheRankingsBlock* node, bool from_list); |
137 | 140 |
138 private: | 141 private: |
139 typedef std::pair<CacheAddr, CacheRankingsBlock*> IteratorPair; | 142 typedef std::pair<CacheAddr, CacheRankingsBlock*> IteratorPair; |
(...skipping 24 matching lines...) Expand all Loading... |
164 bool CheckSingleLink(CacheRankingsBlock* prev, CacheRankingsBlock* next); | 167 bool CheckSingleLink(CacheRankingsBlock* prev, CacheRankingsBlock* next); |
165 | 168 |
166 // Peforms a simple check of the list, and returns the number of items or an | 169 // Peforms a simple check of the list, and returns the number of items or an |
167 // error code (negative value). | 170 // error code (negative value). |
168 int CheckList(List list); | 171 int CheckList(List list); |
169 | 172 |
170 // Returns true if addr is the head or tail of any list. | 173 // Returns true if addr is the head or tail of any list. |
171 bool IsHead(CacheAddr addr); | 174 bool IsHead(CacheAddr addr); |
172 bool IsTail(CacheAddr addr); | 175 bool IsTail(CacheAddr addr); |
173 | 176 |
174 // Controls tracking of nodes used for enumerations. | |
175 void TrackRankingsBlock(CacheRankingsBlock* node, bool start_tracking); | |
176 | |
177 // Updates the iterators whenever node is being changed. | 177 // Updates the iterators whenever node is being changed. |
178 void UpdateIterators(CacheRankingsBlock* node); | 178 void UpdateIterators(CacheRankingsBlock* node); |
179 | 179 |
180 // Verifies that no iterator gets invalidated by changing a node. | 180 // Invalidates the iterators pointing to this node. |
181 void NotAnIterator(CacheRankingsBlock* node); | 181 void InvalidateIterators(CacheRankingsBlock* node); |
182 | 182 |
183 // Keeps track of the number of entries on a list. | 183 // Keeps track of the number of entries on a list. |
184 void IncrementCounter(List list); | 184 void IncrementCounter(List list); |
185 void DecrementCounter(List list); | 185 void DecrementCounter(List list); |
186 | 186 |
187 bool init_; | 187 bool init_; |
188 bool count_lists_; | 188 bool count_lists_; |
189 Addr heads_[LAST_ELEMENT]; | 189 Addr heads_[LAST_ELEMENT]; |
190 Addr tails_[LAST_ELEMENT]; | 190 Addr tails_[LAST_ELEMENT]; |
191 BackendImpl* backend_; | 191 BackendImpl* backend_; |
192 LruData* control_data_; // Data related to the LRU lists. | 192 LruData* control_data_; // Data related to the LRU lists. |
193 IteratorList iterators_; | 193 IteratorList iterators_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(Rankings); | 195 DISALLOW_COPY_AND_ASSIGN(Rankings); |
196 }; | 196 }; |
197 | 197 |
198 } // namespace disk_cache | 198 } // namespace disk_cache |
199 | 199 |
200 #endif // NET_DISK_CACHE_RANKINGS_H_ | 200 #endif // NET_DISK_CACHE_RANKINGS_H_ |
OLD | NEW |