OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
11 #include <set> | 11 #include <set> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
17 #include "base/synchronization/waitable_event_watcher.h" | 18 #include "base/synchronization/waitable_event_watcher.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 21 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
21 #include "chrome/common/features.h" | 22 #include "chrome/common/features.h" |
22 #include "ppapi/features/features.h" | 23 #include "ppapi/features/features.h" |
23 #include "storage/common/quota/quota_types.h" | 24 #include "storage/common/quota/quota_types.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 ~RemovalTask(); | 166 ~RemovalTask(); |
166 | 167 |
167 base::Time delete_begin; | 168 base::Time delete_begin; |
168 base::Time delete_end; | 169 base::Time delete_end; |
169 int remove_mask; | 170 int remove_mask; |
170 int origin_type_mask; | 171 int origin_type_mask; |
171 std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder; | 172 std::unique_ptr<content::BrowsingDataFilterBuilder> filter_builder; |
172 Observer* observer; | 173 Observer* observer; |
173 }; | 174 }; |
174 | 175 |
176 // OriginMaskAndURLMatcher handles the implementation of DoesOriginMatchMask. | |
177 // As an intrinsic part of BrowsingDataRemoverImpl, it should be destroyed | |
178 // together with it on the UI thread. However, it is possible that at this | |
179 // time a StoragePartition is still using it on the IO thread. Therefore, | |
180 // we hold it ref-counted. | |
181 class OriginMaskAndURLMatcher | |
182 : public base::RefCountedThreadSafe<OriginMaskAndURLMatcher> { | |
183 public: | |
184 using MaskMatcherFunction = | |
185 BrowsingDataRemoverDelegate::MaskMatcherFunction; | |
186 | |
187 OriginMaskAndURLMatcher(); | |
188 | |
189 // Returns whether |origin| matches |origin_type_mask| given the special | |
190 // storage |policy|; and if |predicate| is not null, then also whether | |
191 // it matches |predicate|. | |
192 bool DoesOriginMatchMaskAndURLs( | |
193 int origin_type_mask, | |
194 const base::Callback<bool(const GURL&)>& predicate, | |
195 const GURL& origin, | |
196 storage::SpecialStoragePolicy* policy) const; | |
197 | |
198 // Called from BrowsingDataRemoverImpl::SetEmbedderDelegate to inject | |
199 // the matching function for embedder datatypes. | |
200 void set_embedder_matcher(const MaskMatcherFunction& embedder_matcher) { | |
201 embedder_matcher_ = embedder_matcher; | |
202 } | |
203 | |
204 private: | |
205 friend class base::RefCountedThreadSafe<OriginMaskAndURLMatcher>; | |
206 ~OriginMaskAndURLMatcher(); | |
207 | |
208 MaskMatcherFunction embedder_matcher_; | |
Bernhard Bauer
2017/03/30 10:49:26
If this is the only state in the class, and it's a
msramek
2017/04/06 12:06:38
Because I panicked and overengineered it. Done.
| |
209 }; | |
210 | |
175 void Shutdown() override; | 211 void Shutdown() override; |
176 | 212 |
177 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're | 213 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're |
178 // not already removing, and vice-versa. | 214 // not already removing, and vice-versa. |
179 void SetRemoving(bool is_removing); | 215 void SetRemoving(bool is_removing); |
180 | 216 |
181 // Executes the next removal task. Called after the previous task was finished | 217 // Executes the next removal task. Called after the previous task was finished |
182 // or directly from Remove() if the task queue was empty. | 218 // or directly from Remove() if the task queue was empty. |
183 void RunNextTask(); | 219 void RunNextTask(); |
184 | 220 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 SubTask clear_channel_ids_; | 281 SubTask clear_channel_ids_; |
246 SubTask clear_http_auth_cache_; | 282 SubTask clear_http_auth_cache_; |
247 SubTask clear_storage_partition_data_; | 283 SubTask clear_storage_partition_data_; |
248 | 284 |
249 // Observers of the global state and individual tasks. | 285 // Observers of the global state and individual tasks. |
250 base::ObserverList<Observer, true> observer_list_; | 286 base::ObserverList<Observer, true> observer_list_; |
251 | 287 |
252 // We do not own this. | 288 // We do not own this. |
253 content::StoragePartition* storage_partition_for_testing_ = nullptr; | 289 content::StoragePartition* storage_partition_for_testing_ = nullptr; |
254 | 290 |
291 // Handles the implementation of DoesOriginMatchMask(). Used on the UI and IO | |
292 // threads. | |
293 scoped_refptr<OriginMaskAndURLMatcher> origin_mask_and_url_matcher_; | |
294 | |
255 base::WeakPtrFactory<BrowsingDataRemoverImpl> weak_ptr_factory_; | 295 base::WeakPtrFactory<BrowsingDataRemoverImpl> weak_ptr_factory_; |
256 | 296 |
257 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverImpl); | 297 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverImpl); |
258 }; | 298 }; |
259 | 299 |
260 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_ | 300 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_IMPL_H_ |
OLD | NEW |