Index: net/disk_cache/v3/eviction_v3.h |
=================================================================== |
--- net/disk_cache/v3/eviction_v3.h (revision 0) |
+++ net/disk_cache/v3/eviction_v3.h (revision 0) |
@@ -0,0 +1,86 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_DISK_CACHE_V3_EVICTION_V3_H_ |
+#define NET_DISK_CACHE_V3_EVICTION_V3_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/weak_ptr.h" |
+#include "net/base/completion_callback.h" |
+#include "net/disk_cache/v3/disk_format_v3.h" |
+#include "net/disk_cache/v3/index_table.h" |
+ |
+namespace disk_cache { |
+ |
+class BackendImplV3; |
+class EntryImplV3; |
+ |
+// This class implements the eviction algorithm for the cache and it is tightly |
+// integrated with BackendImpl. |
+class EvictionV3 { |
+ public: |
+ EvictionV3(); |
+ ~EvictionV3(); |
+ |
+ void Init(BackendImplV3* backend); |
+ void Stop(); |
+ |
+ // Deletes entries from the cache until the current size is below the limit. |
+ // If empty is true, the whole cache will be trimmed, regardless of being in |
+ // use. |
+ void TrimCache(); |
+ int TrimAllCache(const net::CompletionCallback& callback); |
+ |
+ // Notifications of interesting events for a given entry. |
+ void OnOpenEntry(EntryImplV3* entry); |
+ void OnCreateEntry(EntryImplV3* entry); |
+ void OnResurrectEntry(EntryImplV3* entry); |
+ void OnEvictEntryComplete(); |
+ |
+ // Testing interface. |
+ void SetTestMode(); |
+ void TrimDeletedList(bool empty); |
+ |
+ private: |
+ void PostDelayedTrim(); |
+ void DelayedTrim(); |
+ bool ShouldTrim(); |
+ bool ShouldTrimDeleted(); |
+ int EvictEntry(uint32 hash, Addr address); |
+ |
+ // Returns false when done trimming the cache. |
+ bool TrimCacheImpl(); |
+ void TrimDeleted(bool empty); |
+ |
+ bool EvictionV3::CellIsOldEnough(const IndexIterator& iterator, |
+ int multiplier); |
+ EntryGroup SelectListByLength(); |
+ void ReportListStats(int time1, int time2, int time3); |
+ |
+ BackendImplV3* backend_; |
+ IndexTable* index_; |
+ IndexHeaderV3* header_; |
+ int max_size_; |
+ int trim_delays_; |
+ int index_size_; |
+ bool lru_; |
+ bool first_trim_; |
+ bool trimming_; |
+ bool delay_trim_; |
+ bool init_; |
+ bool test_mode_; |
+ bool empty_; |
+ base::WeakPtrFactory<EvictionV3> ptr_factory_; |
+ IndexIterator no_use_cells_; |
+ IndexIterator low_use_cells_; |
+ IndexIterator high_use_cells_; |
+ IndexIterator* cells_to_evict_; |
+ net::CompletionCallback callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(EvictionV3); |
+}; |
+ |
+} // namespace disk_cache |
+ |
+#endif // NET_DISK_CACHE_V3_EVICTION_V3_H_ |
Property changes on: net\disk_cache\v3\eviction_v3.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |