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

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

Issue 37843003: BrowsingDataRemover, (re)use StoragePartition deletion code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combine functions. 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 #include "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "webkit/browser/quota/special_storage_policy.h" 71 #include "webkit/browser/quota/special_storage_policy.h"
72 #include "webkit/common/quota/quota_types.h" 72 #include "webkit/common/quota/quota_types.h"
73 73
74 using content::BrowserContext; 74 using content::BrowserContext;
75 using content::BrowserThread; 75 using content::BrowserThread;
76 using content::DOMStorageContext; 76 using content::DOMStorageContext;
77 using content::UserMetricsAction; 77 using content::UserMetricsAction;
78 78
79 bool BrowsingDataRemover::is_removing_ = false; 79 bool BrowsingDataRemover::is_removing_ = false;
80 80
81 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask.
82 // Static.
83 bool DoesOriginMatchMask(int origin_set_mask,
84 const GURL& origin,
85 quota::SpecialStoragePolicy* special_storage_policy) {
86 return BrowsingDataHelper::DoesOriginMatchMask(
87 origin, origin_set_mask,
88 static_cast<ExtensionSpecialStoragePolicy*>(special_storage_policy));
89 }
90
81 BrowsingDataRemover::NotificationDetails::NotificationDetails() 91 BrowsingDataRemover::NotificationDetails::NotificationDetails()
82 : removal_begin(base::Time()), 92 : removal_begin(base::Time()),
83 removal_mask(-1), 93 removal_mask(-1),
84 origin_set_mask(-1) { 94 origin_set_mask(-1) {
85 } 95 }
86 96
87 BrowsingDataRemover::NotificationDetails::NotificationDetails( 97 BrowsingDataRemover::NotificationDetails::NotificationDetails(
88 const BrowsingDataRemover::NotificationDetails& details) 98 const BrowsingDataRemover::NotificationDetails& details)
89 : removal_begin(details.removal_begin), 99 : removal_begin(details.removal_begin),
90 removal_mask(details.removal_mask), 100 removal_mask(details.removal_mask),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 151 }
142 return new BrowsingDataRemover(profile, 152 return new BrowsingDataRemover(profile,
143 BrowsingDataRemover::CalculateBeginDeleteTime(period), 153 BrowsingDataRemover::CalculateBeginDeleteTime(period),
144 base::Time::Max()); 154 base::Time::Max());
145 } 155 }
146 156
147 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, 157 BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
148 base::Time delete_begin, 158 base::Time delete_begin,
149 base::Time delete_end) 159 base::Time delete_end)
150 : profile_(profile), 160 : profile_(profile),
151 quota_manager_(NULL),
152 dom_storage_context_(NULL),
153 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), 161 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
154 delete_begin_(delete_begin), 162 delete_begin_(delete_begin),
155 delete_end_(delete_end), 163 delete_end_(delete_end),
156 next_cache_state_(STATE_NONE), 164 next_cache_state_(STATE_NONE),
157 cache_(NULL), 165 cache_(NULL),
158 main_context_getter_(profile->GetRequestContext()), 166 main_context_getter_(profile->GetRequestContext()),
159 media_context_getter_(profile->GetMediaRequestContext()), 167 media_context_getter_(profile->GetMediaRequestContext()),
160 deauthorize_content_licenses_request_id_(0), 168 deauthorize_content_licenses_request_id_(0),
161 waiting_for_clear_autofill_origin_urls_(false), 169 waiting_for_clear_autofill_origin_urls_(false),
162 waiting_for_clear_cache_(false), 170 waiting_for_clear_cache_(false),
163 waiting_for_clear_content_licenses_(false), 171 waiting_for_clear_content_licenses_(false),
164 waiting_for_clear_cookies_count_(0), 172 waiting_for_clear_cookies_count_(0),
165 waiting_for_clear_form_(false), 173 waiting_for_clear_form_(false),
166 waiting_for_clear_history_(false), 174 waiting_for_clear_history_(false),
167 waiting_for_clear_hostname_resolution_cache_(false), 175 waiting_for_clear_hostname_resolution_cache_(false),
168 waiting_for_clear_local_storage_(false), 176 waiting_for_clear_keyword_data_(false),
169 waiting_for_clear_logged_in_predictor_(false), 177 waiting_for_clear_logged_in_predictor_(false),
170 waiting_for_clear_nacl_cache_(false), 178 waiting_for_clear_nacl_cache_(false),
171 waiting_for_clear_network_predictor_(false), 179 waiting_for_clear_network_predictor_(false),
172 waiting_for_clear_networking_history_(false), 180 waiting_for_clear_networking_history_(false),
173 waiting_for_clear_plugin_data_(false), 181 waiting_for_clear_plugin_data_(false),
174 waiting_for_clear_pnacl_cache_(false), 182 waiting_for_clear_pnacl_cache_(false),
175 waiting_for_clear_quota_managed_data_(false), 183 waiting_for_clear_quota_managed_data_(false),
176 waiting_for_clear_server_bound_certs_(false), 184 waiting_for_clear_server_bound_certs_(false),
177 waiting_for_clear_session_storage_(false), 185 waiting_for_clear_storage_partition_data_(false),
178 waiting_for_clear_shader_cache_(false),
179 waiting_for_clear_webrtc_identity_store_(false),
180 waiting_for_clear_keyword_data_(false),
181 remove_mask_(0), 186 remove_mask_(0),
182 remove_origin_(GURL()), 187 remove_origin_(GURL()),
183 origin_set_mask_(0) { 188 origin_set_mask_(0) {
184 DCHECK(profile); 189 DCHECK(profile);
185 // crbug.com/140910: Many places were calling this with base::Time() as 190 // crbug.com/140910: Many places were calling this with base::Time() as
186 // delete_end, even though they should've used base::Time::Max(). Work around 191 // delete_end, even though they should've used base::Time::Max(). Work around
187 // it here. New code should use base::Time::Max(). 192 // it here. New code should use base::Time::Max().
188 DCHECK(delete_end_ != base::Time()); 193 DCHECK(delete_end_ != base::Time());
189 if (delete_end_ == base::Time()) 194 if (delete_end_ == base::Time())
190 delete_end_ = base::Time::Max(); 195 delete_end_ = base::Time::Max();
191 } 196 }
192 197
193 BrowsingDataRemover::~BrowsingDataRemover() { 198 BrowsingDataRemover::~BrowsingDataRemover() {
194 DCHECK(AllDone()); 199 DCHECK(AllDone());
195 } 200 }
196 201
197 // Static. 202 // Static.
198 void BrowsingDataRemover::set_removing(bool is_removing) { 203 void BrowsingDataRemover::set_removing(bool is_removing) {
199 DCHECK(is_removing_ != is_removing); 204 DCHECK(is_removing_ != is_removing);
200 is_removing_ = is_removing; 205 is_removing_ = is_removing;
201 } 206 }
202 207
203 // Static.
204 int BrowsingDataRemover::GenerateQuotaClientMask(int remove_mask) {
205 int quota_client_mask = 0;
206 if (remove_mask & BrowsingDataRemover::REMOVE_FILE_SYSTEMS)
207 quota_client_mask |= quota::QuotaClient::kFileSystem;
208 if (remove_mask & BrowsingDataRemover::REMOVE_WEBSQL)
209 quota_client_mask |= quota::QuotaClient::kDatabase;
210 if (remove_mask & BrowsingDataRemover::REMOVE_APPCACHE)
211 quota_client_mask |= quota::QuotaClient::kAppcache;
212 if (remove_mask & BrowsingDataRemover::REMOVE_INDEXEDDB)
213 quota_client_mask |= quota::QuotaClient::kIndexedDatabase;
214
215 return quota_client_mask;
216 }
217
218 void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) { 208 void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) {
219 RemoveImpl(remove_mask, GURL(), origin_set_mask); 209 RemoveImpl(remove_mask, GURL(), origin_set_mask);
220 } 210 }
221 211
222 void BrowsingDataRemover::RemoveImpl(int remove_mask, 212 void BrowsingDataRemover::RemoveImpl(int remove_mask,
223 const GURL& origin, 213 const GURL& origin,
224 int origin_set_mask) { 214 int origin_set_mask) {
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
226 set_removing(true); 216 set_removing(true);
227 remove_mask_ = remove_mask; 217 remove_mask_ = remove_mask;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { 366 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) {
377 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); 367 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"));
378 content::DownloadManager* download_manager = 368 content::DownloadManager* download_manager =
379 BrowserContext::GetDownloadManager(profile_); 369 BrowserContext::GetDownloadManager(profile_);
380 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); 370 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_);
381 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( 371 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
382 download_manager); 372 download_manager);
383 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); 373 download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
384 } 374 }
385 375
376 uint32 storage_partition_remove_mask = 0;
377
386 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, 378 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set,
387 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB 379 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB
388 // don't accidentally remove the cookies that are associated with the 380 // don't accidentally remove the cookies that are associated with the
389 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated 381 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated
390 // between UNPROTECTED_WEB and PROTECTED_WEB. 382 // between UNPROTECTED_WEB and PROTECTED_WEB.
391 if (remove_mask & REMOVE_COOKIES && 383 if (remove_mask & REMOVE_COOKIES &&
392 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { 384 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
393 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); 385 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
394 // Since we are running on the UI thread don't call GetURLRequestContext(). 386
395 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); 387 storage_partition_remove_mask |=
396 if (rq_context) { 388 content::StoragePartition::REMOVE_DATA_MASK_COOKIES;
397 ++waiting_for_clear_cookies_count_; 389
398 BrowserThread::PostTask(
399 BrowserThread::IO, FROM_HERE,
400 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread,
401 base::Unretained(this), base::Unretained(rq_context)));
402 }
403 // Also delete the LoggedIn Predictor, which tries to keep track of which 390 // Also delete the LoggedIn Predictor, which tries to keep track of which
404 // sites a user is logged into. 391 // sites a user is logged into.
405 ClearLoggedInPredictor(); 392 ClearLoggedInPredictor();
406 393
407 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 394 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
408 // Clear the safebrowsing cookies only if time period is for "all time". It 395 // Clear the safebrowsing cookies only if time period is for "all time". It
409 // doesn't make sense to apply the time period of deleting in the last X 396 // doesn't make sense to apply the time period of deleting in the last X
410 // hours/days to the safebrowsing cookies since they aren't the result of 397 // hours/days to the safebrowsing cookies since they aren't the result of
411 // any user action. 398 // any user action.
412 if (delete_begin_ == base::Time()) { 399 if (delete_begin_ == base::Time()) {
(...skipping 23 matching lines...) Expand all
436 if (rq_context) { 423 if (rq_context) {
437 waiting_for_clear_server_bound_certs_ = true; 424 waiting_for_clear_server_bound_certs_ = true;
438 BrowserThread::PostTask( 425 BrowserThread::PostTask(
439 BrowserThread::IO, FROM_HERE, 426 BrowserThread::IO, FROM_HERE,
440 base::Bind(&BrowsingDataRemover::ClearServerBoundCertsOnIOThread, 427 base::Bind(&BrowsingDataRemover::ClearServerBoundCertsOnIOThread,
441 base::Unretained(this), base::Unretained(rq_context))); 428 base::Unretained(this), base::Unretained(rq_context)));
442 } 429 }
443 } 430 }
444 431
445 if (remove_mask & REMOVE_LOCAL_STORAGE) { 432 if (remove_mask & REMOVE_LOCAL_STORAGE) {
446 waiting_for_clear_local_storage_ = true; 433 storage_partition_remove_mask |=
447 waiting_for_clear_session_storage_ = true; 434 content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE;
448 if (!dom_storage_context_) {
449 dom_storage_context_ =
450 BrowserContext::GetDefaultStoragePartition(profile_)->
451 GetDOMStorageContext();
452 }
453 ClearLocalStorageOnUIThread();
454 ClearSessionStorageOnUIThread();
455 } 435 }
456 436
457 if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL || 437 if (remove_mask & REMOVE_INDEXEDDB) {
458 remove_mask & REMOVE_APPCACHE || remove_mask & REMOVE_FILE_SYSTEMS) { 438 storage_partition_remove_mask |=
459 if (!quota_manager_) { 439 content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB;
460 quota_manager_ = 440 }
461 BrowserContext::GetDefaultStoragePartition(profile_)-> 441 if (remove_mask & REMOVE_WEBSQL) {
462 GetQuotaManager(); 442 storage_partition_remove_mask |=
463 } 443 content::StoragePartition::REMOVE_DATA_MASK_WEBSQL;
464 waiting_for_clear_quota_managed_data_ = true; 444 }
465 BrowserThread::PostTask( 445 if (remove_mask & REMOVE_APPCACHE) {
466 BrowserThread::IO, FROM_HERE, 446 storage_partition_remove_mask |=
467 base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread, 447 content::StoragePartition::REMOVE_DATA_MASK_APPCACHE;
468 base::Unretained(this))); 448 }
449 if (remove_mask & REMOVE_FILE_SYSTEMS) {
450 storage_partition_remove_mask |=
451 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS;
469 } 452 }
470 453
471 #if defined(ENABLE_PLUGINS) 454 #if defined(ENABLE_PLUGINS)
472 // Plugin is data not separated for protected and unprotected web origins. We 455 // Plugin is data not separated for protected and unprotected web origins. We
473 // check the origin_set_mask_ to prevent unintended deletion. 456 // check the origin_set_mask_ to prevent unintended deletion.
474 if (remove_mask & REMOVE_PLUGIN_DATA && 457 if (remove_mask & REMOVE_PLUGIN_DATA &&
475 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { 458 origin_set_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
476 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); 459 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData"));
477 460
478 waiting_for_clear_plugin_data_ = true; 461 waiting_for_clear_plugin_data_ = true;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 // The PrerenderManager may have a page actively being prerendered, which 537 // The PrerenderManager may have a page actively being prerendered, which
555 // is essentially a preemptively cached page. 538 // is essentially a preemptively cached page.
556 prerender::PrerenderManager* prerender_manager = 539 prerender::PrerenderManager* prerender_manager =
557 prerender::PrerenderManagerFactory::GetForProfile(profile_); 540 prerender::PrerenderManagerFactory::GetForProfile(profile_);
558 if (prerender_manager) { 541 if (prerender_manager) {
559 prerender_manager->ClearData( 542 prerender_manager->ClearData(
560 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS); 543 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS);
561 } 544 }
562 545
563 // Tell the shader disk cache to clear. 546 // Tell the shader disk cache to clear.
564 waiting_for_clear_shader_cache_ = true;
565 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); 547 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache"));
548 storage_partition_remove_mask |=
549 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE;
566 550
567 ClearShaderCacheOnUIThread(); 551 storage_partition_remove_mask |=
552 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY;
553 }
568 554
569 waiting_for_clear_webrtc_identity_store_ = true; 555 if (storage_partition_remove_mask) {
570 BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange( 556 waiting_for_clear_storage_partition_data_ = true;
571 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY, 557
572 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, 558 content::StoragePartition* storage_partition;
559 if (storage_partition_for_testing_)
560 storage_partition = storage_partition_for_testing_;
561 else
562 storage_partition = BrowserContext::GetDefaultStoragePartition(profile_);
563
564 uint32 quota_storage_remove_mask =
565 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
566
567 if (delete_begin_ == base::Time() ||
568 origin_set_mask_ &
569 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) {
570 // If we're deleting since the beginning of time, or we're removing
571 // protected origins, then remove persistent quota data.
572 quota_storage_remove_mask |=
573 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
574 }
575
576 storage_partition->ClearData(
577 storage_partition_remove_mask,
578 quota_storage_remove_mask,
579 &remove_origin_,
580 base::Bind(&DoesOriginMatchMask, origin_set_mask_),
573 delete_begin_, 581 delete_begin_,
574 delete_end_, 582 delete_end_,
575 base::Bind(&BrowsingDataRemover::OnClearWebRTCIdentityStore, 583 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData,
576 base::Unretained(this))); 584 base::Unretained(this)));
577 } 585 }
578 586
579 #if defined(ENABLE_PLUGINS) 587 #if defined(ENABLE_PLUGINS)
580 if (remove_mask & REMOVE_CONTENT_LICENSES) { 588 if (remove_mask & REMOVE_CONTENT_LICENSES) {
581 content::RecordAction( 589 content::RecordAction(
582 UserMetricsAction("ClearBrowsingData_ContentLicenses")); 590 UserMetricsAction("ClearBrowsingData_ContentLicenses"));
583 591
584 waiting_for_clear_content_licenses_ = true; 592 waiting_for_clear_content_licenses_ = true;
585 if (!pepper_flash_settings_manager_.get()) { 593 if (!pepper_flash_settings_manager_.get()) {
(...skipping 20 matching lines...) Expand all
606 614
607 void BrowsingDataRemover::RemoveObserver(Observer* observer) { 615 void BrowsingDataRemover::RemoveObserver(Observer* observer) {
608 observer_list_.RemoveObserver(observer); 616 observer_list_.RemoveObserver(observer);
609 } 617 }
610 618
611 void BrowsingDataRemover::OnHistoryDeletionDone() { 619 void BrowsingDataRemover::OnHistoryDeletionDone() {
612 waiting_for_clear_history_ = false; 620 waiting_for_clear_history_ = false;
613 NotifyAndDeleteIfDone(); 621 NotifyAndDeleteIfDone();
614 } 622 }
615 623
616 void BrowsingDataRemover::OverrideQuotaManagerForTesting( 624 void BrowsingDataRemover::OverrideStoragePartitionForTesting(
617 quota::QuotaManager* quota_manager) { 625 content::StoragePartition* storage_partition) {
618 quota_manager_ = quota_manager; 626 storage_partition_for_testing_ = storage_partition;
619 } 627 }
620 628
621 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( 629 base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
622 TimePeriod time_period) { 630 TimePeriod time_period) {
623 base::TimeDelta diff; 631 base::TimeDelta diff;
624 base::Time delete_begin_time = base::Time::Now(); 632 base::Time delete_begin_time = base::Time::Now();
625 switch (time_period) { 633 switch (time_period) {
626 case LAST_HOUR: 634 case LAST_HOUR:
627 diff = base::TimeDelta::FromHours(1); 635 diff = base::TimeDelta::FromHours(1);
628 break; 636 break;
(...skipping 14 matching lines...) Expand all
643 break; 651 break;
644 } 652 }
645 return delete_begin_time - diff; 653 return delete_begin_time - diff;
646 } 654 }
647 655
648 bool BrowsingDataRemover::AllDone() { 656 bool BrowsingDataRemover::AllDone() {
649 return !waiting_for_clear_keyword_data_ && 657 return !waiting_for_clear_keyword_data_ &&
650 !waiting_for_clear_autofill_origin_urls_ && 658 !waiting_for_clear_autofill_origin_urls_ &&
651 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ && 659 !waiting_for_clear_cache_ && !waiting_for_clear_nacl_cache_ &&
652 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ && 660 !waiting_for_clear_cookies_count_ && !waiting_for_clear_history_ &&
653 !waiting_for_clear_local_storage_ &&
654 !waiting_for_clear_logged_in_predictor_ && 661 !waiting_for_clear_logged_in_predictor_ &&
655 !waiting_for_clear_session_storage_ &&
656 !waiting_for_clear_networking_history_ && 662 !waiting_for_clear_networking_history_ &&
657 !waiting_for_clear_server_bound_certs_ && 663 !waiting_for_clear_server_bound_certs_ &&
658 !waiting_for_clear_plugin_data_ && 664 !waiting_for_clear_plugin_data_ &&
659 !waiting_for_clear_pnacl_cache_ && 665 !waiting_for_clear_pnacl_cache_ &&
660 !waiting_for_clear_quota_managed_data_ && 666 !waiting_for_clear_quota_managed_data_ &&
661 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ && 667 !waiting_for_clear_content_licenses_ && !waiting_for_clear_form_ &&
662 !waiting_for_clear_hostname_resolution_cache_ && 668 !waiting_for_clear_hostname_resolution_cache_ &&
663 !waiting_for_clear_network_predictor_ && 669 !waiting_for_clear_network_predictor_ &&
664 !waiting_for_clear_shader_cache_ && 670 !waiting_for_clear_storage_partition_data_;
665 !waiting_for_clear_webrtc_identity_store_;
666 } 671 }
667 672
668 void BrowsingDataRemover::OnKeywordsLoaded() { 673 void BrowsingDataRemover::OnKeywordsLoaded() {
669 // Deletes the entries from the model, and if we're not waiting on anything 674 // Deletes the entries from the model, and if we're not waiting on anything
670 // else notifies observers and deletes this BrowsingDataRemover. 675 // else notifies observers and deletes this BrowsingDataRemover.
671 TemplateURLService* model = 676 TemplateURLService* model =
672 TemplateURLServiceFactory::GetForProfile(profile_); 677 TemplateURLServiceFactory::GetForProfile(profile_);
673 DCHECK_EQ(profile_, model->profile()); 678 DCHECK_EQ(profile_, model->profile());
674 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); 679 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
675 waiting_for_clear_keyword_data_ = false; 680 waiting_for_clear_keyword_data_ = false;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 866 }
862 default: { 867 default: {
863 NOTREACHED() << "bad state"; 868 NOTREACHED() << "bad state";
864 next_cache_state_ = STATE_NONE; // Stop looping. 869 next_cache_state_ = STATE_NONE; // Stop looping.
865 return; 870 return;
866 } 871 }
867 } 872 }
868 } 873 }
869 } 874 }
870 875
871 void BrowsingDataRemover::ClearedShaderCache() {
872 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
873
874 waiting_for_clear_shader_cache_ = false;
875 NotifyAndDeleteIfDone();
876 }
877
878 void BrowsingDataRemover::ClearShaderCacheOnUIThread() {
879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
880
881 BrowserContext::GetDefaultStoragePartition(profile_)->ClearDataForRange(
882 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
883 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
884 delete_begin_, delete_end_,
885 base::Bind(&BrowsingDataRemover::ClearedShaderCache,
886 base::Unretained(this)));
887 }
888
889 #if !defined(DISABLE_NACL) 876 #if !defined(DISABLE_NACL)
890 void BrowsingDataRemover::ClearedNaClCache() { 877 void BrowsingDataRemover::ClearedNaClCache() {
891 // This function should be called on the UI thread. 878 // This function should be called on the UI thread.
892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
893 880
894 waiting_for_clear_nacl_cache_ = false; 881 waiting_for_clear_nacl_cache_ = false;
895 882
896 NotifyAndDeleteIfDone(); 883 NotifyAndDeleteIfDone();
897 } 884 }
898 885
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 base::Time end) { 926 base::Time end) {
940 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 927 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
941 928
942 PnaclHost::GetInstance()->ClearTranslationCacheEntriesBetween( 929 PnaclHost::GetInstance()->ClearTranslationCacheEntriesBetween(
943 begin, end, 930 begin, end,
944 base::Bind(&BrowsingDataRemover::ClearedPnaclCacheOnIOThread, 931 base::Bind(&BrowsingDataRemover::ClearedPnaclCacheOnIOThread,
945 base::Unretained(this))); 932 base::Unretained(this)));
946 } 933 }
947 #endif 934 #endif
948 935
949 void BrowsingDataRemover::ClearLocalStorageOnUIThread() {
950 DCHECK(waiting_for_clear_local_storage_);
951 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
952 dom_storage_context_->GetLocalStorageUsage(
953 base::Bind(&BrowsingDataRemover::OnGotLocalStorageUsageInfo,
954 base::Unretained(this)));
955 }
956
957 void BrowsingDataRemover::OnGotLocalStorageUsageInfo(
958 const std::vector<content::LocalStorageUsageInfo>& infos) {
959 DCHECK(waiting_for_clear_local_storage_);
960 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
961
962 for (size_t i = 0; i < infos.size(); ++i) {
963 if (!BrowsingDataHelper::DoesOriginMatchMask(
964 infos[i].origin, origin_set_mask_, special_storage_policy_.get()))
965 continue;
966
967 if (infos[i].last_modified >= delete_begin_ &&
968 infos[i].last_modified <= delete_end_) {
969 dom_storage_context_->DeleteLocalStorage(infos[i].origin);
970 }
971 }
972 waiting_for_clear_local_storage_ = false;
973 NotifyAndDeleteIfDone();
974 }
975
976 void BrowsingDataRemover::ClearSessionStorageOnUIThread() {
977 DCHECK(waiting_for_clear_session_storage_);
978 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
979
980 dom_storage_context_->GetSessionStorageUsage(
981 base::Bind(&BrowsingDataRemover::OnGotSessionStorageUsageInfo,
982 base::Unretained(this)));
983 }
984
985 void BrowsingDataRemover::OnGotSessionStorageUsageInfo(
986 const std::vector<content::SessionStorageUsageInfo>& infos) {
987 DCHECK(waiting_for_clear_session_storage_);
988 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
989
990 for (size_t i = 0; i < infos.size(); ++i) {
991 if (!BrowsingDataHelper::DoesOriginMatchMask(
992 infos[i].origin, origin_set_mask_, special_storage_policy_.get()))
993 continue;
994
995 dom_storage_context_->DeleteSessionStorage(infos[i]);
996 }
997 waiting_for_clear_session_storage_ = false;
998 NotifyAndDeleteIfDone();
999 }
1000
1001 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() {
1002 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1003
1004 // Ask the QuotaManager for all origins with temporary quota modified within
1005 // the user-specified timeframe, and deal with the resulting set in
1006 // OnGotQuotaManagedOrigins().
1007 quota_managed_origins_to_delete_count_ = 0;
1008 quota_managed_storage_types_to_delete_count_ = 0;
1009
1010 if (delete_begin_ == base::Time() ||
1011 origin_set_mask_ &
1012 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) {
1013 // If we're deleting since the beginning of time, or we're removing
1014 // protected origins, then ask the QuotaManager for all origins with
1015 // persistent quota modified within the user-specified timeframe, and deal
1016 // with the resulting set in OnGotQuotaManagedOrigins.
1017 ++quota_managed_storage_types_to_delete_count_;
1018 quota_manager_->GetOriginsModifiedSince(
1019 quota::kStorageTypePersistent, delete_begin_,
1020 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
1021 base::Unretained(this)));
1022 }
1023
1024 // Do the same for temporary quota.
1025 ++quota_managed_storage_types_to_delete_count_;
1026 quota_manager_->GetOriginsModifiedSince(
1027 quota::kStorageTypeTemporary, delete_begin_,
1028 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
1029 base::Unretained(this)));
1030
1031 // Do the same for syncable quota.
1032 ++quota_managed_storage_types_to_delete_count_;
1033 quota_manager_->GetOriginsModifiedSince(
1034 quota::kStorageTypeSyncable, delete_begin_,
1035 base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
1036 base::Unretained(this)));
1037 }
1038
1039 void BrowsingDataRemover::OnGotQuotaManagedOrigins(
1040 const std::set<GURL>& origins, quota::StorageType type) {
1041 DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0);
1042 // Walk through the origins passed in, delete quota of |type| from each that
1043 // matches the |origin_set_mask_|.
1044 std::set<GURL>::const_iterator origin;
1045 for (origin = origins.begin(); origin != origins.end(); ++origin) {
1046 // TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746
1047 if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin())
1048 continue;
1049
1050 if (!BrowsingDataHelper::DoesOriginMatchMask(origin->GetOrigin(),
1051 origin_set_mask_,
1052 special_storage_policy_.get()))
1053 continue;
1054
1055 ++quota_managed_origins_to_delete_count_;
1056 quota_manager_->DeleteOriginData(
1057 origin->GetOrigin(), type,
1058 BrowsingDataRemover::GenerateQuotaClientMask(remove_mask_),
1059 base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion,
1060 base::Unretained(this), origin->GetOrigin(), type));
1061 }
1062
1063 --quota_managed_storage_types_to_delete_count_;
1064 CheckQuotaManagedDataDeletionStatus();
1065 }
1066
1067 void BrowsingDataRemover::OnQuotaManagedOriginDeletion(
1068 const GURL& origin,
1069 quota::StorageType type,
1070 quota::QuotaStatusCode status) {
1071 DCHECK_GT(quota_managed_origins_to_delete_count_, 0);
1072 if (status != quota::kQuotaStatusOk) {
1073 DLOG(ERROR) << "Couldn't remove data of type " << type << " for origin "
1074 << origin << ". Status: " << status;
1075 }
1076
1077 --quota_managed_origins_to_delete_count_;
1078 CheckQuotaManagedDataDeletionStatus();
1079 }
1080
1081 void BrowsingDataRemover::CheckQuotaManagedDataDeletionStatus() {
1082 if (quota_managed_storage_types_to_delete_count_ != 0 ||
1083 quota_managed_origins_to_delete_count_ != 0) {
1084 return;
1085 }
1086
1087 BrowserThread::PostTask(
1088 BrowserThread::UI, FROM_HERE,
1089 base::Bind(&BrowsingDataRemover::OnQuotaManagedDataDeleted,
1090 base::Unretained(this)));
1091 }
1092
1093 void BrowsingDataRemover::OnQuotaManagedDataDeleted() {
1094 DCHECK(waiting_for_clear_quota_managed_data_);
1095 waiting_for_clear_quota_managed_data_ = false;
1096 NotifyAndDeleteIfDone();
1097 }
1098
1099 void BrowsingDataRemover::OnWaitableEventSignaled( 936 void BrowsingDataRemover::OnWaitableEventSignaled(
1100 base::WaitableEvent* waitable_event) { 937 base::WaitableEvent* waitable_event) {
1101 waiting_for_clear_plugin_data_ = false; 938 waiting_for_clear_plugin_data_ = false;
1102 NotifyAndDeleteIfDone(); 939 NotifyAndDeleteIfDone();
1103 } 940 }
1104 941
1105 #if defined(ENABLE_PLUGINS) 942 #if defined(ENABLE_PLUGINS)
1106 void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted( 943 void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted(
1107 uint32 request_id, 944 uint32 request_id,
1108 bool /* success */) { 945 bool /* success */) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 waiting_for_clear_form_ = false; 1012 waiting_for_clear_form_ = false;
1176 NotifyAndDeleteIfDone(); 1013 NotifyAndDeleteIfDone();
1177 } 1014 }
1178 1015
1179 void BrowsingDataRemover::OnClearedAutofillOriginURLs() { 1016 void BrowsingDataRemover::OnClearedAutofillOriginURLs() {
1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1017 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1181 waiting_for_clear_autofill_origin_urls_ = false; 1018 waiting_for_clear_autofill_origin_urls_ = false;
1182 NotifyAndDeleteIfDone(); 1019 NotifyAndDeleteIfDone();
1183 } 1020 }
1184 1021
1185 void BrowsingDataRemover::OnClearWebRTCIdentityStore() { 1022 void BrowsingDataRemover::OnClearedStoragePartitionData() {
1186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1023 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1187 waiting_for_clear_webrtc_identity_store_ = false; 1024 waiting_for_clear_storage_partition_data_ = false;
1188 NotifyAndDeleteIfDone(); 1025 NotifyAndDeleteIfDone();
1189 } 1026 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698