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

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

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_backend_impl.h
diff --git a/components/autofill/browser/webdata/autofill_webdata_backend.h b/components/autofill/browser/webdata/autofill_webdata_backend_impl.h
similarity index 74%
copy from components/autofill/browser/webdata/autofill_webdata_backend.h
copy to components/autofill/browser/webdata/autofill_webdata_backend_impl.h
index 3ab841e64ccef2f559216b3096a88192d62b0c21..525adcbc812c8e33a5e434c7ac3ebe01e9ca25a2 100644
--- a/components/autofill/browser/webdata/autofill_webdata_backend.h
+++ b/components/autofill/browser/webdata/autofill_webdata_backend_impl.h
@@ -2,18 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
-#define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
+#ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H_
+#define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H_
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "components/autofill/browser/webdata/autofill_webdata.h"
+#include "components/autofill/browser/webdata/autofill_webdata_backend.h"
#include "components/autofill/common/form_field_data.h"
#include "components/webdata/common/web_data_results.h"
#include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database.h"
+class WebDataServiceBackend;
+
namespace autofill {
class AutofillChange;
@@ -26,11 +30,27 @@ class CreditCard;
// in it should only be called from that thread. Most functions here are just
// the implementations of the corresponding functions in the Autofill
// WebDataService.
-class AutofillWebDataBackend
- : public base::RefCountedThreadSafe<AutofillWebDataBackend,
- content::BrowserThread::DeleteOnDBThread> {
+class AutofillWebDataBackendImpl
+ : public base::RefCountedThreadSafe<AutofillWebDataBackendImpl,
+ content::BrowserThread::DeleteOnDBThread>,
+ public AutofillWebDataBackend {
public:
- AutofillWebDataBackend();
+ // |web_database_backend| is used to access the WebDatabase directly for
+ // Sync-related operations. |on_changed_callback| is a closure which can be
+ // used to notify the UI thread of changes initiated by Sync (this callback
+ // may be called multiple times).
+ AutofillWebDataBackendImpl(
+ scoped_refptr<WebDataServiceBackend> web_database_backend,
+ const base::Closure& on_changed_callback);
+
+ // AutofillWebDataBackend implementation.
+ virtual void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer)
+ OVERRIDE;
+ virtual void RemoveObserver(
+ AutofillWebDataServiceObserverOnDBThread* observer) OVERRIDE;
+ virtual WebDatabase* GetDatabase() OVERRIDE;
+ virtual void RemoveExpiredFormElementsWrapper() OVERRIDE;
+ virtual void NotifyOfMultipleAutofillChanges() OVERRIDE;
// Adds form fields to the web database.
WebDatabase::State AddFormElements(const std::vector<FormFieldData>& fields,
@@ -98,22 +118,16 @@ class AutofillWebDataBackend
const base::Time& delete_end,
WebDatabase* db);
- // Add an observer to be notified of changes on the DB thread.
- void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer);
-
- // Remove an observer.
- void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer);
-
protected:
- virtual ~AutofillWebDataBackend();
+ virtual ~AutofillWebDataBackendImpl();
private:
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::DB>;
- friend class base::DeleteHelper<AutofillWebDataBackend>;
+ friend class base::DeleteHelper<AutofillWebDataBackendImpl>;
// We have to friend RCTS<> so WIN shared-lib build is happy
// (http://crbug/112250).
- friend class base::RefCountedThreadSafe<AutofillWebDataBackend,
+ friend class base::RefCountedThreadSafe<AutofillWebDataBackendImpl,
content::BrowserThread::DeleteOnDBThread>;
// Callbacks to ensure that sensitive info is destroyed if request is
@@ -123,9 +137,15 @@ class AutofillWebDataBackend
ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_;
- DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend);
+ // WebDataServiceBackend allows direct access to DB.
+ // TODO(caitkp): Make it so nobody but us needs direct DB access anymore.
+ scoped_refptr<WebDataServiceBackend> web_database_backend_;
+
+ base::Closure on_changed_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackendImpl);
};
} // namespace autofill
-#endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
+#endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698