summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/entry_impl.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 20:05:34 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 20:05:34 +0000
commit90c7aa0fe476246b74608e564ea09f0d2a4951da (patch)
treed4d0c7114c09a537f3493efe866a1e6a7f74a944 /net/disk_cache/entry_impl.cc
parent6d1ef0ff8c7debfd17d00a2c2649f853231d50d8 (diff)
downloadchromium_src-90c7aa0fe476246b74608e564ea09f0d2a4951da.zip
chromium_src-90c7aa0fe476246b74608e564ea09f0d2a4951da.tar.gz
chromium_src-90c7aa0fe476246b74608e564ea09f0d2a4951da.tar.bz2
New disk cache eviction algorithm (partial implementation).
Disabled by a #def. When enabled, file format 2.1 is used, with a possible update from ver 2.0. If a version with this code disabled is run after the upgrade, it will just discard the file and go back to 2.0. We now put some of those extra list to use! Entries are separated into various lists depending on how often are used, and we keep track of previously evicted entries. If the new algorithm is not enabled, most of the code just goes through a different path (with the old code instead of the new one). One notable exception is OpenFollowingEntry, used to enumerate the entries on the cache; the code changed significantly to support the new version of the "cache iterator", but functionally should do the same as the current code. Review URL: http://codereview.chromium.org/27345 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r--net/disk_cache/entry_impl.cc55
1 files changed, 34 insertions, 21 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index 9db5647..361a7ee 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -92,27 +92,7 @@ EntryImpl::EntryImpl(BackendImpl* backend, Addr address)
// written before).
EntryImpl::~EntryImpl() {
if (doomed_) {
- UMA_HISTOGRAM_COUNTS("DiskCache.DeleteHeader", GetDataSize(0));
- UMA_HISTOGRAM_COUNTS("DiskCache.DeleteData", GetDataSize(1));
- for (int index = 0; index < NUM_STREAMS; index++) {
- Addr address(entry_.Data()->data_addr[index]);
- if (address.is_initialized()) {
- DeleteData(address, index);
- backend_->ModifyStorageSize(entry_.Data()->data_size[index] -
- unreported_size_[index], 0);
- }
- }
- Addr address(entry_.Data()->long_key);
- DeleteData(address, kKeyFileIndex);
- backend_->ModifyStorageSize(entry_.Data()->key_len, 0);
-
- memset(node_.buffer(), 0, node_.size());
- memset(entry_.buffer(), 0, entry_.size());
- node_.Store();
- entry_.Store();
-
- backend_->DeleteBlock(node_.address(), false);
- backend_->DeleteBlock(entry_.address(), false);
+ DeleteEntryData(true);
} else {
bool ret = true;
for (int index = 0; index < NUM_STREAMS; index++) {
@@ -474,6 +454,39 @@ void EntryImpl::InternalDoom() {
doomed_ = true;
}
+void EntryImpl::DeleteEntryData(bool everything) {
+ DCHECK(doomed_ || !everything);
+
+ UMA_HISTOGRAM_COUNTS("DiskCache.DeleteHeader", GetDataSize(0));
+ UMA_HISTOGRAM_COUNTS("DiskCache.DeleteData", GetDataSize(1));
+ for (int index = 0; index < NUM_STREAMS; index++) {
+ Addr address(entry_.Data()->data_addr[index]);
+ if (address.is_initialized()) {
+ DeleteData(address, index);
+ backend_->ModifyStorageSize(entry_.Data()->data_size[index] -
+ unreported_size_[index], 0);
+ }
+ }
+
+ if (!everything)
+ return;
+
+ // Remove all traces of this entry.
+ backend_->RemoveEntry(this);
+
+ Addr address(entry_.Data()->long_key);
+ DeleteData(address, kKeyFileIndex);
+ backend_->ModifyStorageSize(entry_.Data()->key_len, 0);
+
+ memset(node_.buffer(), 0, node_.size());
+ memset(entry_.buffer(), 0, entry_.size());
+ node_.Store();
+ entry_.Store();
+
+ backend_->DeleteBlock(node_.address(), false);
+ backend_->DeleteBlock(entry_.address(), false);
+}
+
CacheAddr EntryImpl::GetNextAddress() {
return entry_.Data()->next;
}