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

Unified Diff: chrome/browser/webdata/web_data_service.cc

Issue 6676031: Autofill database migration to clean up bogus profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/webdata/web_data_service.cc
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index 21f8ee1ba29f8bff6beed88215b586ea4bf3e7a1..848edb64e3ae7ed3bd4bf36521c8aa47aee1899f 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -433,6 +433,16 @@ WebDataService::Handle WebDataService::GetAutofillProfiles(
return request->GetHandle();
}
+void WebDataService::EmptyMigrationTrash(bool notify_sync) {
+ GenericRequest<bool>* request =
+ new GenericRequest<bool>(
+ this, GetNextRequestHandle(), NULL, notify_sync);
+ RegisterRequest(request);
+ ScheduleTask(NewRunnableMethod(this,
+ &WebDataService::EmptyMigrationTrashImpl,
+ request));
+}
+
void WebDataService::AddCreditCard(const CreditCard& credit_card) {
GenericRequest<CreditCard>* request =
new GenericRequest<CreditCard>(
@@ -1087,6 +1097,39 @@ void WebDataService::GetAutofillProfilesImpl(WebDataRequest* request) {
request->RequestComplete();
}
+void WebDataService::EmptyMigrationTrashImpl(
+ GenericRequest<bool>* request) {
+ InitializeDatabaseIfNecessary();
+ if (db_ && !request->IsCancelled()) {
+ bool notify_sync = request->GetArgument();
+ if (notify_sync) {
+ std::vector<std::string> guids;
+ if (!db_->GetAutofillProfilesInTrash(&guids)) {
+ NOTREACHED();
+ return;
+ }
+
+ for (std::vector<std::string>::const_iterator iter = guids.begin();
+ iter != guids.end(); ++iter) {
+ // Send GUID-based notification.
+ AutofillProfileChange change(AutofillProfileChange::REMOVE,
+ *iter, NULL);
+ NotificationService::current()->Notify(
+ NotificationType::AUTOFILL_PROFILE_CHANGED,
+ Source<WebDataService>(this),
+ Details<AutofillProfileChange>(&change));
+ }
+ }
+
+ if (!db_->EmptyAutofillProfilesTrash()) {
Ilya Sherman 2011/03/16 04:58:57 I would have expected that we only empty the trash
dhollowa 2011/03/16 16:13:35 No, we know at this point that sync is in a "recep
+ NOTREACHED();
+ return;
+ }
+ ScheduleCommit();
+ }
+ request->RequestComplete();
+}
+
void WebDataService::AddCreditCardImpl(
GenericRequest<CreditCard>* request) {
InitializeDatabaseIfNecessary();

Powered by Google App Engine
This is Rietveld 408576698