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" | |
marja
2011/07/26 11:53:07
Is this intentionally left in?
Mike West
2011/07/26 12:08:33
Yes. I DLOG the status code if an origin can't be
| |
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), | |
114 waiting_for_clear_lso_data_(false), | |
115 waiting_for_clear_gears_data_(false), | 108 waiting_for_clear_gears_data_(false), |
116 waiting_for_clear_file_systems_(false) { | 109 temporary_quota_origins_to_delete_count_(0) { |
marja
2011/07/26 11:53:07
Why initialize temporary_quota_origins_to_delete_c
Mike West
2011/07/26 12:08:33
Copy/paste error. Nice catch!
Both are set to 0
| |
117 DCHECK(profile); | 110 DCHECK(profile); |
118 } | 111 } |
119 | 112 |
120 BrowsingDataRemover::~BrowsingDataRemover() { | 113 BrowsingDataRemover::~BrowsingDataRemover() { |
121 DCHECK(all_done()); | 114 DCHECK(all_done()); |
122 } | 115 } |
123 | 116 |
124 void BrowsingDataRemover::Remove(int remove_mask) { | 117 void BrowsingDataRemover::Remove(int remove_mask) { |
125 DCHECK(!removing_); | 118 DCHECK(!removing_); |
126 removing_ = true; | 119 removing_ = true; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); | 201 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); |
209 | 202 |
210 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure | 203 // 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 | 204 // 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: | 205 // be removed if a WEBKIT thread exists, so check that first: |
213 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { | 206 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { |
214 // We assume the end time is now. | 207 // We assume the end time is now. |
215 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); | 208 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); |
216 } | 209 } |
217 | 210 |
211 // We'll start by using the quota system to clear out AppCaches, WebSQL DBs, | |
212 // and File Systems. | |
213 quota_manager_ = profile_->GetQuotaManager(); | |
214 if (quota_manager_) { | |
215 waiting_for_clear_temporary_quota_managed_data_ = true; | |
216 waiting_for_clear_persistent_quota_managed_data_ = true; | |
217 BrowserThread::PostTask( | |
218 BrowserThread::IO, FROM_HERE, | |
219 NewRunnableMethod( | |
220 this, | |
221 &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); | |
222 } | |
223 | |
218 database_tracker_ = profile_->GetDatabaseTracker(); | 224 database_tracker_ = profile_->GetDatabaseTracker(); |
219 if (database_tracker_.get()) { | 225 if (database_tracker_.get()) { |
220 waiting_for_clear_databases_ = true; | 226 waiting_for_clear_databases_ = true; |
221 BrowserThread::PostTask( | 227 BrowserThread::PostTask( |
222 BrowserThread::FILE, FROM_HERE, | 228 BrowserThread::FILE, FROM_HERE, |
223 NewRunnableMethod( | 229 NewRunnableMethod( |
224 this, | 230 this, |
225 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); | 231 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); |
226 } | 232 } |
227 | 233 |
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; | 234 waiting_for_clear_gears_data_ = true; |
239 BrowserThread::PostTask( | 235 BrowserThread::PostTask( |
240 BrowserThread::FILE, FROM_HERE, | 236 BrowserThread::FILE, FROM_HERE, |
241 NewRunnableMethod( | 237 NewRunnableMethod( |
242 this, | 238 this, |
243 &BrowsingDataRemover::ClearGearsDataOnFILEThread, | 239 &BrowsingDataRemover::ClearGearsDataOnFILEThread, |
244 profile_->GetPath())); | 240 profile_->GetPath())); |
245 | 241 |
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()) { | 242 if (profile_->GetTransportSecurityState()) { |
254 BrowserThread::PostTask( | 243 BrowserThread::PostTask( |
255 BrowserThread::IO, FROM_HERE, | 244 BrowserThread::IO, FROM_HERE, |
256 NewRunnableMethod( | 245 NewRunnableMethod( |
257 profile_->GetTransportSecurityState(), | 246 profile_->GetTransportSecurityState(), |
258 &net::TransportSecurityState::DeleteSince, | 247 &net::TransportSecurityState::DeleteSince, |
259 delete_begin_)); | 248 delete_begin_)); |
260 } | 249 } |
261 } | 250 } |
262 | 251 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 | 496 |
508 void BrowsingDataRemover::ClearDatabasesOnFILEThread() { | 497 void BrowsingDataRemover::ClearDatabasesOnFILEThread() { |
509 // This function should be called on the FILE thread. | 498 // This function should be called on the FILE thread. |
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
511 int rv = database_tracker_->DeleteDataModifiedSince( | 500 int rv = database_tracker_->DeleteDataModifiedSince( |
512 delete_begin_, &database_cleared_callback_); | 501 delete_begin_, &database_cleared_callback_); |
513 if (rv != net::ERR_IO_PENDING) | 502 if (rv != net::ERR_IO_PENDING) |
514 OnClearedDatabases(rv); | 503 OnClearedDatabases(rv); |
515 } | 504 } |
516 | 505 |
517 void BrowsingDataRemover::OnClearedAppCache() { | 506 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { |
518 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 507 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
519 bool result = BrowserThread::PostTask( | 508 DCHECK(waiting_for_clear_temporary_quota_managed_data_); |
520 BrowserThread::UI, FROM_HERE, | 509 DCHECK(waiting_for_clear_persistent_quota_managed_data_); |
521 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedAppCache)); | 510 |
522 DCHECK(result); | 511 // Ask the QuotaManager for all origins with temporary quota modified within |
523 return; | 512 // the user-specified timeframe, and deal with the resulting set in |
513 // OnGotQuotaManagedOrigins(). | |
514 temporary_quota_origins_to_delete_count_ = 0; | |
515 persistent_quota_origins_to_delete_count_ = 0; | |
516 | |
517 // If we're deleting since the beginning of time, ask the QuotaManager for all | |
518 // origins with persistent quota modified within the user-specified timeframe, | |
519 // and deal with the resulting set in OnGotPersistentQuotaManagedOrigins. | |
520 if (delete_begin_ == base::Time()) { | |
521 profile_->GetQuotaManager()->GetOriginsModifiedSince( | |
522 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, | |
523 &BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins)); | |
524 } else { | |
525 // If not deleting since the beginning of time, we're done with any | |
526 // persistent quota. | |
527 waiting_for_clear_persistent_quota_managed_data_ = false; | |
524 } | 528 } |
525 waiting_for_clear_appcache_ = false; | 529 |
526 NotifyAndDeleteIfDone(); | 530 // Do the same for temporary quota, regardless. |
531 profile_->GetQuotaManager()->GetOriginsModifiedSince( | |
532 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, | |
533 &BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins)); | |
527 } | 534 } |
528 | 535 |
529 void BrowsingDataRemover::ClearAppCacheOnIOThread() { | 536 void BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins( |
530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 537 const std::set<GURL>& origins) { |
531 DCHECK(waiting_for_clear_appcache_); | 538 // Walk through the origins passed in, delete temporary quota from each that |
532 appcache_info_ = new appcache::AppCacheInfoCollection; | 539 // isn't protected. |
533 appcache_service_->GetAllAppCacheInfo( | 540 std::set<GURL>::const_iterator origin; |
534 appcache_info_, &appcache_got_info_callback_); | 541 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
535 // continues in OnGotAppCacheInfo. | 542 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) |
543 continue; | |
544 ++temporary_quota_origins_to_delete_count_; | |
545 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
546 quota::kStorageTypeTemporary, NewCallback(this, | |
547 &BrowsingDataRemover::OnTemporaryQuotaManagedOriginDeletion)); | |
548 } | |
549 if (temporary_quota_origins_to_delete_count_ == 0) | |
550 CheckTemporaryQuotaManagedDataDeletionStatus(); | |
536 } | 551 } |
537 | 552 |
538 void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { | 553 void BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins( |
539 using appcache::AppCacheInfoVector; | 554 const std::set<GURL>& origins) { |
540 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | 555 // Walk through the origins passed in, delete temporary quota from each that |
556 // isn't protected. | |
557 bool deleting = false; | |
marja
2011/07/26 11:53:07
This bool seems unnecessary.
Mike West
2011/07/26 12:08:33
It in fact _is_ unnecessary.
| |
558 std::set<GURL>::const_iterator origin; | |
559 for (origin = origins.begin(); origin != origins.end(); ++origin) { | |
560 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | |
561 continue; | |
562 deleting = true; | |
563 ++persistent_quota_origins_to_delete_count_; | |
564 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
565 quota::kStorageTypePersistent, NewCallback(this, | |
566 &BrowsingDataRemover::OnPersistentQuotaManagedOriginDeletion)); | |
567 } | |
568 if (persistent_quota_origins_to_delete_count_ == 0) | |
569 CheckPersistentQuotaManagedDataDeletionStatus(); | |
570 } | |
541 | 571 |
542 for (InfoByOrigin::const_iterator origin = | 572 void BrowsingDataRemover::OnTemporaryQuotaManagedOriginDeletion( |
543 appcache_info_->infos_by_origin.begin(); | 573 quota::QuotaStatusCode status) { |
544 origin != appcache_info_->infos_by_origin.end(); ++origin) { | 574 if (status != quota::kQuotaStatusOk) { |
545 if (special_storage_policy_->IsStorageProtected(origin->first)) | 575 // TODO(mkwst): We should add the GURL to StatusCallback; this is a pretty |
546 continue; | 576 // worthless error message otherwise. |
547 for (AppCacheInfoVector::const_iterator info = origin->second.begin(); | 577 DLOG(ERROR) << "Couldn't remove origin. Status: " << status; |
548 info != origin->second.end(); ++info) { | |
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 } | 578 } |
556 | 579 |
557 if (!appcaches_to_be_deleted_count_) | 580 --temporary_quota_origins_to_delete_count_; |
558 OnClearedAppCache(); | 581 if (temporary_quota_origins_to_delete_count_ == 0) |
559 // else continues in OnAppCacheDeleted | 582 CheckTemporaryQuotaManagedDataDeletionStatus(); |
560 } | 583 } |
561 | 584 |
562 void BrowsingDataRemover::OnAppCacheDeleted(int rv) { | 585 void BrowsingDataRemover::OnPersistentQuotaManagedOriginDeletion( |
563 --appcaches_to_be_deleted_count_; | 586 quota::QuotaStatusCode status) { |
564 if (!appcaches_to_be_deleted_count_) | 587 DCHECK_GT(persistent_quota_origins_to_delete_count_, 0); |
565 OnClearedAppCache(); | 588 if (status != quota::kQuotaStatusOk) |
589 DLOG(ERROR) << "Couldn't remove origin. Status: " << status; | |
590 | |
591 --persistent_quota_origins_to_delete_count_; | |
592 if (persistent_quota_origins_to_delete_count_ == 0) | |
593 CheckPersistentQuotaManagedDataDeletionStatus(); | |
566 } | 594 } |
567 | 595 |
568 void BrowsingDataRemover::ClearFileSystemsOnFILEThread() { | 596 void BrowsingDataRemover::CheckTemporaryQuotaManagedDataDeletionStatus() { |
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 597 DCHECK_EQ(temporary_quota_origins_to_delete_count_, 0); |
570 DCHECK(waiting_for_clear_file_systems_); | 598 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 | 599 |
577 GURL origin; | 600 waiting_for_clear_temporary_quota_managed_data_ = false; |
578 while (!(origin = origin_enumerator->Next()).is_empty()) { | 601 |
579 if (special_storage_policy_->IsStorageProtected(origin)) | 602 if (!waiting_for_clear_persistent_quota_managed_data_ && |
580 continue; | 603 !waiting_for_clear_temporary_quota_managed_data_) { |
581 if (delete_begin_ == base::Time()) { | 604 BrowserThread::PostTask( |
582 // If the user chooses to delete browsing data "since the beginning of | 605 BrowserThread::UI, FROM_HERE, |
583 // time" remove both temporary and persistent file systems entirely. | 606 NewRunnableMethod( |
584 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | 607 this, |
585 fileapi::kFileSystemTypeTemporary); | 608 &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 } | 609 } |
591 | |
592 BrowserThread::PostTask( | |
593 BrowserThread::UI, FROM_HERE, | |
594 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedFileSystems)); | |
595 } | 610 } |
596 | 611 |
597 void BrowsingDataRemover::OnClearedFileSystems() { | 612 void BrowsingDataRemover::CheckPersistentQuotaManagedDataDeletionStatus() { |
598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 613 DCHECK_EQ(persistent_quota_origins_to_delete_count_, 0); |
599 waiting_for_clear_file_systems_ = false; | 614 DCHECK(waiting_for_clear_persistent_quota_managed_data_); |
600 NotifyAndDeleteIfDone(); | 615 |
616 waiting_for_clear_persistent_quota_managed_data_ = false; | |
617 if (!waiting_for_clear_persistent_quota_managed_data_ && | |
618 !waiting_for_clear_temporary_quota_managed_data_) { | |
619 BrowserThread::PostTask( | |
620 BrowserThread::UI, FROM_HERE, | |
621 NewRunnableMethod( | |
622 this, | |
623 &BrowsingDataRemover::NotifyAndDeleteIfDone)); | |
624 } | |
601 } | 625 } |
602 | 626 |
603 // static | 627 // static |
604 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { | 628 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { |
605 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); | 629 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); |
606 if (file_util::DirectoryExists(plugin_data)) | 630 if (file_util::DirectoryExists(plugin_data)) |
607 file_util::Delete(plugin_data, true); | 631 file_util::Delete(plugin_data, true); |
608 } | 632 } |
609 | 633 |
610 void BrowsingDataRemover::OnClearedGearsData() { | 634 void BrowsingDataRemover::OnClearedGearsData() { |
(...skipping 15 matching lines...) Expand all Loading... | |
626 | 650 |
627 ClearGearsData(profile_dir); | 651 ClearGearsData(profile_dir); |
628 OnClearedGearsData(); | 652 OnClearedGearsData(); |
629 } | 653 } |
630 | 654 |
631 void BrowsingDataRemover::OnWaitableEventSignaled( | 655 void BrowsingDataRemover::OnWaitableEventSignaled( |
632 base::WaitableEvent* waitable_event) { | 656 base::WaitableEvent* waitable_event) { |
633 waiting_for_clear_lso_data_ = false; | 657 waiting_for_clear_lso_data_ = false; |
634 NotifyAndDeleteIfDone(); | 658 NotifyAndDeleteIfDone(); |
635 } | 659 } |
OLD | NEW |