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

Unified Diff: net/disk_cache/rankings.cc

Issue 27345: New disk cache eviction algorithm. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months 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/rankings.h ('k') | net/disk_cache/stats.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/rankings.cc
===================================================================
--- net/disk_cache/rankings.cc (revision 11078)
+++ net/disk_cache/rankings.cc (working copy)
@@ -174,14 +174,14 @@
namespace disk_cache {
-bool Rankings::Init(BackendImpl* backend) {
+bool Rankings::Init(BackendImpl* backend, bool count_lists) {
DCHECK(!init_);
if (init_)
return false;
backend_ = backend;
-
control_data_ = backend_->GetLruData();
+ count_lists_ = count_lists;
ReadHeads();
ReadTails();
@@ -281,6 +281,7 @@
// The last thing to do is move our head to point to a node already stored.
WriteHead(list);
+ IncrementCounter(list);
GenerateCrash(ON_INSERT_4);
}
@@ -377,6 +378,7 @@
prev.Store();
GenerateCrash(ON_REMOVE_8);
node->Store();
+ DecrementCounter(list);
UpdateIterators(&next);
UpdateIterators(&prev);
}
@@ -747,4 +749,22 @@
}
}
+void Rankings::IncrementCounter(List list) {
+ if (!count_lists_)
+ return;
+
+ DCHECK(control_data_->sizes[list] < kint32max);
+ if (control_data_->sizes[list] < kint32max)
+ control_data_->sizes[list]++;
+}
+
+void Rankings::DecrementCounter(List list) {
+ if (!count_lists_)
+ return;
+
+ DCHECK(control_data_->sizes[list] > 0);
+ if (control_data_->sizes[list] > 0)
+ control_data_->sizes[list]--;
+}
+
} // namespace disk_cache
« no previous file with comments | « net/disk_cache/rankings.h ('k') | net/disk_cache/stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698