OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_DISK_CACHE_EVICTION_H_ |
| 6 #define NET_DISK_CACHE_EVICTION_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/task.h" |
| 11 #include "net/disk_cache/disk_format.h" |
| 12 #include "net/disk_cache/rankings.h" |
| 13 |
| 14 namespace disk_cache { |
| 15 |
| 16 class BackendImpl; |
| 17 class EntryImpl; |
| 18 |
| 19 // This class implements the eviction algorithm for the cache and it is tightly |
| 20 // integrated with BackendImpl. |
| 21 class Eviction { |
| 22 public: |
| 23 Eviction() : backend_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {} |
| 24 ~Eviction() {} |
| 25 |
| 26 void Init(BackendImpl* backend); |
| 27 |
| 28 // Deletes entries from the cache until the current size is below the limit. |
| 29 // If empty is true, the whole cache will be trimmed, regardless of being in |
| 30 // use. |
| 31 void TrimCache(bool empty); |
| 32 |
| 33 // Updates the ranking information for an entry. |
| 34 void UpdateRank(EntryImpl* entry, bool modified); |
| 35 |
| 36 // Notifications of interesting events for a given entry. |
| 37 void OnOpenEntry(EntryImpl* entry); |
| 38 void OnCreateEntry(EntryImpl* entry); |
| 39 void OnDoomEntry(EntryImpl* entry); |
| 40 void OnDestroyEntry(EntryImpl* entry); |
| 41 |
| 42 private: |
| 43 void ReportTrimTimes(EntryImpl* entry); |
| 44 Rankings::List GetListForEntry(EntryImpl* entry); |
| 45 |
| 46 BackendImpl* backend_; |
| 47 Rankings* rankings_; |
| 48 IndexHeader* header_; |
| 49 int max_size_; |
| 50 ScopedRunnableMethodFactory<Eviction> factory_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(Eviction); |
| 53 }; |
| 54 |
| 55 } // namespace disk_cache |
| 56 |
| 57 #endif // NET_DISK_CACHE_EVICTION_H_ |
OLD | NEW |