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

Unified Diff: net/disk_cache/memory/mem_backend_impl.cc

Issue 2626173003: Calculate the size of all cache entries between two points in time. (Closed)
Patch Set: fix unit_tests compilation Created 3 years, 11 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
Index: net/disk_cache/memory/mem_backend_impl.cc
diff --git a/net/disk_cache/memory/mem_backend_impl.cc b/net/disk_cache/memory/mem_backend_impl.cc
index ad9dfedcfab21bc0f7781a98f2bf181efd64534d..52074198ce74303137fe6d7a11fce09db2f4994e 100644
--- a/net/disk_cache/memory/mem_backend_impl.cc
+++ b/net/disk_cache/memory/mem_backend_impl.cc
@@ -206,6 +206,26 @@ int MemBackendImpl::CalculateSizeOfAllEntries(
return current_size_;
}
+int MemBackendImpl::CalculateSizeOfEntriesBetween(
+ base::Time initial_time,
+ base::Time end_time,
+ const CompletionCallback& callback) {
+ if (end_time.is_null())
+ end_time = Time::Max();
gavinp 2017/01/12 16:07:36 If you're going to cut and paste from DoomEntriesB
dullweber 2017/01/12 17:03:15 Done.
+ DCHECK_GE(end_time, initial_time);
+
+ int size = 0;
+ base::LinkNode<MemEntryImpl>* node = lru_list_.head();
+ while (node != lru_list_.end() && node->value()->GetLastUsed() < initial_time)
+ node = node->next();
+ while (node != lru_list_.end() && node->value()->GetLastUsed() < end_time) {
+ MemEntryImpl* entry = node->value();
+ size += entry->GetStorageSize();
+ node = node->next();
+ }
+ return size;
+}
+
class MemBackendImpl::MemIterator final : public Backend::Iterator {
public:
explicit MemIterator(base::WeakPtr<MemBackendImpl> backend)

Powered by Google App Engine
This is Rietveld 408576698