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

Side by Side Diff: net/disk_cache/blockfile/rankings.h

Issue 583293002: Do not leak when iterator outlives disk cache backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cacheenums-again
Patch Set: cleaner ownership Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 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_BLOCKFILE_RANKINGS_H_ 7 #ifndef NET_DISK_CACHE_BLOCKFILE_RANKINGS_H_
8 #define NET_DISK_CACHE_BLOCKFILE_RANKINGS_H_ 8 #define NET_DISK_CACHE_BLOCKFILE_RANKINGS_H_
9 9
10 #include <list> 10 #include <list>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 private: 89 private:
90 Rankings* rankings_; 90 Rankings* rankings_;
91 DISALLOW_COPY_AND_ASSIGN(ScopedRankingsBlock); 91 DISALLOW_COPY_AND_ASSIGN(ScopedRankingsBlock);
92 }; 92 };
93 93
94 // If we have multiple lists, we have to iterate through all at the same time. 94 // If we have multiple lists, we have to iterate through all at the same time.
95 // This structure keeps track of where we are on the iteration. 95 // This structure keeps track of where we are on the iteration.
96 struct Iterator { 96 struct Iterator {
97 explicit Iterator(Rankings* rankings); 97 Iterator();
98 ~Iterator(); 98 void Reset();
99 99
100 List list; // Which entry was returned to the user. 100 List list; // Which entry was returned to the user.
101 CacheRankingsBlock* nodes[3]; // Nodes on the first three lists. 101 CacheRankingsBlock* nodes[3]; // Nodes on the first three lists.
102 Rankings* my_rankings; 102 Rankings* my_rankings;
103 }; 103 };
104 104
105 Rankings(); 105 Rankings();
106 ~Rankings(); 106 ~Rankings();
107 107
108 bool Init(BackendImpl* backend, bool count_lists); 108 bool Init(BackendImpl* backend, bool count_lists);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 BackendImpl* backend_; 205 BackendImpl* backend_;
206 LruData* control_data_; // Data related to the LRU lists. 206 LruData* control_data_; // Data related to the LRU lists.
207 IteratorList iterators_; 207 IteratorList iterators_;
208 208
209 DISALLOW_COPY_AND_ASSIGN(Rankings); 209 DISALLOW_COPY_AND_ASSIGN(Rankings);
210 }; 210 };
211 211
212 } // namespace disk_cache 212 } // namespace disk_cache
213 213
214 #endif // NET_DISK_CACHE_BLOCKFILE_RANKINGS_H_ 214 #endif // NET_DISK_CACHE_BLOCKFILE_RANKINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698