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

Unified Diff: components/autofill/browser/webdata/autofill_webdata_service.cc

Issue 14679005: Create an AutofillBackend interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix WIN Created 7 years, 7 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: components/autofill/browser/webdata/autofill_webdata_service.cc
diff --git a/components/autofill/browser/webdata/autofill_webdata_service.cc b/components/autofill/browser/webdata/autofill_webdata_service.cc
index 1f7e158fe8421f8738099369d84ca7e427f80304..b965b197e27966dd59d17c49b5ce28f530ddeee4 100644
--- a/components/autofill/browser/webdata/autofill_webdata_service.cc
+++ b/components/autofill/browser/webdata/autofill_webdata_service.cc
@@ -12,9 +12,10 @@
#include "components/autofill/browser/webdata/autofill_change.h"
#include "components/autofill/browser/webdata/autofill_entry.h"
#include "components/autofill/browser/webdata/autofill_table.h"
-#include "components/autofill/browser/webdata/autofill_webdata_backend.h"
+#include "components/autofill/browser/webdata/autofill_webdata_backend_impl.h"
#include "components/autofill/browser/webdata/autofill_webdata_service_observer.h"
#include "components/autofill/common/form_field_data.h"
+#include "components/webdata/common/web_data_service_backend.h"
#include "components/webdata/common/web_database_service.h"
using base::Bind;
@@ -41,16 +42,27 @@ AutofillWebDataService::AutofillWebDataService(
scoped_refptr<WebDatabaseService> wdbs,
const ProfileErrorCallback& callback)
: WebDataServiceBase(wdbs, callback),
- autofill_backend_(new AutofillWebDataBackend()) {
+ weak_ptr_factory_(this),
+ autofill_backend_(NULL) {
+
+ base::Closure on_changed_callback = Bind(
+ &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread,
+ weak_ptr_factory_.GetWeakPtr());
+
+ autofill_backend_ = new AutofillWebDataBackendImpl(
+ wdbs_->GetBackend(),
+ on_changed_callback);
}
AutofillWebDataService::AutofillWebDataService()
: WebDataServiceBase(NULL,
WebDataServiceBase::ProfileErrorCallback()),
- autofill_backend_(new AutofillWebDataBackend()) {
+ weak_ptr_factory_(this),
+ autofill_backend_(new AutofillWebDataBackendImpl(NULL, base::Closure())) {
}
void AutofillWebDataService::ShutdownOnUIThread() {
+ weak_ptr_factory_.InvalidateWeakPtrs();
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
base::Bind(&AutofillWebDataService::ShutdownOnDBThread, this));
@@ -60,7 +72,7 @@ void AutofillWebDataService::ShutdownOnUIThread() {
void AutofillWebDataService::AddFormFields(
const std::vector<FormFieldData>& fields) {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::AddFormElements,
+ Bind(&AutofillWebDataBackendImpl::AddFormElements,
autofill_backend_, fields));
}
@@ -68,69 +80,69 @@ WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName(
const base::string16& name, const base::string16& prefix, int limit,
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&AutofillWebDataBackend::GetFormValuesForElementName,
+ Bind(&AutofillWebDataBackendImpl::GetFormValuesForElementName,
autofill_backend_, name, prefix, limit), consumer);
}
WebDataServiceBase::Handle AutofillWebDataService::HasFormElements(
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&AutofillWebDataBackend::HasFormElements, autofill_backend_),
+ Bind(&AutofillWebDataBackendImpl::HasFormElements, autofill_backend_),
consumer);
}
void AutofillWebDataService::RemoveFormElementsAddedBetween(
const Time& delete_begin, const Time& delete_end) {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::RemoveFormElementsAddedBetween,
+ Bind(&AutofillWebDataBackendImpl::RemoveFormElementsAddedBetween,
autofill_backend_, delete_begin, delete_end));
}
void AutofillWebDataService::RemoveExpiredFormElements() {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::RemoveExpiredFormElements,
+ Bind(&AutofillWebDataBackendImpl::RemoveExpiredFormElements,
autofill_backend_));
}
void AutofillWebDataService::RemoveFormValueForElementName(
const base::string16& name, const base::string16& value) {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::RemoveFormValueForElementName,
+ Bind(&AutofillWebDataBackendImpl::RemoveFormValueForElementName,
autofill_backend_, name, value));
}
void AutofillWebDataService::AddAutofillProfile(
const AutofillProfile& profile) {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::AddAutofillProfile,
+ Bind(&AutofillWebDataBackendImpl::AddAutofillProfile,
autofill_backend_, profile));
}
void AutofillWebDataService::UpdateAutofillProfile(
const AutofillProfile& profile) {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::UpdateAutofillProfile,
+ Bind(&AutofillWebDataBackendImpl::UpdateAutofillProfile,
autofill_backend_, profile));
}
void AutofillWebDataService::RemoveAutofillProfile(
const std::string& guid) {
wdbs_->ScheduleDBTask(FROM_HERE,
- Bind(&AutofillWebDataBackend::RemoveAutofillProfile,
+ Bind(&AutofillWebDataBackendImpl::RemoveAutofillProfile,
autofill_backend_, guid));
}
WebDataServiceBase::Handle AutofillWebDataService::GetAutofillProfiles(
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&AutofillWebDataBackend::GetAutofillProfiles, autofill_backend_),
+ Bind(&AutofillWebDataBackendImpl::GetAutofillProfiles, autofill_backend_),
consumer);
}
void AutofillWebDataService::AddCreditCard(const CreditCard& credit_card) {
wdbs_->ScheduleDBTask(
FROM_HERE,
- Bind(&AutofillWebDataBackend::AddCreditCard,
+ Bind(&AutofillWebDataBackendImpl::AddCreditCard,
autofill_backend_, credit_card));
}
@@ -138,20 +150,21 @@ void AutofillWebDataService::UpdateCreditCard(
const CreditCard& credit_card) {
wdbs_->ScheduleDBTask(
FROM_HERE,
- Bind(&AutofillWebDataBackend::UpdateCreditCard,
+ Bind(&AutofillWebDataBackendImpl::UpdateCreditCard,
autofill_backend_, credit_card));
}
void AutofillWebDataService::RemoveCreditCard(const std::string& guid) {
wdbs_->ScheduleDBTask(
FROM_HERE,
- Bind(&AutofillWebDataBackend::RemoveCreditCard, autofill_backend_, guid));
+ Bind(&AutofillWebDataBackendImpl::RemoveCreditCard,
+ autofill_backend_, guid));
}
WebDataServiceBase::Handle AutofillWebDataService::GetCreditCards(
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&AutofillWebDataBackend::GetCreditCards, autofill_backend_),
+ Bind(&AutofillWebDataBackendImpl::GetCreditCards, autofill_backend_),
consumer);
}
@@ -160,7 +173,7 @@ void AutofillWebDataService::RemoveAutofillDataModifiedBetween(
const Time& delete_end) {
wdbs_->ScheduleDBTask(
FROM_HERE,
- Bind(&AutofillWebDataBackend::RemoveAutofillDataModifiedBetween,
+ Bind(&AutofillWebDataBackendImpl::RemoveAutofillDataModifiedBetween,
autofill_backend_, delete_begin, delete_end));
}
@@ -197,6 +210,13 @@ base::SupportsUserData* AutofillWebDataService::GetDBUserData() {
return db_thread_user_data_.get();
}
+void AutofillWebDataService::GetAutofillBackend(
+ const base::Callback<void(AutofillWebDataBackend*)>& callback) {
+ BrowserThread::PostTask(BrowserThread::DB,
+ FROM_HERE,
+ base::Bind(callback, autofill_backend_));
+}
+
void AutofillWebDataService::ShutdownOnDBThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
db_thread_user_data_.reset();
« no previous file with comments | « components/autofill/browser/webdata/autofill_webdata_service.h ('k') | components/webdata/common/web_data_service_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698