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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.h

Issue 37843003: BrowsingDataRemover, (re)use StoragePartition deletion code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase @tott. Created 7 years, 1 month 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
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_H_ 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 11 matching lines...) Expand all
22 #endif 22 #endif
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 #include "webkit/common/quota/quota_types.h" 24 #include "webkit/common/quota/quota_types.h"
25 25
26 class ExtensionSpecialStoragePolicy; 26 class ExtensionSpecialStoragePolicy;
27 class IOThread; 27 class IOThread;
28 class Profile; 28 class Profile;
29 29
30 namespace content { 30 namespace content {
31 class PluginDataRemover; 31 class PluginDataRemover;
32 class StoragePartition;
32 } 33 }
33 34
34 namespace disk_cache { 35 namespace disk_cache {
35 class Backend; 36 class Backend;
36 } 37 }
37 38
38 namespace net { 39 namespace net {
39 class URLRequestContextGetter; 40 class URLRequestContextGetter;
40 } 41 }
41 42
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 152
152 // Creates a BrowsingDataRemover bound to a specific period of time (as 153 // Creates a BrowsingDataRemover bound to a specific period of time (as
153 // defined via a TimePeriod). Returns a raw pointer, as BrowsingDataRemover 154 // defined via a TimePeriod). Returns a raw pointer, as BrowsingDataRemover
154 // retains ownership of itself, and deletes itself once finished. 155 // retains ownership of itself, and deletes itself once finished.
155 static BrowsingDataRemover* CreateForPeriod(Profile* profile, 156 static BrowsingDataRemover* CreateForPeriod(Profile* profile,
156 TimePeriod period); 157 TimePeriod period);
157 158
158 // Calculate the begin time for the deletion range specified by |time_period|. 159 // Calculate the begin time for the deletion range specified by |time_period|.
159 static base::Time CalculateBeginDeleteTime(TimePeriod time_period); 160 static base::Time CalculateBeginDeleteTime(TimePeriod time_period);
160 161
161 // Quota managed data uses a different bitmask for types than
162 // BrowsingDataRemover uses. This method generates that mask.
163 static int GenerateQuotaClientMask(int remove_mask);
164
165 // Is the BrowsingDataRemover currently in the process of removing data? 162 // Is the BrowsingDataRemover currently in the process of removing data?
166 static bool is_removing() { return is_removing_; } 163 static bool is_removing() { return is_removing_; }
167 164
168 // Removes the specified items related to browsing for all origins that match 165 // Removes the specified items related to browsing for all origins that match
169 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). 166 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask).
170 void Remove(int remove_mask, int origin_set_mask); 167 void Remove(int remove_mask, int origin_set_mask);
171 168
172 void AddObserver(Observer* observer); 169 void AddObserver(Observer* observer);
173 void RemoveObserver(Observer* observer); 170 void RemoveObserver(Observer* observer);
174 171
175 // Called when history deletion is done. 172 // Called when history deletion is done.
176 void OnHistoryDeletionDone(); 173 void OnHistoryDeletionDone();
177 174
178 // Used for testing. 175 // Used for testing.
179 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager); 176 void OverrideStoragePartitionForTesting(
177 content::StoragePartition* storage_partition);
180 178
181 private: 179 private:
182 // The clear API needs to be able to toggle removing_ in order to test that 180 // The clear API needs to be able to toggle removing_ in order to test that
183 // only one BrowsingDataRemover instance can be called at a time. 181 // only one BrowsingDataRemover instance can be called at a time.
184 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); 182 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime);
185 183
186 // The BrowsingDataRemover tests need to be able to access the implementation 184 // The BrowsingDataRemover tests need to be able to access the implementation
187 // of Remove(), as it exposes details that aren't yet available in the public 185 // of Remove(), as it exposes details that aren't yet available in the public
188 // API. As soon as those details are exposed via new methods, this should be 186 // API. As soon as those details are exposed via new methods, this should be
189 // removed. 187 // removed.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // NotifyAndDeleteIfDone. 296 // NotifyAndDeleteIfDone.
299 void ClearedPnaclCache(); 297 void ClearedPnaclCache();
300 298
301 // Invokes ClearedPnaclCacheOn on the UI thread. 299 // Invokes ClearedPnaclCacheOn on the UI thread.
302 void ClearedPnaclCacheOnIOThread(); 300 void ClearedPnaclCacheOnIOThread();
303 301
304 // Invoked on the IO thread to delete entries in the PNaCl translation cache. 302 // Invoked on the IO thread to delete entries in the PNaCl translation cache.
305 void ClearPnaclCacheOnIOThread(base::Time begin, base::Time end); 303 void ClearPnaclCacheOnIOThread(base::Time begin, base::Time end);
306 #endif 304 #endif
307 305
308 // Invoked on the UI thread to delete local storage.
309 void ClearLocalStorageOnUIThread();
310
311 // Callback to deal with the list gathered in ClearLocalStorageOnUIThread.
312 void OnGotLocalStorageUsageInfo(
313 const std::vector<content::LocalStorageUsageInfo>& infos);
314
315 // Invoked on the UI thread to delete session storage.
316 void ClearSessionStorageOnUIThread();
317
318 // Callback to deal with the list gathered in ClearSessionStorageOnUIThread.
319 void OnGotSessionStorageUsageInfo(
320 const std::vector<content::SessionStorageUsageInfo>& infos);
321
322 // Invoked on the IO thread to delete all storage types managed by the quota
323 // system: AppCache, Databases, FileSystems.
324 void ClearQuotaManagedDataOnIOThread();
325
326 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the
327 // core of 'ClearQuotaManagedDataOnIOThread'.
328 void OnGotQuotaManagedOrigins(const std::set<GURL>& origins,
329 quota::StorageType type);
330
331 // Callback responding to deletion of a single quota managed origin's
332 // persistent data
333 void OnQuotaManagedOriginDeletion(const GURL& origin,
334 quota::StorageType type,
335 quota::QuotaStatusCode);
336
337 // Called to check whether all temporary and persistent origin data that
338 // should be deleted has been deleted. If everything's good to go, invokes
339 // OnQuotaManagedDataDeleted on the UI thread.
340 void CheckQuotaManagedDataDeletionStatus();
341
342 // Completion handler that runs on the UI thread once persistent data has been
343 // deleted. Updates the waiting flag and invokes NotifyAndDeleteIfDone.
344 void OnQuotaManagedDataDeleted();
345
346 // Callback for when Cookies has been deleted. Invokes NotifyAndDeleteIfDone. 306 // Callback for when Cookies has been deleted. Invokes NotifyAndDeleteIfDone.
347 void OnClearedCookies(int num_deleted); 307 void OnClearedCookies(int num_deleted);
348 308
349 // Invoked on the IO thread to delete cookies. 309 // Invoked on the IO thread to delete cookies.
350 void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context); 310 void ClearCookiesOnIOThread(net::URLRequestContextGetter* rq_context);
351 311
352 // Invoked on the IO thread to delete server bound certs. 312 // Invoked on the IO thread to delete server bound certs.
353 void ClearServerBoundCertsOnIOThread( 313 void ClearServerBoundCertsOnIOThread(
354 net::URLRequestContextGetter* rq_context); 314 net::URLRequestContextGetter* rq_context);
355 315
356 // Callback on IO Thread when server bound certs have been deleted. Clears SSL 316 // Callback on IO Thread when server bound certs have been deleted. Clears SSL
357 // connection pool and posts to UI thread to run OnClearedServerBoundCerts. 317 // connection pool and posts to UI thread to run OnClearedServerBoundCerts.
358 void OnClearedServerBoundCertsOnIOThread( 318 void OnClearedServerBoundCertsOnIOThread(
359 net::URLRequestContextGetter* rq_context); 319 net::URLRequestContextGetter* rq_context);
360 320
361 // Callback for when server bound certs have been deleted. Invokes 321 // Callback for when server bound certs have been deleted. Invokes
362 // NotifyAndDeleteIfDone. 322 // NotifyAndDeleteIfDone.
363 void OnClearedServerBoundCerts(); 323 void OnClearedServerBoundCerts();
364 324
365 // Callback from the above method. 325 // Callback from the above method.
366 void OnClearedFormData(); 326 void OnClearedFormData();
367 327
368 // Callback for when the Autofill profile and credit card origin URLs have 328 // Callback for when the Autofill profile and credit card origin URLs have
369 // been deleted. 329 // been deleted.
370 void OnClearedAutofillOriginURLs(); 330 void OnClearedAutofillOriginURLs();
371 331
372 // Callback for when the shader cache has been deleted.
373 // Invokes NotifyAndDeleteIfDone.
374 void ClearedShaderCache();
375 332
376 // Invoked on the IO thread to delete from the shader cache. 333 // Callback on UI thread when the storage partition related data are cleared.
377 void ClearShaderCacheOnUIThread(); 334 void OnClearedStoragePartitionData();
378
379 // Callback on UI thread when the WebRTC identities are cleared.
380 void OnClearWebRTCIdentityStore();
381 335
382 // Returns true if we're all done. 336 // Returns true if we're all done.
383 bool AllDone(); 337 bool AllDone();
384 338
385 // Profile we're to remove from. 339 // Profile we're to remove from.
386 Profile* profile_; 340 Profile* profile_;
387 341
388 // The QuotaManager is owned by the profile; we can use a raw pointer here,
389 // and rely on the profile to destroy the object whenever it's reasonable.
390 quota::QuotaManager* quota_manager_;
391
392 // The DOMStorageContext is owned by the profile; we'll store a raw pointer.
393 content::DOMStorageContext* dom_storage_context_;
394
395 // 'Protected' origins are not subject to data removal. 342 // 'Protected' origins are not subject to data removal.
396 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; 343 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_;
397 344
398 // Start time to delete from. 345 // Start time to delete from.
399 const base::Time delete_begin_; 346 const base::Time delete_begin_;
400 347
401 // End time to delete to. 348 // End time to delete to.
402 base::Time delete_end_; 349 base::Time delete_end_;
403 350
404 // True if Remove has been invoked. 351 // True if Remove has been invoked.
(...skipping 19 matching lines...) Expand all
424 // True if we're waiting for various data to be deleted. 371 // True if we're waiting for various data to be deleted.
425 // These may only be accessed from UI thread in order to avoid races! 372 // These may only be accessed from UI thread in order to avoid races!
426 bool waiting_for_clear_autofill_origin_urls_; 373 bool waiting_for_clear_autofill_origin_urls_;
427 bool waiting_for_clear_cache_; 374 bool waiting_for_clear_cache_;
428 bool waiting_for_clear_content_licenses_; 375 bool waiting_for_clear_content_licenses_;
429 // Non-zero if waiting for cookies to be cleared. 376 // Non-zero if waiting for cookies to be cleared.
430 int waiting_for_clear_cookies_count_; 377 int waiting_for_clear_cookies_count_;
431 bool waiting_for_clear_form_; 378 bool waiting_for_clear_form_;
432 bool waiting_for_clear_history_; 379 bool waiting_for_clear_history_;
433 bool waiting_for_clear_hostname_resolution_cache_; 380 bool waiting_for_clear_hostname_resolution_cache_;
434 bool waiting_for_clear_local_storage_; 381 bool waiting_for_clear_keyword_data_;
435 bool waiting_for_clear_logged_in_predictor_; 382 bool waiting_for_clear_logged_in_predictor_;
436 bool waiting_for_clear_nacl_cache_; 383 bool waiting_for_clear_nacl_cache_;
437 bool waiting_for_clear_network_predictor_; 384 bool waiting_for_clear_network_predictor_;
438 bool waiting_for_clear_networking_history_; 385 bool waiting_for_clear_networking_history_;
386 bool waiting_for_clear_platform_keys_;
439 bool waiting_for_clear_plugin_data_; 387 bool waiting_for_clear_plugin_data_;
440 bool waiting_for_clear_pnacl_cache_; 388 bool waiting_for_clear_pnacl_cache_;
441 bool waiting_for_clear_quota_managed_data_;
442 bool waiting_for_clear_server_bound_certs_; 389 bool waiting_for_clear_server_bound_certs_;
443 bool waiting_for_clear_session_storage_; 390 bool waiting_for_clear_storage_partition_data_;
444 bool waiting_for_clear_shader_cache_;
445 bool waiting_for_clear_webrtc_identity_store_;
446 bool waiting_for_clear_keyword_data_;
447 bool waiting_for_clear_platform_keys_;
448
449 // Tracking how many origins need to be deleted, and whether we're finished
450 // gathering origins.
451 int quota_managed_origins_to_delete_count_;
452 int quota_managed_storage_types_to_delete_count_;
453 391
454 // The removal mask for the current removal operation. 392 // The removal mask for the current removal operation.
455 int remove_mask_; 393 int remove_mask_;
456 394
457 // The origin for the current removal operation. 395 // The origin for the current removal operation.
458 GURL remove_origin_; 396 GURL remove_origin_;
459 397
460 // From which types of origins should we remove data? 398 // From which types of origins should we remove data?
461 int origin_set_mask_; 399 int origin_set_mask_;
462 400
463 ObserverList<Observer> observer_list_; 401 ObserverList<Observer> observer_list_;
464 402
465 // Used if we need to clear history. 403 // Used if we need to clear history.
466 CancelableTaskTracker history_task_tracker_; 404 CancelableTaskTracker history_task_tracker_;
467 405
468 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; 406 scoped_ptr<TemplateURLService::Subscription> template_url_sub_;
469 407
408 // We do not own this.
409 content::StoragePartition* storage_partition_for_testing_;
410
470 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); 411 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover);
471 }; 412 };
472 413
473 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 414 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698