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

Unified Diff: net/disk_cache/blockfile/backend_impl.cc

Issue 1304363013: Add a size estimation mechanism to StoragePartitionHttpCacheDataRemover. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support null max time. Created 5 years, 3 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/blockfile/backend_impl.cc
diff --git a/net/disk_cache/blockfile/backend_impl.cc b/net/disk_cache/blockfile/backend_impl.cc
index 50e7b026a83e4b199a3c893f0eae18655e1f5912..a7d8b8d7c311f25e020b839b74ca33a3bcdd683c 100644
--- a/net/disk_cache/blockfile/backend_impl.cc
+++ b/net/disk_cache/blockfile/backend_impl.cc
@@ -436,6 +436,46 @@ int BackendImpl::SyncDoomEntriesSince(const base::Time initial_time) {
}
}
+int BackendImpl::SyncCalculateSizeOfEntriesBetween(
+ const base::Time initial_time, const base::Time end_time) {
+ DCHECK_NE(net::APP_CACHE, cache_type_);
+ if (disabled_)
+ return net::ERR_FAILED;
+
+ if (initial_time.is_null() && end_time.is_null())
+ return data_->header.num_bytes;
+
+ const base::Time effective_end_time =
+ end_time.is_null() ? base::Time::Max() : end_time;
+ DCHECK_GE(effective_end_time, initial_time);
+
+ EntryImpl* node;
+ scoped_ptr<Rankings::Iterator> iterator(new Rankings::Iterator());
+ EntryImpl* next = OpenNextEntryImpl(iterator.get());
+ if (!next)
+ return net::OK;
rvargas (doing something else) 2015/09/12 00:13:02 nit: This would be 0 (a size).
msramek 2015/09/15 11:42:36 Done.
+
+ int size = 0;
+ while (next) {
+ node = next;
+ next = OpenNextEntryImpl(iterator.get());
+
+ if (node->GetLastUsed() >= initial_time &&
+ node->GetLastUsed() < effective_end_time) {
+ size += node->GetEntrySize();
+ } else if (node->GetLastUsed() < initial_time) {
+ if (next)
+ next->Release();
+ next = NULL;
+ SyncEndEnumeration(iterator.Pass());
+ }
+
+ node->Release();
+ }
+
+ return size;
+}
+
int BackendImpl::SyncOpenNextEntry(Rankings::Iterator* iterator,
Entry** next_entry) {
*next_entry = OpenNextEntryImpl(iterator);
@@ -1254,6 +1294,16 @@ int BackendImpl::DoomEntriesSince(const base::Time initial_time,
return net::ERR_IO_PENDING;
}
+int BackendImpl::CalculateSizeOfEntriesBetween(
+ base::Time initial_time,
+ base::Time end_time,
+ const CompletionCallback& callback) {
+ DCHECK(!callback.is_null());
+ background_queue_.CalculateSizeOfEntriesBetween(
+ initial_time, end_time, callback);
+ return net::ERR_IO_PENDING;
+}
+
class BackendImpl::IteratorImpl : public Backend::Iterator {
public:
explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue)

Powered by Google App Engine
This is Rietveld 408576698