| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 Rankings* rankings_; | 88 Rankings* rankings_; |
| 89 DISALLOW_EVIL_CONSTRUCTORS(ScopedRankingsBlock); | 89 DISALLOW_EVIL_CONSTRUCTORS(ScopedRankingsBlock); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // If we have multiple lists, we have to iterate through all at the same time. | 92 // If we have multiple lists, we have to iterate through all at the same time. |
| 93 // This structure keeps track of where we are on the iteration. | 93 // This structure keeps track of where we are on the iteration. |
| 94 struct Iterator { | 94 struct Iterator { |
| 95 List list; // Which entry was returned to the user. | 95 List list; // Which entry was returned to the user. |
| 96 CacheRankingsBlock* nodes[3]; // Nodes on the first three lists. | 96 CacheRankingsBlock* nodes[3]; // Nodes on the first three lists. |
| 97 Rankings* my_rankings; | 97 Rankings* my_rankings; |
| 98 Iterator(Rankings* rankings) { | 98 explicit Iterator(Rankings* rankings) { |
| 99 memset(this, 0, sizeof(Iterator)); | 99 memset(this, 0, sizeof(Iterator)); |
| 100 my_rankings = rankings; | 100 my_rankings = rankings; |
| 101 } | 101 } |
| 102 ~Iterator() { | 102 ~Iterator() { |
| 103 for (int i = 0; i < 3; i++) | 103 for (int i = 0; i < 3; i++) |
| 104 ScopedRankingsBlock(my_rankings, nodes[i]); | 104 ScopedRankingsBlock(my_rankings, nodes[i]); |
| 105 } | 105 } |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 Rankings() : init_(false) {} | 108 Rankings() : init_(false) {} |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // Returns true if addr is the head or tail of any list. | 170 // Returns true if addr is the head or tail of any list. |
| 171 bool IsHead(CacheAddr addr); | 171 bool IsHead(CacheAddr addr); |
| 172 bool IsTail(CacheAddr addr); | 172 bool IsTail(CacheAddr addr); |
| 173 | 173 |
| 174 // Controls tracking of nodes used for enumerations. | 174 // Controls tracking of nodes used for enumerations. |
| 175 void TrackRankingsBlock(CacheRankingsBlock* node, bool start_tracking); | 175 void TrackRankingsBlock(CacheRankingsBlock* node, bool start_tracking); |
| 176 | 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. |
| 181 void NotAnIterator(CacheRankingsBlock* node); |
| 182 |
| 180 // Keeps track of the number of entries on a list. | 183 // Keeps track of the number of entries on a list. |
| 181 void IncrementCounter(List list); | 184 void IncrementCounter(List list); |
| 182 void DecrementCounter(List list); | 185 void DecrementCounter(List list); |
| 183 | 186 |
| 184 bool init_; | 187 bool init_; |
| 185 bool count_lists_; | 188 bool count_lists_; |
| 186 Addr heads_[LAST_ELEMENT]; | 189 Addr heads_[LAST_ELEMENT]; |
| 187 Addr tails_[LAST_ELEMENT]; | 190 Addr tails_[LAST_ELEMENT]; |
| 188 BackendImpl* backend_; | 191 BackendImpl* backend_; |
| 189 LruData* control_data_; // Data related to the LRU lists. | 192 LruData* control_data_; // Data related to the LRU lists. |
| 190 IteratorList iterators_; | 193 IteratorList iterators_; |
| 191 | 194 |
| 192 DISALLOW_COPY_AND_ASSIGN(Rankings); | 195 DISALLOW_COPY_AND_ASSIGN(Rankings); |
| 193 }; | 196 }; |
| 194 | 197 |
| 195 } // namespace disk_cache | 198 } // namespace disk_cache |
| 196 | 199 |
| 197 #endif // NET_DISK_CACHE_RANKINGS_H_ | 200 #endif // NET_DISK_CACHE_RANKINGS_H_ |
| OLD | NEW |