Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 37 #include "content/browser/in_process_webkit/webkit_context.h" | 38 #include "content/browser/in_process_webkit/webkit_context.h" |
| 38 #include "content/browser/user_metrics.h" | 39 #include "content/browser/user_metrics.h" |
| 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/quota/quota_manager.h" |
| 48 #include "webkit/database/database_util.h" | 49 #include "webkit/quota/quota_types.h" |
| 49 #include "webkit/fileapi/file_system_context.h" | |
| 50 #include "webkit/fileapi/file_system_operation_context.h" | |
| 51 #include "webkit/fileapi/sandbox_mount_point_provider.h" | |
| 52 | 50 |
| 53 // Done so that we can use PostTask on BrowsingDataRemovers and not have | 51 // Done so that we can use PostTask on BrowsingDataRemovers and not have |
| 54 // BrowsingDataRemover implement RefCounted. | 52 // BrowsingDataRemover implement RefCounted. |
| 55 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); | 53 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); |
| 56 | 54 |
| 57 bool BrowsingDataRemover::removing_ = false; | 55 bool BrowsingDataRemover::removing_ = false; |
| 58 | 56 |
| 59 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 57 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 60 base::Time delete_begin, | 58 base::Time delete_begin, |
| 61 base::Time delete_end) | 59 base::Time delete_end) |
| 62 : profile_(profile), | 60 : profile_(profile), |
| 61 quota_manager_(NULL), | |
| 63 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 62 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 64 delete_begin_(delete_begin), | 63 delete_begin_(delete_begin), |
| 65 delete_end_(delete_end), | 64 delete_end_(delete_end), |
| 66 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | |
| 67 this, &BrowsingDataRemover::OnClearedDatabases)), | |
| 68 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 65 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
| 69 this, &BrowsingDataRemover::DoClearCache)), | 66 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), | 67 next_cache_state_(STATE_NONE), |
| 76 cache_(NULL), | 68 cache_(NULL), |
| 77 main_context_getter_(profile->GetRequestContext()), | 69 main_context_getter_(profile->GetRequestContext()), |
| 78 media_context_getter_(profile->GetRequestContextForMedia()), | 70 media_context_getter_(profile->GetRequestContextForMedia()), |
| 79 waiting_for_clear_databases_(false), | |
| 80 waiting_for_clear_history_(false), | 71 waiting_for_clear_history_(false), |
| 72 waiting_for_clear_quota_managed_data_(false), | |
| 81 waiting_for_clear_networking_history_(false), | 73 waiting_for_clear_networking_history_(false), |
| 82 waiting_for_clear_cache_(false), | 74 waiting_for_clear_cache_(false) { |
| 83 waiting_for_clear_appcache_(false), | |
| 84 waiting_for_clear_gears_data_(false), | |
| 85 waiting_for_clear_file_systems_(false) { | |
| 86 DCHECK(profile); | 75 DCHECK(profile); |
| 87 } | 76 } |
| 88 | 77 |
| 89 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 78 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 90 TimePeriod time_period, | 79 TimePeriod time_period, |
| 91 base::Time delete_end) | 80 base::Time delete_end) |
| 92 : profile_(profile), | 81 : profile_(profile), |
| 82 quota_manager_(NULL), | |
| 93 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 83 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 94 delete_begin_(CalculateBeginDeleteTime(time_period)), | 84 delete_begin_(CalculateBeginDeleteTime(time_period)), |
| 95 delete_end_(delete_end), | 85 delete_end_(delete_end), |
| 96 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | |
| 97 this, &BrowsingDataRemover::OnClearedDatabases)), | |
| 98 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 86 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
| 99 this, &BrowsingDataRemover::DoClearCache)), | 87 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), | 88 next_cache_state_(STATE_NONE), |
| 106 cache_(NULL), | 89 cache_(NULL), |
| 107 main_context_getter_(profile->GetRequestContext()), | 90 main_context_getter_(profile->GetRequestContext()), |
| 108 media_context_getter_(profile->GetRequestContextForMedia()), | 91 media_context_getter_(profile->GetRequestContextForMedia()), |
| 109 waiting_for_clear_databases_(false), | |
| 110 waiting_for_clear_history_(false), | 92 waiting_for_clear_history_(false), |
| 93 waiting_for_clear_quota_managed_data_(false), | |
| 111 waiting_for_clear_networking_history_(false), | 94 waiting_for_clear_networking_history_(false), |
| 112 waiting_for_clear_cache_(false), | 95 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), | |
| 116 waiting_for_clear_file_systems_(false) { | |
| 117 DCHECK(profile); | 96 DCHECK(profile); |
| 118 } | 97 } |
| 119 | 98 |
| 120 BrowsingDataRemover::~BrowsingDataRemover() { | 99 BrowsingDataRemover::~BrowsingDataRemover() { |
| 121 DCHECK(all_done()); | 100 DCHECK(all_done()); |
| 122 } | 101 } |
| 123 | 102 |
| 124 void BrowsingDataRemover::Remove(int remove_mask) { | 103 void BrowsingDataRemover::Remove(int remove_mask) { |
| 125 DCHECK(!removing_); | 104 DCHECK(!removing_); |
| 126 removing_ = true; | 105 removing_ = true; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); | 187 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); |
| 209 | 188 |
| 210 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure | 189 // 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 | 190 // 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: | 191 // be removed if a WEBKIT thread exists, so check that first: |
| 213 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { | 192 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { |
| 214 // We assume the end time is now. | 193 // We assume the end time is now. |
| 215 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); | 194 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); |
| 216 } | 195 } |
| 217 | 196 |
| 218 database_tracker_ = profile_->GetDatabaseTracker(); | 197 // We'll start by using the quota system to clear out AppCaches, WebSQL DBs, |
| 219 if (database_tracker_.get()) { | 198 // and File Systems. |
| 220 waiting_for_clear_databases_ = true; | 199 quota_manager_ = profile_->GetQuotaManager(); |
| 221 BrowserThread::PostTask( | 200 if (quota_manager_) { |
| 222 BrowserThread::FILE, FROM_HERE, | 201 waiting_for_clear_quota_managed_data_ = true; |
| 223 NewRunnableMethod( | |
| 224 this, | |
| 225 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); | |
| 226 } | |
| 227 | |
| 228 appcache_service_ = profile_->GetAppCacheService(); | |
| 229 if (appcache_service_.get()) { | |
| 230 waiting_for_clear_appcache_ = true; | |
| 231 BrowserThread::PostTask( | 202 BrowserThread::PostTask( |
| 232 BrowserThread::IO, FROM_HERE, | 203 BrowserThread::IO, FROM_HERE, |
| 233 NewRunnableMethod( | 204 NewRunnableMethod( |
| 234 this, | 205 this, |
| 235 &BrowsingDataRemover::ClearAppCacheOnIOThread)); | 206 &BrowsingDataRemover::ClearQuotaManagedDataOnIOThread)); |
| 236 } | 207 } |
| 237 | 208 |
| 238 waiting_for_clear_gears_data_ = true; | |
| 239 BrowserThread::PostTask( | |
| 240 BrowserThread::FILE, FROM_HERE, | |
| 241 NewRunnableMethod( | |
| 242 this, | |
| 243 &BrowsingDataRemover::ClearGearsDataOnFILEThread, | |
| 244 profile_->GetPath())); | |
| 245 | |
| 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()) { | 209 if (profile_->GetTransportSecurityState()) { |
| 254 BrowserThread::PostTask( | 210 BrowserThread::PostTask( |
| 255 BrowserThread::IO, FROM_HERE, | 211 BrowserThread::IO, FROM_HERE, |
| 256 NewRunnableMethod( | 212 NewRunnableMethod( |
| 257 profile_->GetTransportSecurityState(), | 213 profile_->GetTransportSecurityState(), |
| 258 &net::TransportSecurityState::DeleteSince, | 214 &net::TransportSecurityState::DeleteSince, |
| 259 delete_begin_)); | 215 delete_begin_)); |
| 260 } | 216 } |
| 261 } | 217 } |
| 262 | 218 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 } | 439 } |
| 484 default: { | 440 default: { |
| 485 NOTREACHED() << "bad state"; | 441 NOTREACHED() << "bad state"; |
| 486 next_cache_state_ = STATE_NONE; // Stop looping. | 442 next_cache_state_ = STATE_NONE; // Stop looping. |
| 487 break; | 443 break; |
| 488 } | 444 } |
| 489 } | 445 } |
| 490 } | 446 } |
| 491 } | 447 } |
| 492 | 448 |
| 493 void BrowsingDataRemover::OnClearedDatabases(int rv) { | 449 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { |
| 494 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 495 bool result = BrowserThread::PostTask( | 451 DCHECK(waiting_for_clear_quota_managed_data_); |
| 496 BrowserThread::UI, FROM_HERE, | 452 |
| 497 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedDatabases, rv)); | 453 // Ask the QuotaManager for all origins with temporary quota modified within |
| 498 DCHECK(result); | 454 // the user-specified timeframe, and deal with the resulting set in |
| 499 return; | 455 // OnGotQuotaManagedOrigins(). |
| 456 quota_managed_origins_to_delete_count_ = 0; | |
| 457 waiting_for_persistent_quota_managed_origin_list_ = true; | |
| 458 waiting_for_temporary_quota_managed_origin_list_ = true; | |
|
michaeln
2011/07/28 19:17:48
You may be able to get a little more code reuse if
Use mkwst_at_chromium.org plz.
2011/07/28 19:59:09
Combining the boolean flags into a counter makes s
Mike West
2011/07/29 16:39:59
Replaced the flags with a counter, filed http://cr
| |
| 459 | |
| 460 // If we're deleting since the beginning of time, ask the QuotaManager for all | |
| 461 // origins with persistent quota modified within the user-specified timeframe, | |
| 462 // and deal with the resulting set in OnGotPersistentQuotaManagedOrigins. | |
| 463 if (delete_begin_ == base::Time()) { | |
| 464 profile_->GetQuotaManager()->GetOriginsModifiedSince( | |
| 465 quota::kStorageTypePersistent, delete_begin_, NewCallback(this, | |
| 466 &BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins)); | |
| 467 } else { | |
| 468 waiting_for_persistent_quota_managed_origin_list_ = false; | |
| 500 } | 469 } |
| 501 // Notify the UI thread that we are done. | |
| 502 database_tracker_ = NULL; | |
| 503 waiting_for_clear_databases_ = false; | |
| 504 | 470 |
| 505 NotifyAndDeleteIfDone(); | 471 // Do the same for temporary quota, regardless. |
| 472 profile_->GetQuotaManager()->GetOriginsModifiedSince( | |
| 473 quota::kStorageTypeTemporary, delete_begin_, NewCallback(this, | |
| 474 &BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins)); | |
| 506 } | 475 } |
| 507 | 476 |
| 508 void BrowsingDataRemover::ClearDatabasesOnFILEThread() { | 477 void BrowsingDataRemover::OnGotTemporaryQuotaManagedOrigins( |
| 509 // This function should be called on the FILE thread. | 478 const std::set<GURL>& origins) { |
| 510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 479 DCHECK(waiting_for_temporary_quota_managed_origin_list_); |
| 511 int rv = database_tracker_->DeleteDataModifiedSince( | 480 // Walk through the origins passed in, delete temporary quota from each that |
| 512 delete_begin_, &database_cleared_callback_); | 481 // isn't protected. |
| 513 if (rv != net::ERR_IO_PENDING) | 482 std::set<GURL>::const_iterator origin; |
| 514 OnClearedDatabases(rv); | 483 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
| 484 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | |
| 485 continue; | |
| 486 ++quota_managed_origins_to_delete_count_; | |
| 487 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
| 488 quota::kStorageTypeTemporary, NewCallback(this, | |
| 489 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); | |
| 490 } | |
| 491 | |
| 492 waiting_for_temporary_quota_managed_origin_list_ = false; | |
| 493 if (!waiting_for_persistent_quota_managed_origin_list_ && | |
| 494 !waiting_for_temporary_quota_managed_origin_list_ && | |
| 495 quota_managed_origins_to_delete_count_ == 0) | |
| 496 CheckQuotaManagedDataDeletionStatus(); | |
| 515 } | 497 } |
| 516 | 498 |
| 517 void BrowsingDataRemover::OnClearedAppCache() { | 499 void BrowsingDataRemover::OnGotPersistentQuotaManagedOrigins( |
| 518 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 500 const std::set<GURL>& origins) { |
| 519 bool result = BrowserThread::PostTask( | 501 DCHECK(waiting_for_persistent_quota_managed_origin_list_); |
| 520 BrowserThread::UI, FROM_HERE, | 502 // Walk through the origins passed in, delete persistent quota from each that |
| 521 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedAppCache)); | 503 // isn't protected. |
| 522 DCHECK(result); | 504 std::set<GURL>::const_iterator origin; |
| 523 return; | 505 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
| 506 if (special_storage_policy_->IsStorageProtected(origin->GetOrigin())) | |
| 507 continue; | |
| 508 ++quota_managed_origins_to_delete_count_; | |
| 509 quota_manager_->DeleteOriginData(origin->GetOrigin(), | |
| 510 quota::kStorageTypePersistent, NewCallback(this, | |
| 511 &BrowsingDataRemover::OnQuotaManagedOriginDeletion)); | |
| 524 } | 512 } |
| 525 waiting_for_clear_appcache_ = false; | 513 |
| 526 NotifyAndDeleteIfDone(); | 514 waiting_for_persistent_quota_managed_origin_list_ = false; |
| 515 if (!waiting_for_persistent_quota_managed_origin_list_ && | |
| 516 !waiting_for_temporary_quota_managed_origin_list_ && | |
| 517 quota_managed_origins_to_delete_count_ == 0) | |
| 518 CheckQuotaManagedDataDeletionStatus(); | |
| 527 } | 519 } |
| 528 | 520 |
| 529 void BrowsingDataRemover::ClearAppCacheOnIOThread() { | 521 void BrowsingDataRemover::OnQuotaManagedOriginDeletion( |
| 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 522 quota::QuotaStatusCode status) { |
| 531 DCHECK(waiting_for_clear_appcache_); | 523 DCHECK_GT(quota_managed_origins_to_delete_count_, 0); |
| 532 appcache_info_ = new appcache::AppCacheInfoCollection; | 524 if (status != quota::kQuotaStatusOk) { |
| 533 appcache_service_->GetAllAppCacheInfo( | 525 // TODO(mkwst): We should add the GURL to StatusCallback; this is a pretty |
| 534 appcache_info_, &appcache_got_info_callback_); | 526 // worthless error message otherwise. |
| 535 // continues in OnGotAppCacheInfo. | 527 DLOG(ERROR) << "Couldn't remove origin. Status: " << status; |
| 528 } | |
| 529 | |
| 530 --quota_managed_origins_to_delete_count_; | |
| 531 if (!waiting_for_persistent_quota_managed_origin_list_ && | |
| 532 !waiting_for_temporary_quota_managed_origin_list_ && | |
| 533 quota_managed_origins_to_delete_count_ == 0) | |
| 534 CheckQuotaManagedDataDeletionStatus(); | |
| 536 } | 535 } |
| 537 | 536 |
| 538 void BrowsingDataRemover::OnGotAppCacheInfo(int rv) { | 537 void BrowsingDataRemover::CheckQuotaManagedDataDeletionStatus() { |
| 539 using appcache::AppCacheInfoVector; | 538 DCHECK_EQ(quota_managed_origins_to_delete_count_, 0); |
| 540 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | 539 DCHECK(waiting_for_clear_quota_managed_data_); |
| 540 DCHECK(!waiting_for_temporary_quota_managed_origin_list_); | |
| 541 DCHECK(!waiting_for_persistent_quota_managed_origin_list_); | |
| 541 | 542 |
| 542 for (InfoByOrigin::const_iterator origin = | 543 waiting_for_clear_quota_managed_data_ = false; |
| 543 appcache_info_->infos_by_origin.begin(); | |
| 544 origin != appcache_info_->infos_by_origin.end(); ++origin) { | |
| 545 if (special_storage_policy_->IsStorageProtected(origin->first)) | |
| 546 continue; | |
| 547 for (AppCacheInfoVector::const_iterator info = origin->second.begin(); | |
| 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 } | |
| 556 | |
| 557 if (!appcaches_to_be_deleted_count_) | |
| 558 OnClearedAppCache(); | |
| 559 // else continues in OnAppCacheDeleted | |
| 560 } | |
| 561 | |
| 562 void BrowsingDataRemover::OnAppCacheDeleted(int rv) { | |
| 563 --appcaches_to_be_deleted_count_; | |
| 564 if (!appcaches_to_be_deleted_count_) | |
| 565 OnClearedAppCache(); | |
| 566 } | |
| 567 | |
| 568 void BrowsingDataRemover::ClearFileSystemsOnFILEThread() { | |
| 569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 570 DCHECK(waiting_for_clear_file_systems_); | |
| 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 | |
| 577 GURL origin; | |
| 578 while (!(origin = origin_enumerator->Next()).is_empty()) { | |
| 579 if (special_storage_policy_->IsStorageProtected(origin)) | |
| 580 continue; | |
| 581 if (delete_begin_ == base::Time()) { | |
| 582 // If the user chooses to delete browsing data "since the beginning of | |
| 583 // time" remove both temporary and persistent file systems entirely. | |
| 584 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | |
| 585 fileapi::kFileSystemTypeTemporary); | |
| 586 fs_context->DeleteDataForOriginAndTypeOnFileThread(origin, | |
| 587 fileapi::kFileSystemTypePersistent); | |
| 588 } | |
| 589 // TODO(mkwst): Else? Decide what to do for time-based deletion: crbug/63700 | |
| 590 } | |
| 591 | |
| 592 BrowserThread::PostTask( | 544 BrowserThread::PostTask( |
| 593 BrowserThread::UI, FROM_HERE, | 545 BrowserThread::UI, FROM_HERE, |
| 594 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedFileSystems)); | 546 NewRunnableMethod( |
| 595 } | 547 this, |
| 596 | 548 &BrowsingDataRemover::NotifyAndDeleteIfDone)); |
| 597 void BrowsingDataRemover::OnClearedFileSystems() { | |
| 598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 599 waiting_for_clear_file_systems_ = false; | |
| 600 NotifyAndDeleteIfDone(); | |
| 601 } | |
| 602 | |
| 603 // static | |
| 604 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { | |
| 605 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); | |
| 606 if (file_util::DirectoryExists(plugin_data)) | |
| 607 file_util::Delete(plugin_data, true); | |
| 608 } | |
| 609 | |
| 610 void BrowsingDataRemover::OnClearedGearsData() { | |
| 611 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
| 612 bool result = BrowserThread::PostTask( | |
| 613 BrowserThread::UI, FROM_HERE, | |
| 614 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedGearsData)); | |
| 615 DCHECK(result); | |
| 616 return; | |
| 617 } | |
| 618 waiting_for_clear_gears_data_ = false; | |
| 619 NotifyAndDeleteIfDone(); | |
| 620 } | |
| 621 | |
| 622 void BrowsingDataRemover::ClearGearsDataOnFILEThread( | |
| 623 const FilePath& profile_dir) { | |
| 624 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 625 DCHECK(waiting_for_clear_gears_data_); | |
| 626 | |
| 627 ClearGearsData(profile_dir); | |
| 628 OnClearedGearsData(); | |
| 629 } | 549 } |
| 630 | 550 |
| 631 void BrowsingDataRemover::OnWaitableEventSignaled( | 551 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 632 base::WaitableEvent* waitable_event) { | 552 base::WaitableEvent* waitable_event) { |
| 633 waiting_for_clear_lso_data_ = false; | 553 waiting_for_clear_lso_data_ = false; |
| 634 NotifyAndDeleteIfDone(); | 554 NotifyAndDeleteIfDone(); |
| 635 } | 555 } |
| OLD | NEW |