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

Side by Side Diff: components/autofill/browser/webdata/autofill_webdata_backend.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_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
7 7
8 #include "base/memory/ref_counted.h" 8 class WebDatabase;
9 #include "base/observer_list.h"
10 #include "components/autofill/browser/webdata/autofill_webdata.h"
11 #include "components/autofill/common/form_field_data.h"
12 #include "components/webdata/common/web_data_results.h"
13 #include "components/webdata/common/web_data_service_base.h"
14 #include "components/webdata/common/web_data_service_consumer.h"
15 #include "components/webdata/common/web_database.h"
16 9
17 namespace autofill { 10 namespace autofill {
18 11
19 class AutofillChange;
20 class AutofillProfile;
21 class AutofillWebDataServiceObserverOnDBThread; 12 class AutofillWebDataServiceObserverOnDBThread;
22 class CreditCard;
23 13
24 // Backend implentation for the AutofillWebDataService. This class runs on the 14 // Interface for doing Autofill work directly on the DB thread (used by
25 // DB thread, as it handles reads and writes to the WebDatabase, and functions 15 // Sync, mostly), without fully exposing the AutofillWebDataBackend to clients.
26 // in it should only be called from that thread. Most functions here are just 16 class AutofillWebDataBackend {
27 // the implementations of the corresponding functions in the Autofill
28 // WebDataService.
29 class AutofillWebDataBackend
30 : public base::RefCountedThreadSafe<AutofillWebDataBackend,
31 content::BrowserThread::DeleteOnDBThread> {
32 public: 17 public:
33 AutofillWebDataBackend(); 18 virtual ~AutofillWebDataBackend() {}
34 19
35 // Adds form fields to the web database. 20 // Get a raw pointer to the WebDatabase.
36 WebDatabase::State AddFormElements(const std::vector<FormFieldData>& fields, 21 virtual WebDatabase* GetDatabase() = 0;
37 WebDatabase* db);
38
39 // Returns a vector of values which have been entered in form input fields
40 // named |name|.
41 scoped_ptr<WDTypedResult> GetFormValuesForElementName(
42 const base::string16& name,
43 const base::string16& prefix,
44 int limit,
45 WebDatabase* db);
46
47 // Returns true if there are any elements in the form.
48 scoped_ptr<WDTypedResult> HasFormElements(WebDatabase* db);
49
50 // Removes form elements recorded for Autocomplete from the database.
51 WebDatabase::State RemoveFormElementsAddedBetween(
52 const base::Time& delete_begin,
53 const base::Time& delete_end,
54 WebDatabase* db);
55
56 // Removes expired form elements recorded for Autocomplete from the database.
57 WebDatabase::State RemoveExpiredFormElements(WebDatabase* db);
58
59 // Removes the Form-value |value| which has been entered in form input fields
60 // named |name| from the database.
61 WebDatabase::State RemoveFormValueForElementName(const base::string16& name,
62 const base::string16& value,
63 WebDatabase* db);
64
65 // Adds an Autofill profile to the web database.
66 WebDatabase::State AddAutofillProfile(const AutofillProfile& profile,
67 WebDatabase* db);
68
69 // Updates an Autofill profile in the web database.
70 WebDatabase::State UpdateAutofillProfile(const AutofillProfile& profile,
71 WebDatabase* db);
72
73 // Removes an Autofill profile from the web database.
74 WebDatabase::State RemoveAutofillProfile(const std::string& guid,
75 WebDatabase* db);
76
77 // Returns all Autofill profiles from the web database.
78 scoped_ptr<WDTypedResult> GetAutofillProfiles(WebDatabase* db);
79
80 // Adds a credit card to the web database.
81 WebDatabase::State AddCreditCard(const CreditCard& credit_card,
82 WebDatabase* db);
83
84 // Updates a credit card in the web database.
85 WebDatabase::State UpdateCreditCard(const CreditCard& credit_card,
86 WebDatabase* db);
87
88 // Removes a credit card from the web database.
89 WebDatabase::State RemoveCreditCard(const std::string& guid,
90 WebDatabase* db);
91
92 // Returns a vector of all credit cards from the web database.
93 scoped_ptr<WDTypedResult> GetCreditCards(WebDatabase* db);
94
95 // Removes Autofill records from the database.
96 WebDatabase::State RemoveAutofillDataModifiedBetween(
97 const base::Time& delete_begin,
98 const base::Time& delete_end,
99 WebDatabase* db);
100 22
101 // Add an observer to be notified of changes on the DB thread. 23 // Add an observer to be notified of changes on the DB thread.
102 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); 24 virtual void AddObserver(
25 AutofillWebDataServiceObserverOnDBThread* observer) = 0;
103 26
104 // Remove an observer. 27 // Remove an observer.
105 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); 28 virtual void RemoveObserver(
29 AutofillWebDataServiceObserverOnDBThread* observer) = 0;
106 30
107 protected: 31 // Remove expired elements from the database and commit if needed.
108 virtual ~AutofillWebDataBackend(); 32 virtual void RemoveExpiredFormElementsWrapper() = 0;
109 33
110 private: 34 // Notifies listeners on the UI thread that multiple changes have been made to
111 friend struct content::BrowserThread::DeleteOnThread< 35 // to Autofill records of the database.
112 content::BrowserThread::DB>; 36 // NOTE: This method is intended to be called from the DB thread. It
113 friend class base::DeleteHelper<AutofillWebDataBackend>; 37 // asynchronously notifies listeners on the UI thread.
114 // We have to friend RCTS<> so WIN shared-lib build is happy 38 virtual void NotifyOfMultipleAutofillChanges() = 0;
115 // (http://crbug/112250).
116 friend class base::RefCountedThreadSafe<AutofillWebDataBackend,
117 content::BrowserThread::DeleteOnDBThread>;
118
119 // Callbacks to ensure that sensitive info is destroyed if request is
120 // cancelled.
121 void DestroyAutofillProfileResult(const WDTypedResult* result);
122 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
123
124 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_;
125
126 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend);
127 }; 39 };
128 40
129 } // namespace autofill 41 } // namespace autofill
130 42
131 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 43 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
OLDNEW
« no previous file with comments | « components/autofill.gypi ('k') | components/autofill/browser/webdata/autofill_webdata_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698