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

Unified Diff: net/disk_cache/v3/eviction_v3.h

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/v3/entry_operation.cc ('k') | net/disk_cache/v3/eviction_v3.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « net/disk_cache/v3/entry_operation.cc ('k') | net/disk_cache/v3/eviction_v3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698