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

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: Created 5 years, 4 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..730326da9906916382d77197b719f33bf8d9155a 100644
--- a/net/disk_cache/blockfile/backend_impl.cc
+++ b/net/disk_cache/blockfile/backend_impl.cc
@@ -436,6 +436,39 @@ 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;
+
+ EntryImpl* node;
+ scoped_ptr<Rankings::Iterator> iterator(new Rankings::Iterator());
+ EntryImpl* next = OpenNextEntryImpl(iterator.get());
+ if (!next)
+ return net::OK;
+
+ int size = 0;
+ while (next) {
+ node = next;
+ next = OpenNextEntryImpl(iterator.get());
+
+ if (node->GetLastUsed() >= initial_time &&
+ node->GetLastUsed() < end_time) {
+ node->DoomImpl();
msramek 2015/09/02 19:22:25 ...and since this method imitates SyncDoomEntriesB
+ } else if (node->GetLastUsed() < initial_time) {
+ if (next)
+ next->Release();
+ next = NULL;
+ SyncEndEnumeration(iterator.Pass());
+ }
+
+ size += node->GetEntrySize();
+ }
+
+ return size;
+}
+
int BackendImpl::SyncOpenNextEntry(Rankings::Iterator* iterator,
Entry** next_entry) {
*next_entry = OpenNextEntryImpl(iterator);
@@ -1254,6 +1287,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