OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Rankings* rankings_; | 89 Rankings* rankings_; |
90 DISALLOW_COPY_AND_ASSIGN(ScopedRankingsBlock); | 90 DISALLOW_COPY_AND_ASSIGN(ScopedRankingsBlock); |
91 }; | 91 }; |
92 | 92 |
93 // If we have multiple lists, we have to iterate through all at the same time. | 93 // If we have multiple lists, we have to iterate through all at the same time. |
94 // This structure keeps track of where we are on the iteration. | 94 // This structure keeps track of where we are on the iteration. |
95 struct Iterator { | 95 struct Iterator { |
96 List list; // Which entry was returned to the user. | 96 List list; // Which entry was returned to the user. |
97 CacheRankingsBlock* nodes[3]; // Nodes on the first three lists. | 97 CacheRankingsBlock* nodes[3]; // Nodes on the first three lists. |
98 Rankings* my_rankings; | 98 Rankings* my_rankings; |
99 explicit Iterator(Rankings* rankings) { | 99 explicit Iterator(Rankings* rankings); |
100 memset(this, 0, sizeof(Iterator)); | 100 ~Iterator(); |
101 my_rankings = rankings; | |
102 } | |
103 ~Iterator() { | |
104 for (int i = 0; i < 3; i++) | |
105 ScopedRankingsBlock(my_rankings, nodes[i]); | |
106 } | |
107 }; | 101 }; |
108 | 102 |
109 Rankings() : init_(false) {} | 103 Rankings(); |
110 ~Rankings() {} | 104 ~Rankings(); |
111 | 105 |
112 bool Init(BackendImpl* backend, bool count_lists); | 106 bool Init(BackendImpl* backend, bool count_lists); |
113 | 107 |
114 // Restores original state, leaving the object ready for initialization. | 108 // Restores original state, leaving the object ready for initialization. |
115 void Reset(); | 109 void Reset(); |
116 | 110 |
117 // Inserts a given entry at the head of the queue. | 111 // Inserts a given entry at the head of the queue. |
118 void Insert(CacheRankingsBlock* node, bool modified, List list); | 112 void Insert(CacheRankingsBlock* node, bool modified, List list); |
119 | 113 |
120 // Removes a given entry from the LRU list. | 114 // Removes a given entry from the LRU list. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 BackendImpl* backend_; | 191 BackendImpl* backend_; |
198 LruData* control_data_; // Data related to the LRU lists. | 192 LruData* control_data_; // Data related to the LRU lists. |
199 IteratorList iterators_; | 193 IteratorList iterators_; |
200 | 194 |
201 DISALLOW_COPY_AND_ASSIGN(Rankings); | 195 DISALLOW_COPY_AND_ASSIGN(Rankings); |
202 }; | 196 }; |
203 | 197 |
204 } // namespace disk_cache | 198 } // namespace disk_cache |
205 | 199 |
206 #endif // NET_DISK_CACHE_RANKINGS_H_ | 200 #endif // NET_DISK_CACHE_RANKINGS_H_ |
OLD | NEW |