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

Unified Diff: chrome/browser/browsing_data/storage_partition_http_cache_data_remover.h

Issue 1033013003: Refactor http cache removing from a StoragePartition into separate class: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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: chrome/browser/browsing_data/storage_partition_http_cache_data_remover.h
diff --git a/chrome/browser/browsing_data/storage_partition_http_cache_data_remover.h b/chrome/browser/browsing_data/storage_partition_http_cache_data_remover.h
new file mode 100644
index 0000000000000000000000000000000000000000..b09e31ef6f46187dffcd6dcd6829469e144b4995
--- /dev/null
+++ b/chrome/browser/browsing_data/storage_partition_http_cache_data_remover.h
@@ -0,0 +1,78 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_
+#define CHROME_BROWSER_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_
+
+#include "base/callback.h"
+#include "base/sequenced_task_runner_helpers.h"
+#include "base/time/time.h"
+
+namespace content {
+class StoragePartition;
+}
+
+namespace disk_cache {
+class Backend;
+}
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+// Helper to remove http cache data from a StoragePartition.
+class StoragePartitionHttpCacheDataRemover {
+ public:
+ static StoragePartitionHttpCacheDataRemover* CreateForRange(
+ content::StoragePartition* storage_partition,
+ base::Time delete_begin,
+ base::Time delete_end);
+
+ // Calls |done_callback| upon completion and also destroys itself.
+ void Remove(const base::Closure& done_callback);
+
+ private:
+ enum CacheState {
+ STATE_NONE,
+ STATE_CREATE_MAIN,
+ STATE_CREATE_MEDIA,
+ STATE_DELETE_MAIN,
+ STATE_DELETE_MEDIA,
+ STATE_DONE
+ };
+
+ StoragePartitionHttpCacheDataRemover(
+ base::Time delete_begin,
+ base::Time delete_end,
+ net::URLRequestContextGetter* main_context_getter,
+ net::URLRequestContextGetter* media_context_getter);
+
+ // StoragePartitionHttpCacheDataRemover deletes itself (using DeleteHelper)
+ // and is not supposed to be deleted by other objects so make destructor
+ // private and DeleteHelper a friend.
+ friend class base::DeleteHelper<StoragePartitionHttpCacheDataRemover>;
+
+ ~StoragePartitionHttpCacheDataRemover();
+
+ void ClearHttpCacheOnIOThread();
+ void ClearedHttpCache();
+ // Performs the actual work to delete the cache.
+ void DoClearCache(int rv);
+
+ const base::Time delete_begin_;
+ const base::Time delete_end_;
+
+ const scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
+ const scoped_refptr<net::URLRequestContextGetter> media_context_getter_;
+
+ base::Closure done_callback_;
+
+ // IO.
+ int next_cache_state_;
+ disk_cache::Backend* cache_;
+
+ DISALLOW_COPY_AND_ASSIGN(StoragePartitionHttpCacheDataRemover);
+};
+
+#endif // CHROME_BROWSER_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_

Powered by Google App Engine
This is Rietveld 408576698