Chromium Code Reviews| 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(); |