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

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

Issue 14081043: Hook up Autofill Backend interface to SyncableServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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_backend_delegate.cc
diff --git a/components/autofill/browser/webdata/autofill_backend_delegate.cc b/components/autofill/browser/webdata/autofill_backend_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..19062fb6c2a6184307a38dcc24777735510ecf0b
--- /dev/null
+++ b/components/autofill/browser/webdata/autofill_backend_delegate.cc
@@ -0,0 +1,71 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// 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_backend_delegate.h"
+
+#include "components/autofill/browser/webdata/autofill_webdata_backend.h"
+#include "components/autofill/browser/webdata/autofill_webdata_service.h"
+#include "components/autofill/browser/webdata/autofill_webdata_service_observer.h"
+#include "components/webdata/common/web_database.h"
+
+using base::Bind;
+using content::BrowserThread;
+
+namespace autofill {
+
+AutofillBackendDelegate::AutofillBackendDelegate(
+ base::WeakPtr<WebDatabase> db,
+ base::WeakPtr<AutofillWebDataBackend> autofill_backend)
+ : web_database_(db),
+ autofill_backend_(autofill_backend) {
+}
+
+AutofillBackendDelegate::~AutofillBackendDelegate() {
+}
+
+WebDatabase* AutofillBackendDelegate::GetDatabase() {
+ return web_database_.get();
+}
+
+void AutofillBackendDelegate::AddObserver(
+ AutofillWebDataServiceObserverOnDBThread* observer) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ if (autofill_backend_.get())
+ autofill_backend_->AddObserver(observer);
+}
+
+void AutofillBackendDelegate::RemoveObserver(
+ AutofillWebDataServiceObserverOnDBThread* observer) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ if (autofill_backend_.get())
+ autofill_backend_->RemoveObserver(observer);
+}
+
+void AutofillBackendDelegate::RemoveExpiredFormElements() {
+ if (!autofill_backend_.get())
+ return;
+
+ WebDatabase::State state =
+ autofill_backend_->RemoveExpiredFormElementsImpl(web_database_);
+
+ if (state == WebDatabase::COMMIT_NEEDED) {
+ web_database_->CommitTransaction();
+ web_database_->BeginTransaction();
+ }
+}
+
+void AutofillBackendDelegate::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)));
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698