Index: components/autofill/browser/webdata/autofill_webdata_backend.cc |
diff --git a/components/autofill/browser/webdata/autofill_webdata_service.cc b/components/autofill/browser/webdata/autofill_webdata_backend.cc |
similarity index 60% |
copy from components/autofill/browser/webdata/autofill_webdata_service.cc |
copy to components/autofill/browser/webdata/autofill_webdata_backend.cc |
index f4bc67ad78d820446f0f4773837444c25628bc88..0cda3d15310d9e4796315c7be1d2442af50caffb 100644 |
--- a/components/autofill/browser/webdata/autofill_webdata_service.cc |
+++ b/components/autofill/browser/webdata/autofill_webdata_backend.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/autofill/browser/webdata/autofill_webdata_service.h" |
+#include "components/autofill/browser/webdata/autofill_webdata_backend.h" |
#include "base/logging.h" |
#include "base/stl_util.h" |
@@ -14,7 +14,6 @@ |
#include "components/autofill/browser/webdata/autofill_table.h" |
#include "components/autofill/browser/webdata/autofill_webdata_service_observer.h" |
#include "components/autofill/common/form_field_data.h" |
-#include "components/webdata/common/web_database_service.h" |
using base::Bind; |
using base::Time; |
@@ -22,178 +21,25 @@ using content::BrowserThread; |
namespace autofill { |
-// static |
-void AutofillWebDataService::NotifyOfMultipleAutofillChanges( |
- AutofillWebDataService* web_data_service) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
- |
- if (!web_data_service) |
- return; |
- |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- Bind(&AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, |
- make_scoped_refptr(web_data_service))); |
-} |
- |
-AutofillWebDataService::AutofillWebDataService( |
- scoped_refptr<WebDatabaseService> wdbs, |
- const ProfileErrorCallback& callback) |
- : WebDataServiceBase(wdbs, callback) { |
-} |
- |
-AutofillWebDataService::AutofillWebDataService() |
- : WebDataServiceBase(NULL, |
- WebDataServiceBase::ProfileErrorCallback()) { |
-} |
- |
-void AutofillWebDataService::ShutdownOnUIThread() { |
- BrowserThread::PostTask( |
- BrowserThread::DB, FROM_HERE, |
- base::Bind(&AutofillWebDataService::ShutdownOnDBThread, this)); |
- WebDataServiceBase::ShutdownOnUIThread(); |
-} |
- |
-void AutofillWebDataService::AddFormFields( |
- const std::vector<FormFieldData>& fields) { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::AddFormElementsImpl, this, fields)); |
-} |
- |
-WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName( |
- const base::string16& name, const base::string16& prefix, int limit, |
- WebDataServiceConsumer* consumer) { |
- return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
- Bind(&AutofillWebDataService::GetFormValuesForElementNameImpl, |
- this, name, prefix, limit), consumer); |
-} |
- |
-void AutofillWebDataService::RemoveFormElementsAddedBetween( |
- const Time& delete_begin, const Time& delete_end) { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::RemoveFormElementsAddedBetweenImpl, |
- this, delete_begin, delete_end)); |
-} |
- |
-void AutofillWebDataService::RemoveExpiredFormElements() { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::RemoveExpiredFormElementsImpl, this)); |
-} |
- |
-void AutofillWebDataService::RemoveFormValueForElementName( |
- const base::string16& name, const base::string16& value) { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::RemoveFormValueForElementNameImpl, |
- this, name, value)); |
-} |
- |
-void AutofillWebDataService::AddAutofillProfile( |
- const AutofillProfile& profile) { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::AddAutofillProfileImpl, this, profile)); |
-} |
- |
-void AutofillWebDataService::UpdateAutofillProfile( |
- const AutofillProfile& profile) { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::UpdateAutofillProfileImpl, |
- this, profile)); |
-} |
- |
-void AutofillWebDataService::RemoveAutofillProfile( |
- const std::string& guid) { |
- wdbs_->ScheduleDBTask(FROM_HERE, |
- Bind(&AutofillWebDataService::RemoveAutofillProfileImpl, this, guid)); |
+AutofillWebDataBackend::AutofillWebDataBackend() { |
} |
-WebDataServiceBase::Handle AutofillWebDataService::GetAutofillProfiles( |
- WebDataServiceConsumer* consumer) { |
- return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
- Bind(&AutofillWebDataService::GetAutofillProfilesImpl, this), |
- consumer); |
-} |
- |
-void AutofillWebDataService::AddCreditCard(const CreditCard& credit_card) { |
- wdbs_->ScheduleDBTask( |
- FROM_HERE, |
- Bind(&AutofillWebDataService::AddCreditCardImpl, this, credit_card)); |
-} |
- |
-void AutofillWebDataService::UpdateCreditCard( |
- const CreditCard& credit_card) { |
- wdbs_->ScheduleDBTask( |
- FROM_HERE, |
- Bind(&AutofillWebDataService::UpdateCreditCardImpl, this, credit_card)); |
-} |
- |
-void AutofillWebDataService::RemoveCreditCard(const std::string& guid) { |
- wdbs_->ScheduleDBTask( |
- FROM_HERE, |
- Bind(&AutofillWebDataService::RemoveCreditCardImpl, this, guid)); |
-} |
- |
-WebDataServiceBase::Handle AutofillWebDataService::GetCreditCards( |
- WebDataServiceConsumer* consumer) { |
- return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, |
- Bind(&AutofillWebDataService::GetCreditCardsImpl, this), consumer); |
-} |
- |
-void AutofillWebDataService::RemoveAutofillDataModifiedBetween( |
- const Time& delete_begin, |
- const Time& delete_end) { |
- wdbs_->ScheduleDBTask( |
- FROM_HERE, |
- Bind(&AutofillWebDataService::RemoveAutofillDataModifiedBetweenImpl, |
- this, delete_begin, delete_end)); |
-} |
- |
-void AutofillWebDataService::AddObserver( |
+void AutofillWebDataBackend::AddObserver( |
AutofillWebDataServiceObserverOnDBThread* observer) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
db_observer_list_.AddObserver(observer); |
} |
-void AutofillWebDataService::RemoveObserver( |
+void AutofillWebDataBackend::RemoveObserver( |
AutofillWebDataServiceObserverOnDBThread* observer) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
db_observer_list_.RemoveObserver(observer); |
} |
-void AutofillWebDataService::AddObserver( |
- AutofillWebDataServiceObserverOnUIThread* observer) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- ui_observer_list_.AddObserver(observer); |
+AutofillWebDataBackend::~AutofillWebDataBackend() { |
} |
-void AutofillWebDataService::RemoveObserver( |
- AutofillWebDataServiceObserverOnUIThread* observer) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- ui_observer_list_.RemoveObserver(observer); |
-} |
- |
-base::SupportsUserData* AutofillWebDataService::GetDBUserData() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
- if (!db_thread_user_data_) |
- db_thread_user_data_.reset(new SupportsUserDataAggregatable()); |
- return db_thread_user_data_.get(); |
-} |
- |
-void AutofillWebDataService::ShutdownOnDBThread() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
- db_thread_user_data_.reset(); |
-} |
- |
-AutofillWebDataService::~AutofillWebDataService() { |
- DCHECK(!db_thread_user_data_.get()) << "Forgot to call ShutdownOnUIThread?"; |
-} |
- |
-//////////////////////////////////////////////////////////////////////////////// |
-// |
-// Autofill implementation. |
-// |
-//////////////////////////////////////////////////////////////////////////////// |
- |
-WebDatabase::State AutofillWebDataService::AddFormElementsImpl( |
+WebDatabase::State AutofillWebDataBackend::AddFormElements( |
const std::vector<FormFieldData>& fields, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
AutofillChangeList changes; |
@@ -214,7 +60,7 @@ WebDatabase::State AutofillWebDataService::AddFormElementsImpl( |
} |
scoped_ptr<WDTypedResult> |
-AutofillWebDataService::GetFormValuesForElementNameImpl( |
+AutofillWebDataBackend::GetFormValuesForElementName( |
const base::string16& name, const base::string16& prefix, int limit, |
WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
@@ -226,7 +72,7 @@ AutofillWebDataService::GetFormValuesForElementNameImpl( |
values)); |
} |
-WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( |
+WebDatabase::State AutofillWebDataBackend::RemoveFormElementsAddedBetween( |
const base::Time& delete_begin, const base::Time& delete_end, |
WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
@@ -247,7 +93,7 @@ WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( |
return WebDatabase::COMMIT_NOT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::RemoveExpiredFormElementsImpl( |
+WebDatabase::State AutofillWebDataBackend::RemoveExpiredFormElements( |
WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
AutofillChangeList changes; |
@@ -266,7 +112,7 @@ WebDatabase::State AutofillWebDataService::RemoveExpiredFormElementsImpl( |
return WebDatabase::COMMIT_NOT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::RemoveFormValueForElementNameImpl( |
+WebDatabase::State AutofillWebDataBackend::RemoveFormValueForElementName( |
const base::string16& name, const base::string16& value, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
@@ -285,7 +131,7 @@ WebDatabase::State AutofillWebDataService::RemoveFormValueForElementNameImpl( |
return WebDatabase::COMMIT_NOT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::AddAutofillProfileImpl( |
+WebDatabase::State AutofillWebDataBackend::AddAutofillProfile( |
const AutofillProfile& profile, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { |
@@ -303,7 +149,7 @@ WebDatabase::State AutofillWebDataService::AddAutofillProfileImpl( |
return WebDatabase::COMMIT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::UpdateAutofillProfileImpl( |
+WebDatabase::State AutofillWebDataBackend::UpdateAutofillProfile( |
const AutofillProfile& profile, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
// Only perform the update if the profile exists. It is currently |
@@ -332,7 +178,7 @@ WebDatabase::State AutofillWebDataService::UpdateAutofillProfileImpl( |
return WebDatabase::COMMIT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::RemoveAutofillProfileImpl( |
+WebDatabase::State AutofillWebDataBackend::RemoveAutofillProfile( |
const std::string& guid, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
AutofillProfile* profile = NULL; |
@@ -356,7 +202,7 @@ WebDatabase::State AutofillWebDataService::RemoveAutofillProfileImpl( |
return WebDatabase::COMMIT_NEEDED; |
} |
-scoped_ptr<WDTypedResult> AutofillWebDataService::GetAutofillProfilesImpl( |
+scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetAutofillProfiles( |
WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
std::vector<AutofillProfile*> profiles; |
@@ -365,11 +211,11 @@ scoped_ptr<WDTypedResult> AutofillWebDataService::GetAutofillProfilesImpl( |
new WDDestroyableResult<std::vector<AutofillProfile*> >( |
AUTOFILL_PROFILES_RESULT, |
profiles, |
- base::Bind(&AutofillWebDataService::DestroyAutofillProfileResult, |
+ base::Bind(&AutofillWebDataBackend::DestroyAutofillProfileResult, |
base::Unretained(this)))); |
} |
-WebDatabase::State AutofillWebDataService::AddCreditCardImpl( |
+WebDatabase::State AutofillWebDataBackend::AddCreditCard( |
const CreditCard& credit_card, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { |
@@ -380,7 +226,7 @@ WebDatabase::State AutofillWebDataService::AddCreditCardImpl( |
return WebDatabase::COMMIT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::UpdateCreditCardImpl( |
+WebDatabase::State AutofillWebDataBackend::UpdateCreditCard( |
const CreditCard& credit_card, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
// It is currently valid to try to update a missing profile. We simply drop |
@@ -399,7 +245,7 @@ WebDatabase::State AutofillWebDataService::UpdateCreditCardImpl( |
return WebDatabase::COMMIT_NEEDED; |
} |
-WebDatabase::State AutofillWebDataService::RemoveCreditCardImpl( |
+WebDatabase::State AutofillWebDataBackend::RemoveCreditCard( |
const std::string& guid, WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { |
@@ -409,7 +255,7 @@ WebDatabase::State AutofillWebDataService::RemoveCreditCardImpl( |
return WebDatabase::COMMIT_NEEDED; |
} |
-scoped_ptr<WDTypedResult> AutofillWebDataService::GetCreditCardsImpl( |
+scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetCreditCards( |
WebDatabase* db) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
std::vector<CreditCard*> credit_cards; |
@@ -418,12 +264,12 @@ scoped_ptr<WDTypedResult> AutofillWebDataService::GetCreditCardsImpl( |
new WDDestroyableResult<std::vector<CreditCard*> >( |
AUTOFILL_CREDITCARDS_RESULT, |
credit_cards, |
- base::Bind(&AutofillWebDataService::DestroyAutofillCreditCardResult, |
+ base::Bind(&AutofillWebDataBackend::DestroyAutofillCreditCardResult, |
base::Unretained(this)))); |
} |
WebDatabase::State |
- AutofillWebDataService::RemoveAutofillDataModifiedBetweenImpl( |
+ AutofillWebDataBackend::RemoveAutofillDataModifiedBetween( |
const base::Time& delete_begin, |
const base::Time& delete_end, |
WebDatabase* db) { |
@@ -449,7 +295,7 @@ WebDatabase::State |
return WebDatabase::COMMIT_NOT_NEEDED; |
} |
-void AutofillWebDataService::DestroyAutofillProfileResult( |
+void AutofillWebDataBackend::DestroyAutofillProfileResult( |
const WDTypedResult* result) { |
DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); |
const WDResult<std::vector<AutofillProfile*> >* r = |
@@ -458,7 +304,7 @@ void AutofillWebDataService::DestroyAutofillProfileResult( |
STLDeleteElements(&profiles); |
} |
-void AutofillWebDataService::DestroyAutofillCreditCardResult( |
+void AutofillWebDataBackend::DestroyAutofillCreditCardResult( |
const WDTypedResult* result) { |
DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); |
const WDResult<std::vector<CreditCard*> >* r = |
@@ -468,11 +314,4 @@ void AutofillWebDataService::DestroyAutofillCreditCardResult( |
STLDeleteElements(&credit_cards); |
} |
-void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
- ui_observer_list_, |
- AutofillMultipleChanged()); |
-} |
- |
} // namespace autofill |