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

Side by Side Diff: components/browsing_data/content/storage_partition_http_cache_data_remover.h

Issue 2757923002: Move StoragePartitionHttpCacheDataRemover to content/ (Closed)
Patch Set: Rebase. Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_BROWSING_DATA_CONTENT_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOV ER_H_
6 #define COMPONENTS_BROWSING_DATA_CONTENT_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOV ER_H_
7
8 #include <stdint.h>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/sequenced_task_runner_helpers.h"
13 #include "base/time/time.h"
14 #include "net/base/completion_callback.h"
15 #include "url/gurl.h"
16
17 namespace content {
18 class StoragePartition;
19 }
20
21 namespace disk_cache {
22 class Backend;
23 }
24
25 namespace net {
26 class URLRequestContextGetter;
27 }
28
29 namespace browsing_data {
30
31 // Helper to remove http cache data from a StoragePartition.
32 class StoragePartitionHttpCacheDataRemover {
33 public:
34 // Creates a StoragePartitionHttpCacheDataRemover that deletes cache entries
35 // in the time range between |delete_begin| (inclusively) and |delete_end|
36 // (exclusively).
37 static StoragePartitionHttpCacheDataRemover* CreateForRange(
38 content::StoragePartition* storage_partition,
39 base::Time delete_begin,
40 base::Time delete_end);
41
42 // Similar to CreateForRange(), but only deletes URLs that are matched by
43 // |url_predicate|. Note that the deletion with URL filtering is not built in
44 // to the cache interface and might be slower.
45 static StoragePartitionHttpCacheDataRemover* CreateForURLsAndRange(
46 content::StoragePartition* storage_partition,
47 const base::Callback<bool(const GURL&)>& url_predicate,
48 base::Time delete_begin,
49 base::Time delete_end);
50
51 // Calls |done_callback| upon completion and also destroys itself.
52 void Remove(const base::Closure& done_callback);
53
54 private:
55 enum CacheState {
56 NONE,
57 CREATE_MAIN,
58 CREATE_MEDIA,
59 DELETE_MAIN,
60 DELETE_MEDIA,
61 DONE
62 };
63
64 StoragePartitionHttpCacheDataRemover(
65 base::Callback<bool(const GURL&)> url_predicate,
66 base::Time delete_begin,
67 base::Time delete_end,
68 net::URLRequestContextGetter* main_context_getter,
69 net::URLRequestContextGetter* media_context_getter);
70
71 // StoragePartitionHttpCacheDataRemover deletes itself (using DeleteHelper)
72 // and is not supposed to be deleted by other objects so make destructor
73 // private and DeleteHelper a friend.
74 friend class base::DeleteHelper<StoragePartitionHttpCacheDataRemover>;
75
76 ~StoragePartitionHttpCacheDataRemover();
77
78 void ClearHttpCacheOnIOThread();
79 void ClearedHttpCache();
80 // Performs the actual work to delete or count the cache.
81 void DoClearCache(int rv);
82
83 base::Callback<bool(const GURL&)> url_predicate_;
84 const base::Time delete_begin_;
85 const base::Time delete_end_;
86
87 const scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
88 const scoped_refptr<net::URLRequestContextGetter> media_context_getter_;
89
90 base::Closure done_callback_;
91
92 // IO.
93 int next_cache_state_;
94 disk_cache::Backend* cache_;
95
96 DISALLOW_COPY_AND_ASSIGN(StoragePartitionHttpCacheDataRemover);
97 };
98
99 } // namespace browsing_data
100
101 #endif // COMPONENTS_BROWSING_DATA_CONTENT_STORAGE_PARTITION_HTTP_CACHE_DATA_RE MOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698