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

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: revert cache_storage_cache_unittest.cc 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
« no previous file with comments | « net/disk_cache/memory/mem_backend_impl.h ('k') | net/disk_cache/simple/simple_backend_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7ded277b2a6eac201ef6bbac4cf5598cd232587c 100644
--- a/net/disk_cache/memory/mem_backend_impl.cc
+++ b/net/disk_cache/memory/mem_backend_impl.cc
@@ -181,7 +181,6 @@ int MemBackendImpl::DoomEntriesBetween(Time initial_time,
const CompletionCallback& callback) {
if (end_time.is_null())
end_time = Time::Max();
-
DCHECK_GE(end_time, initial_time);
base::LinkNode<MemEntryImpl>* node = lru_list_.head();
@@ -206,6 +205,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();
+ 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)
« no previous file with comments | « net/disk_cache/memory/mem_backend_impl.h ('k') | net/disk_cache/simple/simple_backend_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698