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

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

Issue 14679005: Create an AutofillBackend interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments pt 2 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_backend_impl.cc
diff --git a/components/autofill/browser/webdata/autofill_webdata_backend.cc b/components/autofill/browser/webdata/autofill_webdata_backend_impl.cc
similarity index 81%
rename from components/autofill/browser/webdata/autofill_webdata_backend.cc
rename to components/autofill/browser/webdata/autofill_webdata_backend_impl.cc
index 0cda3d15310d9e4796315c7be1d2442af50caffb..a88ab30bf18266b86b99cf13679986a1d6b9a9b3 100644
--- a/components/autofill/browser/webdata/autofill_webdata_backend.cc
+++ b/components/autofill/browser/webdata/autofill_webdata_backend_impl.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_backend.h"
+#include "components/autofill/browser/webdata/autofill_webdata_backend_impl.h"
#include "base/logging.h"
#include "base/stl_util.h"
@@ -14,6 +14,7 @@
#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_data_service_backend.h"
using base::Bind;
using base::Time;
@@ -21,25 +22,49 @@ using content::BrowserThread;
namespace autofill {
-AutofillWebDataBackend::AutofillWebDataBackend() {
+AutofillWebDataBackendImpl::AutofillWebDataBackendImpl(
+ scoped_refptr<WebDataServiceBackend> web_database_backend,
+ const base::Closure& on_changed_callback)
+ : web_database_backend_(web_database_backend),
+ on_changed_callback_(new base::Closure(on_changed_callback)) {
Ilya Sherman 2013/05/09 05:04:24 nit: Why are you storing the as a pointer rather t
Cait (Slow) 2013/05/09 18:29:54 Done.
}
-void AutofillWebDataBackend::AddObserver(
+void AutofillWebDataBackendImpl::AddObserver(
AutofillWebDataServiceObserverOnDBThread* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
db_observer_list_.AddObserver(observer);
}
-void AutofillWebDataBackend::RemoveObserver(
+void AutofillWebDataBackendImpl::RemoveObserver(
AutofillWebDataServiceObserverOnDBThread* observer) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
db_observer_list_.RemoveObserver(observer);
}
-AutofillWebDataBackend::~AutofillWebDataBackend() {
+AutofillWebDataBackendImpl::~AutofillWebDataBackendImpl() {
}
-WebDatabase::State AutofillWebDataBackend::AddFormElements(
+WebDatabase* AutofillWebDataBackendImpl::GetDatabase() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ return web_database_backend_->database();
Ilya Sherman 2013/05/09 05:04:24 nit: De-indent two spaces.
Cait (Slow) 2013/05/09 18:29:54 Done.
+}
+
+void AutofillWebDataBackendImpl::RemoveExpiredFormElementsWrapper() {
+ if (RemoveExpiredFormElements(web_database_backend_->database()) ==
+ WebDatabase::COMMIT_NEEDED) {
+ web_database_backend_->database()->CommitTransaction();
+ web_database_backend_->database()->BeginTransaction();
+ }
Ilya Sherman 2013/05/09 05:04:24 Is this new behavior that's being added in this CL
Cait (Slow) 2013/05/09 18:29:54 This is duplicating behavior in WebDataServiceBack
+}
+
+void AutofillWebDataBackendImpl::NotifyOfMultipleAutofillChanges() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ *(on_changed_callback_.get()));
Ilya Sherman 2013/05/09 05:04:24 nit: I don't think the .get() is necessary.
Cait (Slow) 2013/05/09 18:29:54 Done.
+}
+
+WebDatabase::State AutofillWebDataBackendImpl::AddFormElements(
const std::vector<FormFieldData>& fields, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
AutofillChangeList changes;
@@ -60,7 +85,7 @@ WebDatabase::State AutofillWebDataBackend::AddFormElements(
}
scoped_ptr<WDTypedResult>
-AutofillWebDataBackend::GetFormValuesForElementName(
+AutofillWebDataBackendImpl::GetFormValuesForElementName(
const base::string16& name, const base::string16& prefix, int limit,
WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
@@ -72,7 +97,7 @@ AutofillWebDataBackend::GetFormValuesForElementName(
values));
}
-WebDatabase::State AutofillWebDataBackend::RemoveFormElementsAddedBetween(
+WebDatabase::State AutofillWebDataBackendImpl::RemoveFormElementsAddedBetween(
const base::Time& delete_begin, const base::Time& delete_end,
WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
@@ -93,7 +118,7 @@ WebDatabase::State AutofillWebDataBackend::RemoveFormElementsAddedBetween(
return WebDatabase::COMMIT_NOT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::RemoveExpiredFormElements(
+WebDatabase::State AutofillWebDataBackendImpl::RemoveExpiredFormElements(
WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
AutofillChangeList changes;
@@ -112,7 +137,7 @@ WebDatabase::State AutofillWebDataBackend::RemoveExpiredFormElements(
return WebDatabase::COMMIT_NOT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::RemoveFormValueForElementName(
+WebDatabase::State AutofillWebDataBackendImpl::RemoveFormValueForElementName(
const base::string16& name, const base::string16& value, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
@@ -131,7 +156,7 @@ WebDatabase::State AutofillWebDataBackend::RemoveFormValueForElementName(
return WebDatabase::COMMIT_NOT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::AddAutofillProfile(
+WebDatabase::State AutofillWebDataBackendImpl::AddAutofillProfile(
const AutofillProfile& profile, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!AutofillTable::FromWebDatabase(db)->AddAutofillProfile(profile)) {
@@ -149,7 +174,7 @@ WebDatabase::State AutofillWebDataBackend::AddAutofillProfile(
return WebDatabase::COMMIT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::UpdateAutofillProfile(
+WebDatabase::State AutofillWebDataBackendImpl::UpdateAutofillProfile(
const AutofillProfile& profile, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
// Only perform the update if the profile exists. It is currently
@@ -178,7 +203,7 @@ WebDatabase::State AutofillWebDataBackend::UpdateAutofillProfile(
return WebDatabase::COMMIT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::RemoveAutofillProfile(
+WebDatabase::State AutofillWebDataBackendImpl::RemoveAutofillProfile(
const std::string& guid, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
AutofillProfile* profile = NULL;
@@ -202,7 +227,7 @@ WebDatabase::State AutofillWebDataBackend::RemoveAutofillProfile(
return WebDatabase::COMMIT_NEEDED;
}
-scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetAutofillProfiles(
+scoped_ptr<WDTypedResult> AutofillWebDataBackendImpl::GetAutofillProfiles(
WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
std::vector<AutofillProfile*> profiles;
@@ -211,11 +236,11 @@ scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetAutofillProfiles(
new WDDestroyableResult<std::vector<AutofillProfile*> >(
AUTOFILL_PROFILES_RESULT,
profiles,
- base::Bind(&AutofillWebDataBackend::DestroyAutofillProfileResult,
+ base::Bind(&AutofillWebDataBackendImpl::DestroyAutofillProfileResult,
base::Unretained(this))));
}
-WebDatabase::State AutofillWebDataBackend::AddCreditCard(
+WebDatabase::State AutofillWebDataBackendImpl::AddCreditCard(
const CreditCard& credit_card, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!AutofillTable::FromWebDatabase(db)->AddCreditCard(credit_card)) {
@@ -226,7 +251,7 @@ WebDatabase::State AutofillWebDataBackend::AddCreditCard(
return WebDatabase::COMMIT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::UpdateCreditCard(
+WebDatabase::State AutofillWebDataBackendImpl::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
@@ -245,7 +270,7 @@ WebDatabase::State AutofillWebDataBackend::UpdateCreditCard(
return WebDatabase::COMMIT_NEEDED;
}
-WebDatabase::State AutofillWebDataBackend::RemoveCreditCard(
+WebDatabase::State AutofillWebDataBackendImpl::RemoveCreditCard(
const std::string& guid, WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!AutofillTable::FromWebDatabase(db)->RemoveCreditCard(guid)) {
@@ -255,7 +280,7 @@ WebDatabase::State AutofillWebDataBackend::RemoveCreditCard(
return WebDatabase::COMMIT_NEEDED;
}
-scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetCreditCards(
+scoped_ptr<WDTypedResult> AutofillWebDataBackendImpl::GetCreditCards(
WebDatabase* db) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
std::vector<CreditCard*> credit_cards;
@@ -264,12 +289,12 @@ scoped_ptr<WDTypedResult> AutofillWebDataBackend::GetCreditCards(
new WDDestroyableResult<std::vector<CreditCard*> >(
AUTOFILL_CREDITCARDS_RESULT,
credit_cards,
- base::Bind(&AutofillWebDataBackend::DestroyAutofillCreditCardResult,
+ base::Bind(&AutofillWebDataBackendImpl::DestroyAutofillCreditCardResult,
base::Unretained(this))));
}
WebDatabase::State
- AutofillWebDataBackend::RemoveAutofillDataModifiedBetween(
+ AutofillWebDataBackendImpl::RemoveAutofillDataModifiedBetween(
const base::Time& delete_begin,
const base::Time& delete_end,
WebDatabase* db) {
@@ -295,7 +320,7 @@ WebDatabase::State
return WebDatabase::COMMIT_NOT_NEEDED;
}
-void AutofillWebDataBackend::DestroyAutofillProfileResult(
+void AutofillWebDataBackendImpl::DestroyAutofillProfileResult(
const WDTypedResult* result) {
DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT);
const WDResult<std::vector<AutofillProfile*> >* r =
@@ -304,7 +329,7 @@ void AutofillWebDataBackend::DestroyAutofillProfileResult(
STLDeleteElements(&profiles);
}
-void AutofillWebDataBackend::DestroyAutofillCreditCardResult(
+void AutofillWebDataBackendImpl::DestroyAutofillCreditCardResult(
const WDTypedResult* result) {
DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT);
const WDResult<std::vector<CreditCard*> >* r =

Powered by Google App Engine
This is Rietveld 408576698