| Index: chrome/browser/browsing_data/browsing_data_remover.cc
|
| diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
|
| index b8d8e90462794d3024079c69694c53f5315dde74..14324baef683917b04d03062aa75c9e22063bf01 100644
|
| --- a/chrome/browser/browsing_data/browsing_data_remover.cc
|
| +++ b/chrome/browser/browsing_data/browsing_data_remover.cc
|
| @@ -78,6 +78,16 @@ using content::UserMetricsAction;
|
|
|
| bool BrowsingDataRemover::is_removing_ = false;
|
|
|
| +// Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask.
|
| +// Static.
|
| +bool DoesOriginMatchMask(int origin_set_mask,
|
| + const GURL& origin,
|
| + quota::SpecialStoragePolicy* special_storage_policy) {
|
| + return BrowsingDataHelper::DoesOriginMatchMask(
|
| + origin, origin_set_mask,
|
| + static_cast<ExtensionSpecialStoragePolicy*>(special_storage_policy));
|
| +}
|
| +
|
| BrowsingDataRemover::NotificationDetails::NotificationDetails()
|
| : removal_begin(base::Time()),
|
| removal_mask(-1),
|
| @@ -148,8 +158,6 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
|
| base::Time delete_begin,
|
| base::Time delete_end)
|
| : profile_(profile),
|
| - quota_manager_(NULL),
|
| - dom_storage_context_(NULL),
|
| special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
|
| delete_begin_(delete_begin),
|
| delete_end_(delete_end),
|
| @@ -165,7 +173,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
|
| waiting_for_clear_form_(false),
|
| waiting_for_clear_history_(false),
|
| waiting_for_clear_hostname_resolution_cache_(false),
|
| - waiting_for_clear_local_storage_(false),
|
| + waiting_for_clear_keyword_data_(false),
|
| waiting_for_clear_logged_in_predictor_(false),
|
| waiting_for_clear_nacl_cache_(false),
|
| waiting_for_clear_network_predictor_(false),
|
| @@ -174,10 +182,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
|
| waiting_for_clear_pnacl_cache_(false),
|
| waiting_for_clear_quota_managed_data_(false),
|
| waiting_for_clear_server_bound_certs_(false),
|
| - waiting_for_clear_session_storage_(false),
|
| - waiting_for_clear_shader_cache_(false),
|
| - waiting_for_clear_webrtc_identity_store_(false),
|
| - waiting_for_clear_keyword_data_(false),
|
| + waiting_for_clear_storage_partition_data_(false),
|
| remove_mask_(0),
|
| remove_origin_(GURL()),
|
| origin_set_mask_(0) {
|
| @@ -200,21 +205,6 @@ void BrowsingDataRemover::set_removing(bool is_removing) {
|
| is_removing_ = is_removing;
|
| }
|
|
|
| -// Static.
|
| -int BrowsingDataRemover::GenerateQuotaClientMask(int remove_mask) {
|
| - int quota_client_mask = 0;
|
| - if (remove_mask & BrowsingDataRemover::REMOVE_FILE_SYSTEMS)
|
| - quota_client_mask |= quota::QuotaClient::kFileSystem;
|
| - if (remove_mask & BrowsingDataRemover::REMOVE_WEBSQL)
|
| - quota_client_mask |= quota::QuotaClient::kDatabase;
|
| - if (remove_mask & BrowsingDataRemover::REMOVE_APPCACHE)
|
| - quota_client_mask |= quota::QuotaClient::kAppcache;
|
| - if (remove_mask & BrowsingDataRemover::REMOVE_INDEXEDDB)
|
| - quota_client_mask |= quota::QuotaClient::kIndexedDatabase;
|
| -
|
| - return quota_client_mask;
|
| -}
|
| -
|
| void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) {
|
| RemoveImpl(remove_mask, GURL(), origin_set_mask);
|
| }
|
| @@ -383,6 +373,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
|
| download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
|
| }
|
|
|
| + uint32 storage_partition_remove_mask = 0;
|
| +
|
| // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set,
|
| // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB
|
| // don't accidentally remove the cookies that are associated with the
|
| @@ -391,15 +383,10 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
|
| if (remove_mask & REMOVE_COOKIES &&
|
| origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
|
| content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
|
| - // Since we are running on the UI thread don't call GetURLRequestContext().
|
| - net::URLRequestContextGetter* rq_context = profile_->GetRequestContext();
|
| - if (rq_context) {
|
| - ++waiting_for_clear_cookies_count_;
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread,
|
| - base::Unretained(this), base::Unretained(rq_context)));
|
| - }
|
| +
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_COOKIES;
|
| +
|
| // Also delete the LoggedIn Predictor, which tries to keep track of which
|
| // sites a user is logged into.
|
| ClearLoggedInPredictor();
|
| @@ -443,29 +430,25 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
|
| }
|
|
|
| if (remove_mask & REMOVE_LOCAL_STORAGE) {
|
| - waiting_for_clear_local_storage_ = true;
|
| - waiting_for_clear_session_storage_ = true;
|
| - if (!dom_storage_context_) {
|
| - dom_storage_context_ =
|
| - BrowserContext::GetDefaultStoragePartition(profile_)->
|
| - GetDOMStorageContext();
|
| - }
|
| - ClearLocalStorageOnUIThread();
|
| - ClearSessionStorageOnUIThread();
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE;
|
| }
|
|
|
| - if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL ||
|
| - remove_mask & REMOVE_APPCACHE || remove_mask & REMOVE_FILE_SYSTEMS) {
|
| - if (!quota_manager_) {
|
| - quota_manager_ =
|
| - BrowserContext::GetDefaultStoragePartition(profile_)->
|
| - GetQuotaManager();
|
| - }
|
| - waiting_for_clear_quota_managed_data_ = true;
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO, FROM_HERE,
|
| - base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread,
|
| - base::Unretained(this)));
|
| + if (remove_mask & REMOVE_INDEXEDDB) {
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB;
|
| + }
|
| + if (remove_mask & REMOVE_WEBSQL) {
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_WEBSQL;
|
| + }
|
| + if (remove_mask & REMOVE_APPCACHE) {
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_APPCACHE;
|
| + }
|
| + if (remove_mask & REMOVE_FILE_SYSTEMS) {
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS;
|
| }
|
|
|
| #if defined(ENABLE_PLUGINS)
|
| @@ -561,18 +544,43 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
|
| }
|
|
|
| // Tell the shader disk cache to clear.
|
| - waiting_for_clear_shader_cache_ = true;
|
| content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache"));
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE;
|
| +
|
| + storage_partition_remove_mask |=
|
| + content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY;
|
| + }
|
| +
|
| + if (storage_partition_remove_mask) {
|
| + waiting_for_clear_storage_partition_data_ = true;
|
|
|
| - ClearShaderCacheOnUIThread();
|
| + content::StoragePartition* storage_partition;
|
| + if (storage_partition_for_testing_)
|
| + storage_partition = storage_partition_for_testing_;
|
| + else
|
| + storage_partition = BrowserContext::GetDefaultStoragePartition(profile_);
|
|
|
| - waiting_for_clear_webrtc_identity_store_ = true;
|
| - BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange(
|
| - content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY,
|
| - content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
|
| + uint32 quota_storage_remove_mask =
|
| + ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
|
| +
|
| + if (delete_begin_ == base::Time() ||
|
| + origin_set_mask_ &
|
| + (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) {
|
| + // If we're deleting since the beginning of time, or we're removing
|
| + // protected origins, then remove persistent quota data.
|
| + quota_storage_remove_mask |=
|
| + content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
|
| + }
|
| +
|
| + storage_partition->ClearData(
|
| + storage_partition_remove_mask,
|
| + quota_storage_remove_mask,
|
| + &remove_origin_,
|
| + base::Bind(&DoesOriginMatchMask, origin_set_mask_),
|
| delete_begin_,
|
| delete_end_,
|
| - base::Bind(&BrowsingDataRemover::OnClearWebRTCIdentityStore,
|
| + base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData,
|
| base::Unretained(this)));
|
| }
|
|
|
| @@ -613,9 +621,9 @@ void BrowsingDataRemover::OnHistoryDeletionDone() {
|
| NotifyAndDeleteIfDone();
|
| }
|
|
|
| -void BrowsingDataRemover::OverrideQuotaManagerForTesting(
|
| - quota::QuotaManager* quota_manager) {
|
| - quota_manager_ = quota_manager;
|
| +void BrowsingDataRemover::OverrideStoragePartitionForTesting(
|
| + content::StoragePartition* storage_partition) {
|
| + storage_partition_for_testing_ = storage_partition;
|
| }
|
|
|
| base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
|
| @@ -650,9 +658,7 @@ bool BrowsingDataRemover::AllDone() {
|
| !waiting_for_clear_autofill_origin_urls_ &&
|
| !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ &&
|
| !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ &&
|
| - !waiting_for_clear_local_storage_ &&
|
| !waiting_for_clear_logged_in_predictor_ &&
|
| - !waiting_for_clear_session_storage_ &&
|
| !waiting_for_clear_networking_history_ &&
|
| !waiting_for_clear_server_bound_certs_ &&
|
| !waiting_for_clear_plugin_data_ &&
|
| @@ -661,8 +667,7 @@ bool BrowsingDataRemover::AllDone() {
|
| !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ &&
|
| !waiting_for_clear_hostname_resolution_cache_ &&
|
| !waiting_for_clear_network_predictor_ &&
|
| - !waiting_for_clear_shader_cache_ &&
|
| - !waiting_for_clear_webrtc_identity_store_;
|
| + !waiting_for_clear_storage_partition_data_;
|
| }
|
|
|
| void BrowsingDataRemover::OnKeywordsLoaded() {
|
| @@ -868,24 +873,6 @@ void BrowsingDataRemover::DoClearCache(int rv) {
|
| }
|
| }
|
|
|
| -void BrowsingDataRemover::ClearedShaderCache() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - waiting_for_clear_shader_cache_ = false;
|
| - NotifyAndDeleteIfDone();
|
| -}
|
| -
|
| -void BrowsingDataRemover::ClearShaderCacheOnUIThread() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange(
|
| - content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
|
| - content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
|
| - delete_begin_, delete_end_,
|
| - base::Bind(&BrowsingDataRemover::ClearedShaderCache,
|
| - base::Unretained(this)));
|
| -}
|
| -
|
| #if !defined(DISABLE_NACL)
|
| void BrowsingDataRemover::ClearedNaClCache() {
|
| // This function should be called on the UI thread.
|
| @@ -946,156 +933,6 @@ void BrowsingDataRemover::ClearPnaclCacheOnIOThread(base::Time begin,
|
| }
|
| #endif
|
|
|
| -void BrowsingDataRemover::ClearLocalStorageOnUIThread() {
|
| - DCHECK(waiting_for_clear_local_storage_);
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - dom_storage_context_->GetLocalStorageUsage(
|
| - base::Bind(&BrowsingDataRemover::OnGotLocalStorageUsageInfo,
|
| - base::Unretained(this)));
|
| -}
|
| -
|
| -void BrowsingDataRemover::OnGotLocalStorageUsageInfo(
|
| - const std::vector<content::LocalStorageUsageInfo>& infos) {
|
| - DCHECK(waiting_for_clear_local_storage_);
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - for (size_t i = 0; i < infos.size(); ++i) {
|
| - if (!BrowsingDataHelper::DoesOriginMatchMask(
|
| - infos[i].origin, origin_set_mask_, special_storage_policy_.get()))
|
| - continue;
|
| -
|
| - if (infos[i].last_modified >= delete_begin_ &&
|
| - infos[i].last_modified <= delete_end_) {
|
| - dom_storage_context_->DeleteLocalStorage(infos[i].origin);
|
| - }
|
| - }
|
| - waiting_for_clear_local_storage_ = false;
|
| - NotifyAndDeleteIfDone();
|
| -}
|
| -
|
| -void BrowsingDataRemover::ClearSessionStorageOnUIThread() {
|
| - DCHECK(waiting_for_clear_session_storage_);
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - dom_storage_context_->GetSessionStorageUsage(
|
| - base::Bind(&BrowsingDataRemover::OnGotSessionStorageUsageInfo,
|
| - base::Unretained(this)));
|
| -}
|
| -
|
| -void BrowsingDataRemover::OnGotSessionStorageUsageInfo(
|
| - const std::vector<content::SessionStorageUsageInfo>& infos) {
|
| - DCHECK(waiting_for_clear_session_storage_);
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - for (size_t i = 0; i < infos.size(); ++i) {
|
| - if (!BrowsingDataHelper::DoesOriginMatchMask(
|
| - infos[i].origin, origin_set_mask_, special_storage_policy_.get()))
|
| - continue;
|
| -
|
| - dom_storage_context_->DeleteSessionStorage(infos[i]);
|
| - }
|
| - waiting_for_clear_session_storage_ = false;
|
| - NotifyAndDeleteIfDone();
|
| -}
|
| -
|
| -void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| -
|
| - // Ask the QuotaManager for all origins with temporary quota modified within
|
| - // the user-specified timeframe, and deal with the resulting set in
|
| - // OnGotQuotaManagedOrigins().
|
| - quota_managed_origins_to_delete_count_ = 0;
|
| - quota_managed_storage_types_to_delete_count_ = 0;
|
| -
|
| - if (delete_begin_ == base::Time() ||
|
| - origin_set_mask_ &
|
| - (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) {
|
| - // If we're deleting since the beginning of time, or we're removing
|
| - // protected origins, then ask the QuotaManager for all origins with
|
| - // persistent quota modified within the user-specified timeframe, and deal
|
| - // with the resulting set in OnGotQuotaManagedOrigins.
|
| - ++quota_managed_storage_types_to_delete_count_;
|
| - quota_manager_->GetOriginsModifiedSince(
|
| - quota::kStorageTypePersistent, delete_begin_,
|
| - base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
|
| - base::Unretained(this)));
|
| - }
|
| -
|
| - // Do the same for temporary quota.
|
| - ++quota_managed_storage_types_to_delete_count_;
|
| - quota_manager_->GetOriginsModifiedSince(
|
| - quota::kStorageTypeTemporary, delete_begin_,
|
| - base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
|
| - base::Unretained(this)));
|
| -
|
| - // Do the same for syncable quota.
|
| - ++quota_managed_storage_types_to_delete_count_;
|
| - quota_manager_->GetOriginsModifiedSince(
|
| - quota::kStorageTypeSyncable, delete_begin_,
|
| - base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
|
| - base::Unretained(this)));
|
| -}
|
| -
|
| -void BrowsingDataRemover::OnGotQuotaManagedOrigins(
|
| - const std::set<GURL>& origins, quota::StorageType type) {
|
| - DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0);
|
| - // Walk through the origins passed in, delete quota of |type| from each that
|
| - // matches the |origin_set_mask_|.
|
| - std::set<GURL>::const_iterator origin;
|
| - for (origin = origins.begin(); origin != origins.end(); ++origin) {
|
| - // TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746
|
| - if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin())
|
| - continue;
|
| -
|
| - if (!BrowsingDataHelper::DoesOriginMatchMask(origin->GetOrigin(),
|
| - origin_set_mask_,
|
| - special_storage_policy_.get()))
|
| - continue;
|
| -
|
| - ++quota_managed_origins_to_delete_count_;
|
| - quota_manager_->DeleteOriginData(
|
| - origin->GetOrigin(), type,
|
| - BrowsingDataRemover::GenerateQuotaClientMask(remove_mask_),
|
| - base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion,
|
| - base::Unretained(this), origin->GetOrigin(), type));
|
| - }
|
| -
|
| - --quota_managed_storage_types_to_delete_count_;
|
| - CheckQuotaManagedDataDeletionStatus();
|
| -}
|
| -
|
| -void BrowsingDataRemover::OnQuotaManagedOriginDeletion(
|
| - const GURL& origin,
|
| - quota::StorageType type,
|
| - quota::QuotaStatusCode status) {
|
| - DCHECK_GT(quota_managed_origins_to_delete_count_, 0);
|
| - if (status != quota::kQuotaStatusOk) {
|
| - DLOG(ERROR) << "Couldn't remove data of type " << type << " for origin "
|
| - << origin << ". Status: " << status;
|
| - }
|
| -
|
| - --quota_managed_origins_to_delete_count_;
|
| - CheckQuotaManagedDataDeletionStatus();
|
| -}
|
| -
|
| -void BrowsingDataRemover::CheckQuotaManagedDataDeletionStatus() {
|
| - if (quota_managed_storage_types_to_delete_count_ != 0 ||
|
| - quota_managed_origins_to_delete_count_ != 0) {
|
| - return;
|
| - }
|
| -
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&BrowsingDataRemover::OnQuotaManagedDataDeleted,
|
| - base::Unretained(this)));
|
| -}
|
| -
|
| -void BrowsingDataRemover::OnQuotaManagedDataDeleted() {
|
| - DCHECK(waiting_for_clear_quota_managed_data_);
|
| - waiting_for_clear_quota_managed_data_ = false;
|
| - NotifyAndDeleteIfDone();
|
| -}
|
| -
|
| void BrowsingDataRemover::OnWaitableEventSignaled(
|
| base::WaitableEvent* waitable_event) {
|
| waiting_for_clear_plugin_data_ = false;
|
| @@ -1182,8 +1019,8 @@ void BrowsingDataRemover::OnClearedAutofillOriginURLs() {
|
| NotifyAndDeleteIfDone();
|
| }
|
|
|
| -void BrowsingDataRemover::OnClearWebRTCIdentityStore() {
|
| +void BrowsingDataRemover::OnClearedStoragePartitionData() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - waiting_for_clear_webrtc_identity_store_ = false;
|
| + waiting_for_clear_storage_partition_data_ = false;
|
| NotifyAndDeleteIfDone();
|
| }
|
|
|