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 #ifndef NET_DISK_CACHE_EVICTION_H_ | 5 #ifndef NET_DISK_CACHE_EVICTION_H_ |
6 #define NET_DISK_CACHE_EVICTION_H_ | 6 #define NET_DISK_CACHE_EVICTION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "net/disk_cache/disk_format.h" | 10 #include "net/disk_cache/disk_format.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 ~Eviction(); | 23 ~Eviction(); |
24 | 24 |
25 void Init(BackendImpl* backend); | 25 void Init(BackendImpl* backend); |
26 void Stop(); | 26 void Stop(); |
27 | 27 |
28 // Deletes entries from the cache until the current size is below the limit. | 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 | 29 // If empty is true, the whole cache will be trimmed, regardless of being in |
30 // use. | 30 // use. |
31 void TrimCache(bool empty); | 31 void TrimCache(bool empty); |
32 | 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. | 33 // Notifications of interesting events for a given entry. |
37 void OnOpenEntry(EntryImpl* entry); | 34 void OnOpenEntry(EntryImpl* entry); |
38 void OnCreateEntry(EntryImpl* entry); | 35 void OnCreateEntry(EntryImpl* entry); |
39 void OnDoomEntry(EntryImpl* entry); | |
40 void OnDestroyEntry(EntryImpl* entry); | |
41 | 36 |
42 // Testing interface. | 37 // Testing interface. |
43 void SetTestMode(); | 38 void SetTestMode(); |
44 void TrimDeletedList(bool empty); | 39 void TrimDeletedList(bool empty); |
45 | 40 |
46 private: | 41 private: |
47 void PostDelayedTrim(); | 42 void PostDelayedTrim(); |
48 void DelayedTrim(); | 43 void DelayedTrim(); |
49 bool ShouldTrim(); | 44 bool ShouldTrim(); |
50 bool ShouldTrimDeleted(); | 45 bool ShouldTrimDeleted(); |
51 void ReportTrimTimes(EntryImpl* entry); | |
52 Rankings::List GetListForEntry(EntryImpl* entry); | |
53 bool EvictEntry(CacheRankingsBlock* node, bool empty, Rankings::List list); | 46 bool EvictEntry(CacheRankingsBlock* node, bool empty, Rankings::List list); |
54 | 47 |
55 // We'll just keep for a while a separate set of methods that implement the | |
56 // new eviction algorithm. This code will replace the original methods when | |
57 // finished. | |
58 void TrimCacheV2(bool empty); | 48 void TrimCacheV2(bool empty); |
59 void UpdateRankV2(EntryImpl* entry, bool modified); | |
60 void OnOpenEntryV2(EntryImpl* entry); | |
61 void OnCreateEntryV2(EntryImpl* entry); | |
62 void OnDoomEntryV2(EntryImpl* entry); | |
63 void OnDestroyEntryV2(EntryImpl* entry); | |
64 Rankings::List GetListForEntryV2(EntryImpl* entry); | |
65 void TrimDeleted(bool empty); | 49 void TrimDeleted(bool empty); |
66 bool RemoveDeletedNode(CacheRankingsBlock* node); | |
67 | 50 |
68 bool NodeIsOldEnough(CacheRankingsBlock* node, int list); | 51 bool NodeIsOldEnough(CacheRankingsBlock* node, int list); |
69 int SelectListByLength(Rankings::ScopedRankingsBlock* next); | 52 int SelectListByLength(Rankings::ScopedRankingsBlock* next); |
70 void ReportListStats(); | 53 void ReportListStats(); |
71 | 54 |
72 BackendImpl* backend_; | 55 BackendImpl* backend_; |
73 Rankings* rankings_; | 56 Rankings* rankings_; |
74 IndexHeader* header_; | 57 IndexHeader* header_; |
75 int max_size_; | 58 int max_size_; |
76 int trim_delays_; | 59 int trim_delays_; |
77 int index_size_; | 60 int index_size_; |
78 bool new_eviction_; | 61 bool new_eviction_; |
79 bool first_trim_; | 62 bool first_trim_; |
80 bool trimming_; | 63 bool trimming_; |
81 bool delay_trim_; | 64 bool delay_trim_; |
82 bool init_; | 65 bool init_; |
83 bool test_mode_; | 66 bool test_mode_; |
84 base::WeakPtrFactory<Eviction> ptr_factory_; | 67 base::WeakPtrFactory<Eviction> ptr_factory_; |
85 | 68 |
86 DISALLOW_COPY_AND_ASSIGN(Eviction); | 69 DISALLOW_COPY_AND_ASSIGN(Eviction); |
87 }; | 70 }; |
88 | 71 |
89 } // namespace disk_cache | 72 } // namespace disk_cache |
90 | 73 |
91 #endif // NET_DISK_CACHE_EVICTION_H_ | 74 #endif // NET_DISK_CACHE_EVICTION_H_ |
OLD | NEW |