OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data_remover.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | |
12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
13 #include "chrome/browser/autofill/personal_data_manager.h" | 14 #include "chrome/browser/autofill/personal_data_manager.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 18 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
18 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/io_thread.h" | 20 #include "chrome/browser/io_thread.h" |
20 #include "chrome/browser/net/chrome_net_log.h" | 21 #include "chrome/browser/net/chrome_net_log.h" |
21 #include "chrome/browser/net/chrome_url_request_context.h" | 22 #include "chrome/browser/net/chrome_url_request_context.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
39 #include "content/common/notification_source.h" | 40 #include "content/common/notification_source.h" |
40 #include "net/base/cookie_monster.h" | 41 #include "net/base/cookie_monster.h" |
41 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
42 #include "net/base/transport_security_state.h" | 43 #include "net/base/transport_security_state.h" |
43 #include "net/disk_cache/disk_cache.h" | 44 #include "net/disk_cache/disk_cache.h" |
44 #include "net/http/http_cache.h" | 45 #include "net/http/http_cache.h" |
45 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
46 #include "net/url_request/url_request_context_getter.h" | 47 #include "net/url_request/url_request_context_getter.h" |
47 #include "webkit/database/database_tracker.h" | 48 #include "webkit/database/database_tracker.h" |
48 #include "webkit/database/database_util.h" | 49 #include "webkit/database/database_util.h" |
49 #include "webkit/fileapi/file_system_context.h" | 50 #include "webkit/quota/quota_manager.h" |
50 #include "webkit/fileapi/file_system_operation_context.h" | 51 #include "webkit/quota/quota_types.h" |
51 #include "webkit/fileapi/sandbox_mount_point_provider.h" | |
52 | 52 |
53 // Done so that we can use PostTask on BrowsingDataRemovers and not have | 53 // Done so that we can use PostTask on BrowsingDataRemovers and not have |
54 // BrowsingDataRemover implement RefCounted. | 54 // BrowsingDataRemover implement RefCounted. |
55 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); | 55 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); |
56 | 56 |
57 bool BrowsingDataRemover::removing_ = false; | 57 bool BrowsingDataRemover::removing_ = false; |
58 | 58 |
59 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 59 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
60 base::Time delete_begin, | 60 base::Time delete_begin, |
61 base::Time delete_end) | 61 base::Time delete_end) |
62 : profile_(profile), | 62 : profile_(profile), |
63 quota_manager_(NULL), | |
63 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 64 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
64 delete_begin_(delete_begin), | 65 delete_begin_(delete_begin), |
65 delete_end_(delete_end), | 66 delete_end_(delete_end), |
66 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | 67 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( |
67 this, &BrowsingDataRemover::OnClearedDatabases)), | 68 this, &BrowsingDataRemover::OnClearedDatabases)), |
68 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 69 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
69 this, &BrowsingDataRemover::DoClearCache)), | 70 this, &BrowsingDataRemover::DoClearCache)), |
70 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( | |
71 this, &BrowsingDataRemover::OnGotAppCacheInfo)), | |
72 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | |
73 this, &BrowsingDataRemover::OnAppCacheDeleted)), | |
74 appcaches_to_be_deleted_count_(0), | |
75 next_cache_state_(STATE_NONE), | 71 next_cache_state_(STATE_NONE), |
76 cache_(NULL), | 72 cache_(NULL), |
77 main_context_getter_(profile->GetRequestContext()), | 73 main_context_getter_(profile->GetRequestContext()), |
78 media_context_getter_(profile->GetRequestContextForMedia()), | 74 media_context_getter_(profile->GetRequestContextForMedia()), |
79 waiting_for_clear_databases_(false), | 75 waiting_for_clear_databases_(false), |
80 waiting_for_clear_history_(false), | 76 waiting_for_clear_history_(false), |
77 waiting_for_clear_temporary_quota_managed_data_(false), | |
78 waiting_for_clear_persistent_quota_managed_data_(false), | |
81 waiting_for_clear_networking_history_(false), | 79 waiting_for_clear_networking_history_(false), |
82 waiting_for_clear_cache_(false), | 80 waiting_for_clear_cache_(false), |
83 waiting_for_clear_appcache_(false), | |
84 waiting_for_clear_gears_data_(false), | 81 waiting_for_clear_gears_data_(false), |
85 waiting_for_clear_file_systems_(false) { | 82 temporary_quota_origins_to_delete_count_(0) { |
86 DCHECK(profile); | 83 DCHECK(profile); |
87 } | 84 } |
88 | 85 |
89 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 86 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
90 TimePeriod time_period, | 87 TimePeriod time_period, |
91 base::Time delete_end) | 88 base::Time delete_end) |
92 : profile_(profile), | 89 : profile_(profile), |
90 quota_manager_(NULL), | |
93 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 91 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
94 delete_begin_(CalculateBeginDeleteTime(time_period)), | 92 delete_begin_(CalculateBeginDeleteTime(time_period)), |
95 delete_end_(delete_end), | 93 delete_end_(delete_end), |
96 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | 94 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( |
97 this, &BrowsingDataRemover::OnClearedDatabases)), | 95 this, &BrowsingDataRemover::OnClearedDatabases)), |
98 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 96 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
99 this, &BrowsingDataRemover::DoClearCache)), | 97 this, &BrowsingDataRemover::DoClearCache)), |
100 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( | |
101 this, &BrowsingDataRemover::OnGotAppCacheInfo)), | |
102 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | |
103 this, &BrowsingDataRemover::OnAppCacheDeleted)), | |
104 appcaches_to_be_deleted_count_(0), | |
105 next_cache_state_(STATE_NONE), | 98 next_cache_state_(STATE_NONE), |
106 cache_(NULL), | 99 cache_(NULL), |
107 main_context_getter_(profile->GetRequestContext()), | 100 main_context_getter_(profile->GetRequestContext()), |
108 media_context_getter_(profile->GetRequestContextForMedia()), | 101 media_context_getter_(profile->GetRequestContextForMedia()), |
109 waiting_for_clear_databases_(false), | 102 waiting_for_clear_databases_(false), |
110 waiting_for_clear_history_(false), | 103 waiting_for_clear_history_(false), |
104 waiting_for_clear_temporary_quota_managed_data_(false), | |
105 waiting_for_clear_persistent_quota_managed_data_(false), | |
111 waiting_for_clear_networking_history_(false), | 106 waiting_for_clear_networking_history_(false), |
112 waiting_for_clear_cache_(false), | 107 waiting_for_clear_cache_(false), |
113 waiting_for_clear_appcache_(false), | 108 waiting_for_clear_gears_data_(false) { |
114 waiting_for_clear_lso_data_(false), | |
115 waiting_for_clear_gears_data_(false), | |
116 waiting_for_clear_file_systems_(false) { | |
117 DCHECK(profile); | 109 DCHECK(profile); |
118 } | 110 } |
119 | 111 |
120 BrowsingDataRemover::~BrowsingDataRemover() { | 112 BrowsingDataRemover::~BrowsingDataRemover() { |
121 DCHECK(all_done()); | 113 DCHECK(all_done()); |
122 } | 114 } |
123 | 115 |
124 void BrowsingDataRemover::Remove(int remove_mask) { | 116 void BrowsingDataRemover::Remove(int remove_mask) { |
125 DCHECK(!removing_); | 117 DCHECK(!removing_); |
126 removing_ = true; | 118 removing_ = true; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); | 200 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); |
209 | 201 |
210 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure | 202 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure |
211 // to remove other data such local databases, STS state, etc. These only can | 203 // to remove other data such local databases, STS state, etc. These only can |
212 // be removed if a WEBKIT thread exists, so check that first: | 204 // be removed if a WEBKIT thread exists, so check that first: |
213 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { | 205 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { |
214 // We assume the end time is now. | 206 // We assume the end time is now. |
215 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); | 207 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); |
216 } | 208 } |
217 | 209 |
210 // We'll start by using the quota system to clear out AppCaches, WebSQL DBs, | |
211 // and File Systems. | |
212 quota_manager_ = profile_->GetQuotaManager(); | |
213 if (quota_manager_) { | |
214 waiting_for_clear_temporary_quota_managed_data_ = true; | |
215 waiting_for_clear_persistent_quota_managed_data_ = true; | |
216 BrowserThread::PostTask( | |
217 BrowserThread::IO, FROM_HERE, | |
218 NewRunnableMethod( | |
219 this, | |
220 &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); | |
221 } | |
222 | |
218 database_tracker_ = profile_->GetDatabaseTracker(); | 223 database_tracker_ = profile_->GetDatabaseTracker(); |
219 if (database_tracker_.get()) { | 224 if (database_tracker_.get()) { |
220 waiting_for_clear_databases_ = true; | 225 waiting_for_clear_databases_ = true; |
221 BrowserThread::PostTask( | 226 BrowserThread::PostTask( |
222 BrowserThread::FILE, FROM_HERE, | 227 BrowserThread::FILE, FROM_HERE, |
223 NewRunnableMethod( | 228 NewRunnableMethod( |
224 this, | 229 this, |
225 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); | 230 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); |
226 } | 231 } |
227 | 232 |
228 appcache_service_ = profile_->GetAppCacheService(); | |
229 if (appcache_service_.get()) { | |
230 waiting_for_clear_appcache_ = true; | |
231 BrowserThread::PostTask( | |
232 BrowserThread::IO, FROM_HERE, | |
233 NewRunnableMethod( | |
234 this, | |
235 &BrowsingDataRemover::ClearAppCacheOnIOThread)); | |
236 } | |
237 | |
238 waiting_for_clear_gears_data_ = true; | 233 waiting_for_clear_gears_data_ = true; |
239 BrowserThread::PostTask( | 234 BrowserThread::PostTask( |
240 BrowserThread::FILE, FROM_HERE, | 235 BrowserThread::FILE, FROM_HERE, |
241 NewRunnableMethod( | 236 NewRunnableMethod( |
242 this, | 237 this, |
243 &BrowsingDataRemover::ClearGearsDataOnFILEThread, | 238 &BrowsingDataRemover::ClearGearsDataOnFILEThread, |
244 profile_->GetPath())); | 239 profile_->GetPath())); |
245 | 240 |
246 waiting_for_clear_file_systems_ = true; | |
247 BrowserThread::PostTask( | |
248 BrowserThread::FILE, FROM_HERE, | |
249 NewRunnableMethod( | |
250 this, | |
251 &BrowsingDataRemover::ClearFileSystemsOnFILEThread)); | |
252 | |
253 if (profile_->GetTransportSecurityState()) { | 241 if (profile_->GetTransportSecurityState()) { |
254 BrowserThread::PostTask( | 242 BrowserThread::PostTask( |
255 BrowserThread::IO, FROM_HERE, | 243 BrowserThread::IO, FROM_HERE, |
256 NewRunnableMethod( | 244 NewRunnableMethod( |
257 profile_->GetTransportSecurityState(), | 245 profile_->GetTransportSecurityState(), |
258 &net::TransportSecurityState::DeleteSince, | 246 &net::TransportSecurityState::DeleteSince, |
259 delete_begin_)); | 247 delete_begin_)); |
260 } | 248 } |
261 } | 249 } |
262 | 250 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 } | 471 } |
484 default: { | 472 default: { |
485 NOTREACHED() << "bad state"; | 473 NOTREACHED() << "bad state"; |
486 next_cache_state_ = STATE_NONE; // Stop looping. | 474 next_cache_state_ = STATE_NONE; // Stop looping. |
487 break; | 475 break; |
488 } | 476 } |
489 } | 477 } |
490 } | 478 } |
491 } | 479 } |
492 | 480 |
493 void BrowsingDataRemover::OnClearedDatabases(int rv) { | 481 void BrowsingDataRemover::OnClearedDatabases(int rv) { |
michaeln
2011/07/26 22:40:19
can be deleted?
Mike West
2011/07/27 12:49:18
Done.
| |
494 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 482 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
495 bool result = BrowserThread::PostTask( | 483 bool result = BrowserThread::PostTask( |
496 BrowserThread::UI, FROM_HERE, | 484 BrowserThread::UI, FROM_HERE, |
497 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedDatabases, rv)); | 485 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedDatabases, rv)); |
498 DCHECK(result); | 486 DCHECK(result); |
499 return; | 487 return; |
500 } | 488 } |
501 // Notify the UI thread that we are done. | 489 // Notify the UI thread that we are done. |
502 database_tracker_ = NULL; | 490 database_tracker_ = NULL; |
503 waiting_for_clear_databases_ = false; | 491 waiting_for_clear_databases_ = false; |
504 | 492 |
505 NotifyAndDeleteIfDone(); | 493 NotifyAndDeleteIfDone(); |
506 } | 494 } |
507 | 495 |
508 void BrowsingDataRemover::ClearDatabasesOnFILEThread() { | 496 void BrowsingDataRemover::ClearDatabasesOnFILEThread() { |
michaeln
2011/07/26 22:40:19
ditto?
Mike West
2011/07/27 12:49:18
Done.
| |
509 // This function should be called on the FILE thread. | 497 // This function should be called on the FILE thread. |
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
511 int rv = database_tracker_->DeleteDataModifiedSince( | 499 int rv = database_tracker_->DeleteDataModifiedSince( |
512 delete_begin_, &database_cleared_callback_); | 500 delete_begin_, &database_cleared_callback_); |
513 if (rv != net::ERR_IO_PENDING) | 501 if (rv != net::ERR_IO_PENDING) |
514 OnClearedDatabases(rv); | 502 OnClearedDatabases(rv); |
515 } | 503 } |
516 | 504 |
517 void BrowsingDataRemover::OnClearedAppCache() { | 505 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { |
518 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 506 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
519 bool result = BrowserThread::PostTask( | 507 DCHECK(waiting_for_clear_temporary_quota_managed_data_); |
520 BrowserThread::UI, FROM_HERE, | 508 DCHECK(waiting_for_clear_persistent_quota_managed_data_); |
521 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedAppCache)); | 509 |
522 DCHECK(result); | 510 // Ask the QuotaManager for all origins with temporary quota modified within |
523 return; | 511 // the user-specified timeframe, and deal with the resulting set in |
512 // OnGotQuotaManagedOrigins(). | |
513 temporary_quota_origins_to_delete_count_ = 0; | |
514 persistent_quota_origins_to_delete_count_ = 0; | |
515 | |
516 // If we're deleting since the beginning of time, ask the QuotaManager for all | |
517 // origins with persistent quota modified within the user-specified timeframe, | |
518 // and deal with the resulting set in OnGotPersistentQuotaManagedOrigins. | |
519 if (delete_begin_ == base::Time()) { | |
520 profile_->GetQuotaManager()->GetOriginsModifiedSince( | |
521 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, | |
522 &BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins)); | |
523 } else { | |
524 // If not deleting since the beginning of time, we're done with any | |
525 // persistent quota. | |
526 waiting_for_clear_persistent_quota_managed_data_ = false; | |
524 } | 527 } |
525 waiting_for_clear_appcache_ = false; | 528 |
526 NotifyAndDeleteIfDone(); | 529 // Do the same for temporary quota, regardless. |
530 profile_->GetQuotaManager()->GetOriginsModifiedSince( | |
531 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, | |
532 &BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins)); | |
527 } | 533 } |
528 | 534 |
529 void BrowsingDataRemover::ClearAppCacheOnIOThread() { | 535 void BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins( |
530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 536 const std::set<GURL>& origins) { |
531 DCHECK(waiting_for_clear_appcache_); | 537 // Walk through the origins passed in, delete temporary quota from each that |
532 appcache_info_ = new appcache::AppCacheInfoCollection; | 538 // isn't protected. |
533 appcache_service_->GetAllAppCacheInfo( | 539 std::set<GURL>::const_iterator origin; |
534 appcache_info_, &appcache_got_info_callback_); | 540 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
535 // continues in OnGotAppCacheInfo. | 541 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
542 continue; | |
543 ++temporary_quota_origins_to_delete_count_; | |
michaeln
2011/07/26 22:40:19
There is a codepath where the QuotaManager will in
Mike West
2011/07/27 12:49:18
I'll ping you about this. I'm not sure I understa
| |
544 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
545 quota::kStorageTypeTemporary, NewCallback(this, | |
546 &BrowsingDataRemover::OnTemporaryQuotaManagedOriginDeletion)); | |
547 } | |
548 if (temporary_quota_origins_to_delete_count_ == 0) | |
549 CheckTemporaryQuotaManagedDataDeletionStatus(); | |
536 } | 550 } |
537 | 551 |
538 void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { | 552 void BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins( |
539 using appcache::AppCacheInfoVector; | 553 const std::set<GURL>& origins) { |
540 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | 554 // Walk through the origins passed in, delete temporary quota from each that |
555 // isn't protected. | |
556 std::set<GURL>::const_iterator origin; | |
557 for (origin = origins.begin(); origin != origins.end(); ++origin) { | |
558 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | |
559 continue; | |
560 ++persistent_quota_origins_to_delete_count_; | |
561 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
562 quota::kStorageTypePersistent, NewCallback(this, | |
563 &BrowsingDataRemover::OnPersistentQuotaManagedOriginDeletion)); | |
564 } | |
565 if (persistent_quota_origins_to_delete_count_ == 0) | |
566 CheckPersistentQuotaManagedDataDeletionStatus(); | |
567 } | |
541 | 568 |
542 for (InfoByOrigin::const_iterator origin = | 569 void BrowsingDataRemover::OnTemporaryQuotaManagedOriginDeletion( |
michaeln
2011/07/26 22:40:19
There's a fair amount of code duplication between
Mike West
2011/07/27 12:49:18
I agree in part, and I've made some changes here,
| |
543 appcache_info_->infos_by_origin.begin(); | 570 quota::QuotaStatusCode status) { |
544 origin != appcache_info_->infos_by_origin.end(); ++origin) { | 571 DCHECK_GT(temporary_quota_origins_to_delete_count_, 0); |
545 if (special_storage_policy_->IsStorageProtected(origin->first)) | 572 if (status != quota::kQuotaStatusOk) { |
546 continue; | 573 // TODO(mkwst): We should add the GURL to StatusCallback; this is a pretty |
547 for (AppCacheInfoVector::const_iterator info = origin->second.begin(); | 574 // worthless error message otherwise. |
548 info != origin->second.end(); ++info) { | 575 DLOG(ERROR) << "Couldn't remove origin. Status: " << status; |
549 if (info->creation_time > delete_begin_) { | |
550 ++appcaches_to_be_deleted_count_; | |
551 appcache_service_->DeleteAppCacheGroup( | |
552 info->manifest_url, &appcache_deleted_callback_); | |
553 } | |
554 } | |
555 } | 576 } |
556 | 577 |
557 if (!appcaches_to_be_deleted_count_) | 578 --temporary_quota_origins_to_delete_count_; |
558 OnClearedAppCache(); | 579 if (temporary_quota_origins_to_delete_count_ == 0) |
559 // else continues in OnAppCacheDeleted | 580 CheckTemporaryQuotaManagedDataDeletionStatus(); |
560 } | 581 } |
561 | 582 |
562 void BrowsingDataRemover::OnAppCacheDeleted(int rv) { | 583 void BrowsingDataRemover::OnPersistentQuotaManagedOriginDeletion( |
563 --appcaches_to_be_deleted_count_; | 584 quota::QuotaStatusCode status) { |
564 if (!appcaches_to_be_deleted_count_) | 585 DCHECK_GT(persistent_quota_origins_to_delete_count_, 0); |
565 OnClearedAppCache(); | 586 if (status != quota::kQuotaStatusOk) |
587 DLOG(ERROR) << "Couldn't remove origin. Status: " << status; | |
588 | |
589 --persistent_quota_origins_to_delete_count_; | |
590 if (persistent_quota_origins_to_delete_count_ == 0) | |
591 CheckPersistentQuotaManagedDataDeletionStatus(); | |
566 } | 592 } |
567 | 593 |
568 void BrowsingDataRemover::ClearFileSystemsOnFILEThread() { | 594 void BrowsingDataRemover::CheckTemporaryQuotaManagedDataDeletionStatus() { |
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 595 DCHECK_EQ(temporary_quota_origins_to_delete_count_, 0); |
570 DCHECK(waiting_for_clear_file_systems_); | 596 DCHECK(waiting_for_clear_temporary_quota_managed_data_); |
571 scoped_refptr<fileapi::FileSystemContext> | |
572 fs_context(profile_->GetFileSystemContext()); | |
573 scoped_ptr<fileapi::SandboxMountPointProvider::OriginEnumerator> | |
574 origin_enumerator(fs_context->path_manager()->sandbox_provider()-> | |
575 CreateOriginEnumerator()); | |
576 | 597 |
577 GURL origin; | 598 waiting_for_clear_temporary_quota_managed_data_ = false; |
578 while (!(origin = origin_enumerator->Next()).is_empty()) { | 599 |
579 if (special_storage_policy_->IsStorageProtected(origin)) | 600 if (!waiting_for_clear_persistent_quota_managed_data_ && |
580 continue; | 601 !waiting_for_clear_temporary_quota_managed_data_) { |
581 if (delete_begin_ == base::Time()) { | 602 BrowserThread::PostTask( |
582 // If the user chooses to delete browsing data "since the beginning of | 603 BrowserThread::UI, FROM_HERE, |
583 // time" remove both temporary and persistent file systems entirely. | 604 NewRunnableMethod( |
584 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | 605 this, |
585 fileapi::kFileSystemTypeTemporary); | 606 &BrowsingDataRemover::NotifyAndDeleteIfDone)); |
586 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | |
587 fileapi::kFileSystemTypePersistent); | |
588 } | |
589 // TODO(mkwst): Else? Decide what to do for time-based deletion: crbug/63700 | |
590 } | 607 } |
591 | |
592 BrowserThread::PostTask( | |
593 BrowserThread::UI, FROM_HERE, | |
594 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedFileSystems)); | |
595 } | 608 } |
596 | 609 |
597 void BrowsingDataRemover::OnClearedFileSystems() { | 610 void BrowsingDataRemover::CheckPersistentQuotaManagedDataDeletionStatus() { |
598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 611 DCHECK_EQ(persistent_quota_origins_to_delete_count_, 0); |
599 waiting_for_clear_file_systems_ = false; | 612 DCHECK(waiting_for_clear_persistent_quota_managed_data_); |
600 NotifyAndDeleteIfDone(); | 613 |
614 waiting_for_clear_persistent_quota_managed_data_ = false; | |
615 if (!waiting_for_clear_persistent_quota_managed_data_ && | |
616 !waiting_for_clear_temporary_quota_managed_data_) { | |
617 BrowserThread::PostTask( | |
618 BrowserThread::UI, FROM_HERE, | |
619 NewRunnableMethod( | |
620 this, | |
621 &BrowsingDataRemover::NotifyAndDeleteIfDone)); | |
622 } | |
601 } | 623 } |
602 | 624 |
603 // static | 625 // static |
604 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { | 626 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { |
605 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); | 627 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); |
606 if (file_util::DirectoryExists(plugin_data)) | 628 if (file_util::DirectoryExists(plugin_data)) |
607 file_util::Delete(plugin_data, true); | 629 file_util::Delete(plugin_data, true); |
608 } | 630 } |
609 | 631 |
610 void BrowsingDataRemover::OnClearedGearsData() { | 632 void BrowsingDataRemover::OnClearedGearsData() { |
(...skipping 15 matching lines...) Expand all Loading... | |
626 | 648 |
627 ClearGearsData(profile_dir); | 649 ClearGearsData(profile_dir); |
628 OnClearedGearsData(); | 650 OnClearedGearsData(); |
629 } | 651 } |
630 | 652 |
631 void BrowsingDataRemover::OnWaitableEventSignaled( | 653 void BrowsingDataRemover::OnWaitableEventSignaled( |
632 base::WaitableEvent* waitable_event) { | 654 base::WaitableEvent* waitable_event) { |
633 waiting_for_clear_lso_data_ = false; | 655 waiting_for_clear_lso_data_ = false; |
634 NotifyAndDeleteIfDone(); | 656 NotifyAndDeleteIfDone(); |
635 } | 657 } |
OLD | NEW |