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

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

Issue 10866013: Convert the browsing_data pyauto tests to chrome tests. Remove the ClearBrowsingData automation cod… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix flake in unittest harness Created 8 years, 4 months 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 | Annotate | Revision Log
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 waiting_for_clear_cache_(false), 118 waiting_for_clear_cache_(false),
119 waiting_for_clear_nacl_cache_(false), 119 waiting_for_clear_nacl_cache_(false),
120 waiting_for_clear_cookies_count_(0), 120 waiting_for_clear_cookies_count_(0),
121 waiting_for_clear_history_(false), 121 waiting_for_clear_history_(false),
122 waiting_for_clear_local_storage_(false), 122 waiting_for_clear_local_storage_(false),
123 waiting_for_clear_networking_history_(false), 123 waiting_for_clear_networking_history_(false),
124 waiting_for_clear_server_bound_certs_(false), 124 waiting_for_clear_server_bound_certs_(false),
125 waiting_for_clear_plugin_data_(false), 125 waiting_for_clear_plugin_data_(false),
126 waiting_for_clear_quota_managed_data_(false), 126 waiting_for_clear_quota_managed_data_(false),
127 waiting_for_clear_content_licenses_(false), 127 waiting_for_clear_content_licenses_(false),
128 waiting_for_clear_form_(false),
128 remove_mask_(0), 129 remove_mask_(0),
129 remove_origin_(GURL()), 130 remove_origin_(GURL()),
130 origin_set_mask_(0) { 131 origin_set_mask_(0) {
131 DCHECK(profile); 132 DCHECK(profile);
132 // crbug.com/140910: Many places were calling this with base::Time() as 133 // crbug.com/140910: Many places were calling this with base::Time() as
133 // delete_end, even though they should've used base::Time::Now(). Work around 134 // delete_end, even though they should've used base::Time::Now(). Work around
134 // it here. New code should use base::Time::Now(). 135 // it here. New code should use base::Time::Now().
135 DCHECK(delete_end_ != base::Time()); 136 DCHECK(delete_end_ != base::Time());
136 if (delete_end_ == base::Time()) 137 if (delete_end_ == base::Time())
137 delete_end_ = base::Time::Now(); 138 delete_end_ = base::Time::Now();
(...skipping 16 matching lines...) Expand all
154 waiting_for_clear_cache_(false), 155 waiting_for_clear_cache_(false),
155 waiting_for_clear_nacl_cache_(false), 156 waiting_for_clear_nacl_cache_(false),
156 waiting_for_clear_cookies_count_(0), 157 waiting_for_clear_cookies_count_(0),
157 waiting_for_clear_history_(false), 158 waiting_for_clear_history_(false),
158 waiting_for_clear_local_storage_(false), 159 waiting_for_clear_local_storage_(false),
159 waiting_for_clear_networking_history_(false), 160 waiting_for_clear_networking_history_(false),
160 waiting_for_clear_server_bound_certs_(false), 161 waiting_for_clear_server_bound_certs_(false),
161 waiting_for_clear_plugin_data_(false), 162 waiting_for_clear_plugin_data_(false),
162 waiting_for_clear_quota_managed_data_(false), 163 waiting_for_clear_quota_managed_data_(false),
163 waiting_for_clear_content_licenses_(false), 164 waiting_for_clear_content_licenses_(false),
165 waiting_for_clear_form_(false),
164 remove_mask_(0), 166 remove_mask_(0),
165 remove_origin_(GURL()), 167 remove_origin_(GURL()),
166 origin_set_mask_(0) { 168 origin_set_mask_(0) {
167 DCHECK(profile); 169 DCHECK(profile);
168 // crbug.com/140910: Many places were calling this with base::Time() as 170 // crbug.com/140910: Many places were calling this with base::Time() as
169 // delete_end, even though they should've used base::Time::Now(). Work around 171 // delete_end, even though they should've used base::Time::Now(). Work around
170 // it here. New code should use base::Time::Now(). 172 // it here. New code should use base::Time::Now().
171 DCHECK(delete_end_ != base::Time()); 173 DCHECK(delete_end_ != base::Time());
172 if (delete_end_ == base::Time()) 174 if (delete_end_ == base::Time())
173 delete_end_ = base::Time::Now(); 175 delete_end_ = base::Time::Now();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_); 421 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_);
420 } 422 }
421 423
422 if (remove_mask & REMOVE_FORM_DATA) { 424 if (remove_mask & REMOVE_FORM_DATA) {
423 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); 425 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
424 scoped_refptr<WebDataService> web_data_service = 426 scoped_refptr<WebDataService> web_data_service =
425 WebDataServiceFactory::GetForProfile(profile_, 427 WebDataServiceFactory::GetForProfile(profile_,
426 Profile::EXPLICIT_ACCESS); 428 Profile::EXPLICIT_ACCESS);
427 429
428 if (web_data_service.get()) { 430 if (web_data_service.get()) {
431 waiting_for_clear_form_ = true;
429 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, 432 web_data_service->RemoveFormElementsAddedBetween(delete_begin_,
430 delete_end_); 433 delete_end_);
431 web_data_service->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 434 web_data_service->RemoveAutofillProfilesAndCreditCardsModifiedBetween(
432 delete_begin_, delete_end_); 435 delete_begin_, delete_end_);
436 // The above calls are done on the UI thread but do their work on the DB
437 // thread. So wait for it.
438 BrowserThread::PostTask(
439 BrowserThread::DB, FROM_HERE,
440 base::Bind(&BrowsingDataRemover::FormDataDBThreadHop,
441 base::Unretained(this)));
442
433 PersonalDataManager* data_manager = 443 PersonalDataManager* data_manager =
434 PersonalDataManagerFactory::GetForProfile(profile_); 444 PersonalDataManagerFactory::GetForProfile(profile_);
435 if (data_manager) { 445 if (data_manager) {
436 data_manager->Refresh(); 446 data_manager->Refresh();
437 } 447 }
438 } 448 }
439 } 449 }
440 450
441 if (remove_mask & REMOVE_CACHE) { 451 if (remove_mask & REMOVE_CACHE) {
442 // Tell the renderers to clear their cache. 452 // Tell the renderers to clear their cache.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 return registrar_.IsEmpty() && 549 return registrar_.IsEmpty() &&
540 !waiting_for_clear_cache_ && 550 !waiting_for_clear_cache_ &&
541 !waiting_for_clear_nacl_cache_ && 551 !waiting_for_clear_nacl_cache_ &&
542 !waiting_for_clear_cookies_count_&& 552 !waiting_for_clear_cookies_count_&&
543 !waiting_for_clear_history_ && 553 !waiting_for_clear_history_ &&
544 !waiting_for_clear_local_storage_ && 554 !waiting_for_clear_local_storage_ &&
545 !waiting_for_clear_networking_history_ && 555 !waiting_for_clear_networking_history_ &&
546 !waiting_for_clear_server_bound_certs_ && 556 !waiting_for_clear_server_bound_certs_ &&
547 !waiting_for_clear_plugin_data_ && 557 !waiting_for_clear_plugin_data_ &&
548 !waiting_for_clear_quota_managed_data_ && 558 !waiting_for_clear_quota_managed_data_ &&
549 !waiting_for_clear_content_licenses_; 559 !waiting_for_clear_content_licenses_ &&
560 !waiting_for_clear_form_;
550 } 561 }
551 562
552 void BrowsingDataRemover::Observe(int type, 563 void BrowsingDataRemover::Observe(int type,
553 const content::NotificationSource& source, 564 const content::NotificationSource& source,
554 const content::NotificationDetails& details) { 565 const content::NotificationDetails& details) {
555 // TODO(brettw) bug 1139736: This should also observe session 566 // TODO(brettw) bug 1139736: This should also observe session
556 // clearing (what about other things such as passwords, etc.?) and wait for 567 // clearing (what about other things such as passwords, etc.?) and wait for
557 // them to complete before continuing. 568 // them to complete before continuing.
558 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); 569 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
559 TemplateURLService* model = content::Source<TemplateURLService>(source).ptr(); 570 TemplateURLService* model = content::Source<TemplateURLService>(source).ptr();
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 BrowserThread::UI, FROM_HERE, 912 BrowserThread::UI, FROM_HERE,
902 base::Bind(&BrowsingDataRemover::OnClearedServerBoundCerts, 913 base::Bind(&BrowsingDataRemover::OnClearedServerBoundCerts,
903 base::Unretained(this))); 914 base::Unretained(this)));
904 } 915 }
905 916
906 void BrowsingDataRemover::OnClearedServerBoundCerts() { 917 void BrowsingDataRemover::OnClearedServerBoundCerts() {
907 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
908 waiting_for_clear_server_bound_certs_ = false; 919 waiting_for_clear_server_bound_certs_ = false;
909 NotifyAndDeleteIfDone(); 920 NotifyAndDeleteIfDone();
910 } 921 }
922
923 void BrowsingDataRemover::FormDataDBThreadHop() {
924 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
925 BrowserThread::PostTask(
926 BrowserThread::UI, FROM_HERE,
927 base::Bind(&BrowsingDataRemover::OnClearedFormData,
928 base::Unretained(this)));
929 }
930
931 void BrowsingDataRemover::OnClearedFormData() {
932 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
933 waiting_for_clear_form_ = false;
934 NotifyAndDeleteIfDone();
935 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698