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

Side by Side Diff: components/autofill/browser/webdata/autofill_webdata_service.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SERVICE_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 namespace autofill { 26 namespace autofill {
27 27
28 class AutofillChange; 28 class AutofillChange;
29 class AutofillProfile; 29 class AutofillProfile;
30 class AutofillWebDataBackend; 30 class AutofillWebDataBackend;
31 class AutofillWebDataServiceObserverOnDBThread; 31 class AutofillWebDataServiceObserverOnDBThread;
32 class AutofillWebDataServiceObserverOnUIThread; 32 class AutofillWebDataServiceObserverOnUIThread;
33 class CreditCard; 33 class CreditCard;
34 class AutofillBackendDelegate;
34 35
35 // API for Autofill web data. 36 // API for Autofill web data.
36 class AutofillWebDataService : public AutofillWebData, 37 class AutofillWebDataService : public AutofillWebData,
37 public WebDataServiceBase { 38 public WebDataServiceBase {
38 public: 39 public:
40 typedef base::Callback<void(AutofillBackendDelegate*)> DelegateOnDBCallback;
41
39 AutofillWebDataService(); 42 AutofillWebDataService();
40 43
41 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, 44 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs,
42 const ProfileErrorCallback& callback); 45 const ProfileErrorCallback& callback);
43 46
44 // Retrieve an AutofillWebDataService for the given context. 47 // Retrieve an AutofillWebDataService for the given context.
45 // Can return NULL in some contexts. 48 // Can return NULL in some contexts.
46 static scoped_refptr<AutofillWebDataService> FromBrowserContext( 49 static scoped_refptr<AutofillWebDataService> FromBrowserContext(
47 content::BrowserContext* context); 50 content::BrowserContext* context);
48 51
49 // Notifies listeners on the UI thread that multiple changes have been made to
50 // to Autofill records of the database.
51 // NOTE: This method is intended to be called from the DB thread. It
52 // it asynchronously notifies listeners on the UI thread.
53 // |web_data_service| may be NULL for testing purposes.
54 static void NotifyOfMultipleAutofillChanges(
55 AutofillWebDataService* web_data_service);
56
57 // WebDataServiceBase implementation. 52 // WebDataServiceBase implementation.
58 virtual void ShutdownOnUIThread() OVERRIDE; 53 virtual void ShutdownOnUIThread() OVERRIDE;
59 54
60 // AutofillWebData implementation. 55 // AutofillWebData implementation.
61 virtual void AddFormFields( 56 virtual void AddFormFields(
62 const std::vector<FormFieldData>& fields) OVERRIDE; 57 const std::vector<FormFieldData>& fields) OVERRIDE;
63 virtual WebDataServiceBase::Handle GetFormValuesForElementName( 58 virtual WebDataServiceBase::Handle GetFormValuesForElementName(
64 const base::string16& name, 59 const base::string16& name,
65 const base::string16& prefix, 60 const base::string16& prefix,
66 int limit, 61 int limit,
(...skipping 10 matching lines...) Expand all
77 virtual WebDataServiceBase::Handle GetAutofillProfiles( 72 virtual WebDataServiceBase::Handle GetAutofillProfiles(
78 WebDataServiceConsumer* consumer) OVERRIDE; 73 WebDataServiceConsumer* consumer) OVERRIDE;
79 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; 74 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE;
80 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; 75 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE;
81 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; 76 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE;
82 virtual WebDataServiceBase::Handle GetCreditCards( 77 virtual WebDataServiceBase::Handle GetCreditCards(
83 WebDataServiceConsumer* consumer) OVERRIDE; 78 WebDataServiceConsumer* consumer) OVERRIDE;
84 virtual void RemoveAutofillDataModifiedBetween( 79 virtual void RemoveAutofillDataModifiedBetween(
85 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; 80 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE;
86 81
87 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer);
88 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer);
89
90 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); 82 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer);
91 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); 83 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer);
92 84
93 void NotifyAutofillMultipleChangedOnUIThread(); 85 void NotifyAutofillMultipleChangedOnUIThread();
94 86
95 // Returns a SupportsUserData objects that may be used to store data 87 // Returns a SupportsUserData objects that may be used to store data
96 // owned by the DB thread on this object. Should be called only from 88 // owned by the DB thread on this object. Should be called only from
97 // the DB thread, and will be destroyed on the DB thread soon after 89 // the DB thread, and will be destroyed on the DB thread soon after
98 // |ShutdownOnUIThread()| is called. 90 // |ShutdownOnUIThread()| is called.
99 base::SupportsUserData* GetDBUserData(); 91 base::SupportsUserData* GetDBUserData();
100 92
101 virtual void ShutdownOnDBThread(); 93 virtual void ShutdownOnDBThread();
102 94
95 // Asynchronously gets an instance of |AutofillBackendDelegate|, which can be
96 // used to do work on the DB thread. This method is meant to be called from
97 // the UI thread, but the callback will be called on the DB thread.
98 // The delegate instance is owned by |AutofillWebDataBackend|, and so has the
99 // same lifetime as |AutofillWebDataService|.
100 void GetDelegateOnDB(const DelegateOnDBCallback& del_callback);
101
103 protected: 102 protected:
104 virtual ~AutofillWebDataService(); 103 virtual ~AutofillWebDataService();
105 104
106 private: 105 private:
107 // This makes the destructor public, and thus allows us to aggregate 106 // This makes the destructor public, and thus allows us to aggregate
108 // SupportsUserData. It is private by default to prevent incorrect 107 // SupportsUserData. It is private by default to prevent incorrect
109 // usage in class hierarchies where it is inherited by 108 // usage in class hierarchies where it is inherited by
110 // reference-counted objects. 109 // reference-counted objects.
111 class SupportsUserDataAggregatable : public base::SupportsUserData { 110 class SupportsUserDataAggregatable : public base::SupportsUserData {
112 public: 111 public:
(...skipping 10 matching lines...) Expand all
123 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; 122 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_;
124 123
125 scoped_refptr<AutofillWebDataBackend> autofill_backend_; 124 scoped_refptr<AutofillWebDataBackend> autofill_backend_;
126 125
127 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); 126 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService);
128 }; 127 };
129 128
130 } // namespace autofill 129 } // namespace autofill
131 130
132 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 131 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698