Chromium Code Reviews| 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..71866c59f624f1506bbbdba9e7b51cc23adae7bd 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,186 +14,31 @@ |
| #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; |
| using content::BrowserThread; |
| namespace autofill { |
|
Ilya Sherman
2013/04/30 00:14:08
nit: Please leave a blank line after this one.
Cait (Slow)
2013/04/30 22:24:40
Done.
|
| - |
| -// 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)); |
| +AutofillWebDataBackend::AutofillWebDataBackend() { |
| } |
| -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)); |
| -} |
| - |
| -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::AddFormElementsImpl( |
| const std::vector<FormFieldData>& fields, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| AutofillChangeList changes; |
| @@ -214,7 +59,7 @@ WebDatabase::State AutofillWebDataService::AddFormElementsImpl( |
| } |
| scoped_ptr<WDTypedResult> |
| -AutofillWebDataService::GetFormValuesForElementNameImpl( |
| +AutofillWebDataBackend::GetFormValuesForElementNameImpl( |
| const base::string16& name, const base::string16& prefix, int limit, |
| WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| @@ -226,7 +71,7 @@ AutofillWebDataService::GetFormValuesForElementNameImpl( |
| values)); |
| } |
| -WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( |
| +WebDatabase::State AutofillWebDataBackend::RemoveFormElementsAddedBetweenImpl( |
| const base::Time& delete_begin, const base::Time& delete_end, |
| WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| @@ -247,7 +92,7 @@ WebDatabase::State AutofillWebDataService::RemoveFormElementsAddedBetweenImpl( |
| return WebDatabase::COMMIT_NOT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::RemoveExpiredFormElementsImpl( |
| +WebDatabase::State AutofillWebDataBackend::RemoveExpiredFormElementsImpl( |
| WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| AutofillChangeList changes; |
| @@ -266,7 +111,7 @@ WebDatabase::State AutofillWebDataService::RemoveExpiredFormElementsImpl( |
| return WebDatabase::COMMIT_NOT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::RemoveFormValueForElementNameImpl( |
| +WebDatabase::State AutofillWebDataBackend::RemoveFormValueForElementNameImpl( |
| const base::string16& name, const base::string16& value, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| @@ -285,7 +130,7 @@ WebDatabase::State AutofillWebDataService::RemoveFormValueForElementNameImpl( |
| return WebDatabase::COMMIT_NOT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::AddAutofillProfileImpl( |
| +WebDatabase::State AutofillWebDataBackend::AddAutofillProfileImpl( |
| const AutofillProfile& profile, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) { |
| @@ -303,7 +148,7 @@ WebDatabase::State AutofillWebDataService::AddAutofillProfileImpl( |
| return WebDatabase::COMMIT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::UpdateAutofillProfileImpl( |
| +WebDatabase::State AutofillWebDataBackend::UpdateAutofillProfileImpl( |
| const AutofillProfile& profile, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| // Only perform the update if the profile exists. It is currently |
| @@ -332,7 +177,7 @@ WebDatabase::State AutofillWebDataService::UpdateAutofillProfileImpl( |
| return WebDatabase::COMMIT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::RemoveAutofillProfileImpl( |
| +WebDatabase::State AutofillWebDataBackend::RemoveAutofillProfileImpl( |
| const std::string& guid, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| AutofillProfile* profile = NULL; |
| @@ -356,7 +201,7 @@ WebDatabase::State AutofillWebDataService::RemoveAutofillProfileImpl( |
| return WebDatabase::COMMIT_NEEDED; |
| } |
| -scoped_ptr<WDTypedResult> AutofillWebDataService::GetAutofillProfilesImpl( |
| +scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetAutofillProfilesImpl( |
| WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| std::vector<AutofillProfile*> profiles; |
| @@ -365,11 +210,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::AddCreditCardImpl( |
| const CreditCard& credit_card, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) { |
| @@ -380,7 +225,7 @@ WebDatabase::State AutofillWebDataService::AddCreditCardImpl( |
| return WebDatabase::COMMIT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::UpdateCreditCardImpl( |
| +WebDatabase::State AutofillWebDataBackend::UpdateCreditCardImpl( |
| 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 +244,7 @@ WebDatabase::State AutofillWebDataService::UpdateCreditCardImpl( |
| return WebDatabase::COMMIT_NEEDED; |
| } |
| -WebDatabase::State AutofillWebDataService::RemoveCreditCardImpl( |
| +WebDatabase::State AutofillWebDataBackend::RemoveCreditCardImpl( |
| const std::string& guid, WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) { |
| @@ -409,7 +254,7 @@ WebDatabase::State AutofillWebDataService::RemoveCreditCardImpl( |
| return WebDatabase::COMMIT_NEEDED; |
| } |
| -scoped_ptr<WDTypedResult> AutofillWebDataService::GetCreditCardsImpl( |
| +scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetCreditCardsImpl( |
| WebDatabase* db) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| std::vector<CreditCard*> credit_cards; |
| @@ -418,12 +263,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::RemoveAutofillDataModifiedBetweenImpl( |
| const base::Time& delete_begin, |
| const base::Time& delete_end, |
| WebDatabase* db) { |
| @@ -449,7 +294,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 +303,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 +313,4 @@ void AutofillWebDataService::DestroyAutofillCreditCardResult( |
| STLDeleteElements(&credit_cards); |
| } |
| -void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
| - ui_observer_list_, |
| - AutofillMultipleChanged()); |
| } |
|
Ilya Sherman
2013/04/30 00:14:08
nit: " // namespace autofill"
Cait (Slow)
2013/04/30 22:24:40
Done.
|
| - |
| -} // namespace autofill |