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

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

Issue 2127403002: Make browsing_data component a layered component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed output_name from components/browsing_data/content/BUILD.gn Created 4 years, 5 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_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_
6 #define COMPONENTS_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_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 // Counts the total size of entries that would be removed by calling |Remove|.
55 // Reports it via |result_callback| and then destroys itself.
56 void Count(const net::Int64CompletionCallback& result_callback);
57
58 private:
59 enum CacheState {
60 STATE_NONE,
61 STATE_CREATE_MAIN,
62 STATE_CREATE_MEDIA,
63 STATE_PROCESS_MAIN,
64 STATE_PROCESS_MEDIA,
65 STATE_DONE
66 };
67
68 StoragePartitionHttpCacheDataRemover(
69 base::Callback<bool(const GURL&)> url_predicate,
70 base::Time delete_begin,
71 base::Time delete_end,
72 net::URLRequestContextGetter* main_context_getter,
73 net::URLRequestContextGetter* media_context_getter);
74
75 // StoragePartitionHttpCacheDataRemover deletes itself (using DeleteHelper)
76 // and is not supposed to be deleted by other objects so make destructor
77 // private and DeleteHelper a friend.
78 friend class base::DeleteHelper<StoragePartitionHttpCacheDataRemover>;
79
80 ~StoragePartitionHttpCacheDataRemover();
81
82 void ClearHttpCacheOnIOThread();
83 void CountHttpCacheOnIOThread();
84
85 void ClearedHttpCache();
86 void CountedHttpCache();
87
88 // Performs the actual work to delete or count the cache.
89 void DoClearCache(int rv);
90 void DoCountCache(int rv);
91
92 base::Callback<bool(const GURL&)> url_predicate_;
93 const base::Time delete_begin_;
94 const base::Time delete_end_;
95
96 const scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
97 const scoped_refptr<net::URLRequestContextGetter> media_context_getter_;
98
99 base::Closure done_callback_;
100 net::Int64CompletionCallback result_callback_;
101
102 // IO.
103 int next_cache_state_;
104 disk_cache::Backend* cache_;
105
106 // Stores the cache size computation result before it can be returned
107 // via a callback. This is either the sum of size of the the two cache
108 // backends, or an error code if the calculation failed.
109 int64_t calculation_result_;
110
111 DISALLOW_COPY_AND_ASSIGN(StoragePartitionHttpCacheDataRemover);
112 };
113
114 } // namespace browsing_data
115
116 #endif // COMPONENTS_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_
OLDNEW
« no previous file with comments | « components/browsing_data/pref_names.cc ('k') | 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