OLD | NEW |
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_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 RESERVED, // Reserved for future use. | 57 RESERVED, // Reserved for future use. |
58 DELETED, // List of recently deleted or doomed entries. | 58 DELETED, // List of recently deleted or doomed entries. |
59 LAST_ELEMENT | 59 LAST_ELEMENT |
60 }; | 60 }; |
61 | 61 |
62 // This class provides a specialized version of scoped_ptr, that calls | 62 // This class provides a specialized version of scoped_ptr, that calls |
63 // Rankings whenever a CacheRankingsBlock is deleted, to keep track of cache | 63 // Rankings whenever a CacheRankingsBlock is deleted, to keep track of cache |
64 // iterators that may go stale. | 64 // iterators that may go stale. |
65 class ScopedRankingsBlock : public scoped_ptr<CacheRankingsBlock> { | 65 class ScopedRankingsBlock : public scoped_ptr<CacheRankingsBlock> { |
66 public: | 66 public: |
67 ScopedRankingsBlock() : rankings_(NULL) {} | 67 ScopedRankingsBlock(); |
68 explicit ScopedRankingsBlock(Rankings* rankings) : rankings_(rankings) {} | 68 explicit ScopedRankingsBlock(Rankings* rankings); |
69 ScopedRankingsBlock(Rankings* rankings, CacheRankingsBlock* node) | 69 ScopedRankingsBlock(Rankings* rankings, CacheRankingsBlock* node); |
70 : scoped_ptr<CacheRankingsBlock>(node), rankings_(rankings) {} | |
71 | 70 |
72 ~ScopedRankingsBlock() { | 71 ~ScopedRankingsBlock() { |
73 rankings_->FreeRankingsBlock(get()); | 72 rankings_->FreeRankingsBlock(get()); |
74 } | 73 } |
75 | 74 |
76 void set_rankings(Rankings* rankings) { | 75 void set_rankings(Rankings* rankings) { |
77 rankings_ = rankings; | 76 rankings_ = rankings; |
78 } | 77 } |
79 | 78 |
80 // scoped_ptr::reset will delete the object. | 79 // scoped_ptr::reset will delete the object. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 BackendImpl* backend_; | 206 BackendImpl* backend_; |
208 LruData* control_data_; // Data related to the LRU lists. | 207 LruData* control_data_; // Data related to the LRU lists. |
209 IteratorList iterators_; | 208 IteratorList iterators_; |
210 | 209 |
211 DISALLOW_COPY_AND_ASSIGN(Rankings); | 210 DISALLOW_COPY_AND_ASSIGN(Rankings); |
212 }; | 211 }; |
213 | 212 |
214 } // namespace disk_cache | 213 } // namespace disk_cache |
215 | 214 |
216 #endif // NET_DISK_CACHE_RANKINGS_H_ | 215 #endif // NET_DISK_CACHE_RANKINGS_H_ |
OLD | NEW |