summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/eviction.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-18 00:22:08 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-18 00:22:08 +0000
commitdf4825733e94311ffdefbbed6fecc93203886243 (patch)
tree5dd5fbe5a2d3163cff7752a5abf647bfcb2ffb0e /net/disk_cache/eviction.h
parent4364d3ed5abb7fc2788508cac79ecd8a8703289a (diff)
downloadchromium_src-df4825733e94311ffdefbbed6fecc93203886243.zip
chromium_src-df4825733e94311ffdefbbed6fecc93203886243.tar.gz
chromium_src-df4825733e94311ffdefbbed6fecc93203886243.tar.bz2
Disk cache: move eviction code to a separate file.
There should be no change in behavior with this CL. Review URL: http://codereview.chromium.org/14183 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/eviction.h')
-rw-r--r--net/disk_cache/eviction.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/net/disk_cache/eviction.h b/net/disk_cache/eviction.h
new file mode 100644
index 0000000..dd4e467
--- /dev/null
+++ b/net/disk_cache/eviction.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2006-2008 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_EVICTION_H_
+#define NET_DISK_CACHE_EVICTION_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/task.h"
+#include "net/disk_cache/disk_format.h"
+#include "net/disk_cache/rankings.h"
+
+namespace disk_cache {
+
+class BackendImpl;
+class EntryImpl;
+
+// This class implements the eviction algorithm for the cache and it is tightly
+// integrated with BackendImpl.
+class Eviction {
+ public:
+ Eviction() : backend_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
+ ~Eviction() {}
+
+ void Init(BackendImpl* backend);
+
+ // 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(bool empty);
+
+ // Updates the ranking information for an entry.
+ void UpdateRank(EntryImpl* entry, bool modified);
+
+ // Notifications of interesting events for a given entry.
+ void OnOpenEntry(EntryImpl* entry);
+ void OnCreateEntry(EntryImpl* entry);
+ void OnDoomEntry(EntryImpl* entry);
+ void OnDestroyEntry(EntryImpl* entry);
+
+ private:
+ void ReportTrimTimes(EntryImpl* entry);
+ Rankings::List GetListForEntry(EntryImpl* entry);
+
+ BackendImpl* backend_;
+ Rankings* rankings_;
+ IndexHeader* header_;
+ int max_size_;
+ ScopedRunnableMethodFactory<Eviction> factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(Eviction);
+};
+
+} // namespace disk_cache
+
+#endif // NET_DISK_CACHE_EVICTION_H_