Index: chrome/browser/webdata/web_data_service.cc |
=================================================================== |
--- chrome/browser/webdata/web_data_service.cc (revision 36778) |
+++ chrome/browser/webdata/web_data_service.cc (working copy) |
@@ -160,10 +160,10 @@ |
request)); |
} |
-void WebDataService::RemoveAutoFillProfile(const AutoFillProfile& profile) { |
- GenericRequest<AutoFillProfile>* request = |
- new GenericRequest<AutoFillProfile>( |
- this, GetNextRequestHandle(), NULL, profile); |
+void WebDataService::RemoveAutoFillProfile(int profile_id) { |
+ GenericRequest<int>* request = |
+ new GenericRequest<int>( |
+ this, GetNextRequestHandle(), NULL, profile_id); |
RegisterRequest(request); |
ScheduleTask(NewRunnableMethod(this, |
&WebDataService::RemoveAutoFillProfileImpl, |
@@ -183,6 +183,18 @@ |
return request->GetHandle(); |
} |
+WebDataService::Handle WebDataService::GetAutoFillProfiles( |
+ WebDataServiceConsumer* consumer) { |
+ WebDataRequest* request = |
+ new WebDataRequest(this, GetNextRequestHandle(), consumer); |
+ RegisterRequest(request); |
+ ScheduleTask( |
+ NewRunnableMethod(this, |
+ &WebDataService::GetAutoFillProfilesImpl, |
+ request)); |
+ return request->GetHandle(); |
+} |
+ |
void WebDataService::RequestCompleted(Handle h) { |
pending_lock_.Acquire(); |
RequestMap::iterator i = pending_requests_.find(h); |
@@ -472,10 +484,21 @@ |
return; |
} |
+ ChromeThread::PostTask( |
+ ChromeThread::UI, FROM_HERE, |
+ NewRunnableMethod(this, &WebDataService::NotifyDatabaseLoadedOnUIThread)); |
+ |
db_ = db; |
db_->BeginTransaction(); |
} |
+void WebDataService::NotifyDatabaseLoadedOnUIThread() { |
+ // Notify that the database has been initialized. |
+ NotificationService::current()->Notify(NotificationType::WEB_DATABASE_LOADED, |
+ NotificationService::AllSources(), |
+ NotificationService::NoDetails()); |
+} |
+ |
void WebDataService::ShutdownDatabase() { |
should_commit_ = false; |
@@ -734,11 +757,11 @@ |
} |
void WebDataService::RemoveAutoFillProfileImpl( |
- GenericRequest<AutoFillProfile>* request) { |
+ GenericRequest<int>* request) { |
InitializeDatabaseIfNecessary(); |
if (db_ && !request->IsCancelled()) { |
- const AutoFillProfile& profile = request->GetArgument(); |
- if (!db_->RemoveAutoFillProfile(profile)) |
+ int profile_id = request->GetArgument(); |
+ if (!db_->RemoveAutoFillProfile(profile_id)) |
NOTREACHED(); |
ScheduleCommit(); |
} |
@@ -758,6 +781,18 @@ |
request->RequestComplete(); |
} |
+void WebDataService::GetAutoFillProfilesImpl(WebDataRequest* request) { |
+ InitializeDatabaseIfNecessary(); |
+ if (db_ && !request->IsCancelled()) { |
+ std::vector<AutoFillProfile*> profiles; |
+ db_->GetAutoFillProfiles(&profiles); |
+ request->SetResult( |
+ new WDResult<std::vector<AutoFillProfile*> >(AUTOFILL_PROFILES_RESULT, |
+ profiles)); |
+ } |
+ request->RequestComplete(); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// |
// Web Apps implementation. |