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

Unified Diff: components/browsing_data/storage_partition_http_cache_data_remover.h

Issue 1304363013: Add a size estimation mechanism to StoragePartitionHttpCacheDataRemover. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: static_cast Created 5 years, 2 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 | « no previous file | components/browsing_data/storage_partition_http_cache_data_remover.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/browsing_data/storage_partition_http_cache_data_remover.h
diff --git a/components/browsing_data/storage_partition_http_cache_data_remover.h b/components/browsing_data/storage_partition_http_cache_data_remover.h
index eb9f575fae82478e918e5dd139d979ad09137f6b..40143e3b5abf75c40a3ba562c6e1a45e26012de9 100644
--- a/components/browsing_data/storage_partition_http_cache_data_remover.h
+++ b/components/browsing_data/storage_partition_http_cache_data_remover.h
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/time/time.h"
+#include "net/base/completion_callback.h"
namespace content {
class StoragePartition;
@@ -34,13 +35,17 @@ class StoragePartitionHttpCacheDataRemover {
// Calls |done_callback| upon completion and also destroys itself.
void Remove(const base::Closure& done_callback);
+ // Counts the total size of entries that would be removed by calling |Remove|.
+ // Reports it via |result_callback| and then destroys itself.
+ void Count(const net::Int64CompletionCallback& result_callback);
+
private:
enum CacheState {
STATE_NONE,
STATE_CREATE_MAIN,
STATE_CREATE_MEDIA,
- STATE_DELETE_MAIN,
- STATE_DELETE_MEDIA,
+ STATE_PROCESS_MAIN,
+ STATE_PROCESS_MEDIA,
STATE_DONE
};
@@ -58,9 +63,14 @@ class StoragePartitionHttpCacheDataRemover {
~StoragePartitionHttpCacheDataRemover();
void ClearHttpCacheOnIOThread();
+ void CountHttpCacheOnIOThread();
+
void ClearedHttpCache();
- // Performs the actual work to delete the cache.
+ void CountedHttpCache();
+
+ // Performs the actual work to delete or count the cache.
void DoClearCache(int rv);
+ void DoCountCache(int rv);
const base::Time delete_begin_;
const base::Time delete_end_;
@@ -69,11 +79,17 @@ class StoragePartitionHttpCacheDataRemover {
const scoped_refptr<net::URLRequestContextGetter> media_context_getter_;
base::Closure done_callback_;
+ net::Int64CompletionCallback result_callback_;
// IO.
int next_cache_state_;
disk_cache::Backend* cache_;
+ // Stores the cache size computation result before it can be returned
+ // via a callback. This is either the sum of size of the the two cache
+ // backends, or an error code if the calculation failed.
+ int64 calculation_result_;
+
DISALLOW_COPY_AND_ASSIGN(StoragePartitionHttpCacheDataRemover);
};
« no previous file with comments | « no previous file | components/browsing_data/storage_partition_http_cache_data_remover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698