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

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: Pure merge 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 (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 30 matching lines...) Expand all
41 AutofillWebDataService(); 41 AutofillWebDataService();
42 42
43 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, 43 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs,
44 const ProfileErrorCallback& callback); 44 const ProfileErrorCallback& callback);
45 45
46 // Retrieve an AutofillWebDataService for the given context. 46 // Retrieve an AutofillWebDataService for the given context.
47 // Can return NULL in some contexts. 47 // Can return NULL in some contexts.
48 static scoped_refptr<AutofillWebDataService> FromBrowserContext( 48 static scoped_refptr<AutofillWebDataService> FromBrowserContext(
49 content::BrowserContext* context); 49 content::BrowserContext* context);
50 50
51 // Notifies listeners on the UI thread that multiple changes have been made to
52 // to Autofill records of the database.
53 // NOTE: This method is intended to be called from the DB thread. It
54 // it asynchronously notifies listeners on the UI thread.
55 // |web_data_service| may be NULL for testing purposes.
56 static void NotifyOfMultipleAutofillChanges(
57 AutofillWebDataService* web_data_service);
58
59 // WebDataServiceBase implementation. 51 // WebDataServiceBase implementation.
60 virtual void ShutdownOnUIThread() OVERRIDE; 52 virtual void ShutdownOnUIThread() OVERRIDE;
61 53
62 // AutofillWebData implementation. 54 // AutofillWebData implementation.
63 virtual void AddFormFields( 55 virtual void AddFormFields(
64 const std::vector<FormFieldData>& fields) OVERRIDE; 56 const std::vector<FormFieldData>& fields) OVERRIDE;
65 virtual WebDataServiceBase::Handle GetFormValuesForElementName( 57 virtual WebDataServiceBase::Handle GetFormValuesForElementName(
66 const base::string16& name, 58 const base::string16& name,
67 const base::string16& prefix, 59 const base::string16& prefix,
68 int limit, 60 int limit,
69 WebDataServiceConsumer* consumer) OVERRIDE; 61 WebDataServiceConsumer* consumer) OVERRIDE;
70 62
71 virtual WebDataServiceBase::Handle HasFormElements( 63 virtual WebDataServiceBase::Handle HasFormElements(
72 WebDataServiceConsumer* consumer) OVERRIDE; 64 WebDataServiceConsumer* consumer) OVERRIDE;
73 virtual void RemoveFormElementsAddedBetween( 65 virtual void RemoveFormElementsAddedBetween(
74 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; 66 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE;
75 virtual void RemoveExpiredFormElements() OVERRIDE;
76 virtual void RemoveFormValueForElementName( 67 virtual void RemoveFormValueForElementName(
77 const base::string16& name, 68 const base::string16& name,
78 const base::string16& value) OVERRIDE; 69 const base::string16& value) OVERRIDE;
79 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE; 70 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE;
80 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE; 71 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE;
81 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE; 72 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE;
82 virtual WebDataServiceBase::Handle GetAutofillProfiles( 73 virtual WebDataServiceBase::Handle GetAutofillProfiles(
83 WebDataServiceConsumer* consumer) OVERRIDE; 74 WebDataServiceConsumer* consumer) OVERRIDE;
84 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; 75 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE;
85 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; 76 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE;
(...skipping 19 matching lines...) Expand all
105 96
106 // Takes a callback which will be called on the DB thread with a pointer to an 97 // Takes a callback which will be called on the DB thread with a pointer to an
107 // |AutofillWebdataBackend|. This backend can be used to access or update the 98 // |AutofillWebdataBackend|. This backend can be used to access or update the
108 // WebDatabase directly on the DB thread. 99 // WebDatabase directly on the DB thread.
109 void GetAutofillBackend( 100 void GetAutofillBackend(
110 const base::Callback<void(AutofillWebDataBackend*)>& callback); 101 const base::Callback<void(AutofillWebDataBackend*)>& callback);
111 102
112 protected: 103 protected:
113 virtual ~AutofillWebDataService(); 104 virtual ~AutofillWebDataService();
114 105
106 virtual void NotifyAutofillMultipleChangedOnUIThread();
107
115 virtual void ShutdownOnDBThread(); 108 virtual void ShutdownOnDBThread();
116 109
110 base::WeakPtr<AutofillWebDataService> AsWeakPtr() {
111 return weak_ptr_factory_.GetWeakPtr();
112 }
113
117 private: 114 private:
118 // This makes the destructor public, and thus allows us to aggregate 115 // This makes the destructor public, and thus allows us to aggregate
119 // SupportsUserData. It is private by default to prevent incorrect 116 // SupportsUserData. It is private by default to prevent incorrect
120 // usage in class hierarchies where it is inherited by 117 // usage in class hierarchies where it is inherited by
121 // reference-counted objects. 118 // reference-counted objects.
122 class SupportsUserDataAggregatable : public base::SupportsUserData { 119 class SupportsUserDataAggregatable : public base::SupportsUserData {
123 public: 120 public:
124 SupportsUserDataAggregatable() {} 121 SupportsUserDataAggregatable() {}
125 virtual ~SupportsUserDataAggregatable() {} 122 virtual ~SupportsUserDataAggregatable() {}
126 private: 123 private:
127 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); 124 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable);
128 }; 125 };
129 126
130 void NotifyAutofillMultipleChangedOnUIThread();
131
132 // Storage for user data to be accessed only on the DB thread. May 127 // Storage for user data to be accessed only on the DB thread. May
133 // be used e.g. for SyncableService subclasses that need to be owned 128 // be used e.g. for SyncableService subclasses that need to be owned
134 // by this object. Is created on first call to |GetDBUserData()|. 129 // by this object. Is created on first call to |GetDBUserData()|.
135 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; 130 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_;
136 131
137 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; 132 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_;
138 133
139 // This factory is used on the UI thread. All vended weak pointers are 134 // This factory is used on the UI thread. All vended weak pointers are
140 // invalidated in ShutdownOnUIThread(). 135 // invalidated in ShutdownOnUIThread().
141 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; 136 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_;
142 137
143 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_; 138 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_;
144 139
145 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); 140 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService);
146 }; 141 };
147 142
148 } // namespace autofill 143 } // namespace autofill
149 144
150 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 145 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698