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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "base/observer_list.h" 10 #include "base/observer_list.h"
10 #include "components/autofill/browser/webdata/autofill_webdata.h" 11 #include "components/autofill/browser/webdata/autofill_webdata.h"
12 #include "components/autofill/browser/webdata/autofill_webdata_backend.h"
11 #include "components/autofill/common/form_field_data.h" 13 #include "components/autofill/common/form_field_data.h"
12 #include "components/webdata/common/web_data_results.h" 14 #include "components/webdata/common/web_data_results.h"
13 #include "components/webdata/common/web_data_service_base.h" 15 #include "components/webdata/common/web_data_service_base.h"
14 #include "components/webdata/common/web_data_service_consumer.h" 16 #include "components/webdata/common/web_data_service_consumer.h"
15 #include "components/webdata/common/web_database.h" 17 #include "components/webdata/common/web_database.h"
16 18
19 class WebDataServiceBackend;
20
17 namespace autofill { 21 namespace autofill {
18 22
19 class AutofillChange; 23 class AutofillChange;
20 class AutofillProfile; 24 class AutofillProfile;
21 class AutofillWebDataServiceObserverOnDBThread; 25 class AutofillWebDataServiceObserverOnDBThread;
22 class CreditCard; 26 class CreditCard;
23 27
24 // Backend implentation for the AutofillWebDataService. This class runs on the 28 // Backend implentation for the AutofillWebDataService. This class runs on the
25 // DB thread, as it handles reads and writes to the WebDatabase, and functions 29 // DB thread, as it handles reads and writes to the WebDatabase, and functions
26 // in it should only be called from that thread. Most functions here are just 30 // in it should only be called from that thread. Most functions here are just
27 // the implementations of the corresponding functions in the Autofill 31 // the implementations of the corresponding functions in the Autofill
28 // WebDataService. 32 // WebDataService.
29 class AutofillWebDataBackend 33 class AutofillWebDataBackendImpl
30 : public base::RefCountedThreadSafe<AutofillWebDataBackend, 34 : public base::RefCountedThreadSafe<AutofillWebDataBackendImpl,
31 content::BrowserThread::DeleteOnDBThread> { 35 content::BrowserThread::DeleteOnDBThread>,
36 public AutofillWebDataBackend {
32 public: 37 public:
33 AutofillWebDataBackend(); 38 // |web_database_backend| is used to access the WebDatabase directly for
39 // Sync-related operations. |on_changed_callback| is a closure which can be
40 // used to notify the UI thread of changes initiated by Sync (this callback
41 // may be called multiple times).
42 AutofillWebDataBackendImpl(
43 scoped_refptr<WebDataServiceBackend> web_database_backend,
44 const base::Closure& on_changed_callback);
45
46 // AutofillWebDataBackend implementation.
47 virtual void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer)
48 OVERRIDE;
49 virtual void RemoveObserver(
50 AutofillWebDataServiceObserverOnDBThread* observer) OVERRIDE;
51 virtual WebDatabase* GetDatabase() OVERRIDE;
52 virtual void RemoveExpiredFormElementsWrapper() OVERRIDE;
53 virtual void NotifyOfMultipleAutofillChanges() OVERRIDE;
34 54
35 // Adds form fields to the web database. 55 // Adds form fields to the web database.
36 WebDatabase::State AddFormElements(const std::vector<FormFieldData>& fields, 56 WebDatabase::State AddFormElements(const std::vector<FormFieldData>& fields,
37 WebDatabase* db); 57 WebDatabase* db);
38 58
39 // Returns a vector of values which have been entered in form input fields 59 // Returns a vector of values which have been entered in form input fields
40 // named |name|. 60 // named |name|.
41 scoped_ptr<WDTypedResult> GetFormValuesForElementName( 61 scoped_ptr<WDTypedResult> GetFormValuesForElementName(
42 const base::string16& name, 62 const base::string16& name,
43 const base::string16& prefix, 63 const base::string16& prefix,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 111
92 // Returns a vector of all credit cards from the web database. 112 // Returns a vector of all credit cards from the web database.
93 scoped_ptr<WDTypedResult> GetCreditCards(WebDatabase* db); 113 scoped_ptr<WDTypedResult> GetCreditCards(WebDatabase* db);
94 114
95 // Removes Autofill records from the database. 115 // Removes Autofill records from the database.
96 WebDatabase::State RemoveAutofillDataModifiedBetween( 116 WebDatabase::State RemoveAutofillDataModifiedBetween(
97 const base::Time& delete_begin, 117 const base::Time& delete_begin,
98 const base::Time& delete_end, 118 const base::Time& delete_end,
99 WebDatabase* db); 119 WebDatabase* db);
100 120
101 // Add an observer to be notified of changes on the DB thread.
102 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer);
103
104 // Remove an observer.
105 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer);
106
107 protected: 121 protected:
108 virtual ~AutofillWebDataBackend(); 122 virtual ~AutofillWebDataBackendImpl();
109 123
110 private: 124 private:
111 friend struct content::BrowserThread::DeleteOnThread< 125 friend struct content::BrowserThread::DeleteOnThread<
112 content::BrowserThread::DB>; 126 content::BrowserThread::DB>;
113 friend class base::DeleteHelper<AutofillWebDataBackend>; 127 friend class base::DeleteHelper<AutofillWebDataBackendImpl>;
114 // We have to friend RCTS<> so WIN shared-lib build is happy 128 // We have to friend RCTS<> so WIN shared-lib build is happy
115 // (http://crbug/112250). 129 // (http://crbug/112250).
116 friend class base::RefCountedThreadSafe<AutofillWebDataBackend, 130 friend class base::RefCountedThreadSafe<AutofillWebDataBackendImpl,
117 content::BrowserThread::DeleteOnDBThread>; 131 content::BrowserThread::DeleteOnDBThread>;
118 132
119 // Callbacks to ensure that sensitive info is destroyed if request is 133 // Callbacks to ensure that sensitive info is destroyed if request is
120 // cancelled. 134 // cancelled.
121 void DestroyAutofillProfileResult(const WDTypedResult* result); 135 void DestroyAutofillProfileResult(const WDTypedResult* result);
122 void DestroyAutofillCreditCardResult(const WDTypedResult* result); 136 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
123 137
124 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; 138 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_;
125 139
126 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend); 140 // WebDataServiceBackend allows direct access to DB.
141 // TODO(caitkp): Make it so nobody but us needs direct DB access anymore.
142 scoped_refptr<WebDataServiceBackend> web_database_backend_;
143
144 base::Closure on_changed_callback_;
145
146 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackendImpl);
127 }; 147 };
128 148
129 } // namespace autofill 149 } // namespace autofill
130 150
131 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 151 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698