OLD | NEW |
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 Loading... |
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 17 matching lines...) Expand all Loading... |
103 | 94 |
104 // Takes a callback which will be called on the DB thread with a pointer to an | 95 // Takes a callback which will be called on the DB thread with a pointer to an |
105 // |AutofillWebdataBackend|. This backend can be used to access or update the | 96 // |AutofillWebdataBackend|. This backend can be used to access or update the |
106 // WebDatabase directly on the DB thread. | 97 // WebDatabase directly on the DB thread. |
107 void GetAutofillBackend( | 98 void GetAutofillBackend( |
108 const base::Callback<void(AutofillWebDataBackend*)>& callback); | 99 const base::Callback<void(AutofillWebDataBackend*)>& callback); |
109 | 100 |
110 protected: | 101 protected: |
111 virtual ~AutofillWebDataService(); | 102 virtual ~AutofillWebDataService(); |
112 | 103 |
| 104 virtual void NotifyAutofillMultipleChangedOnUIThread(); |
| 105 |
113 virtual void ShutdownOnDBThread(); | 106 virtual void ShutdownOnDBThread(); |
114 | 107 |
| 108 base::WeakPtr<AutofillWebDataService> AsWeakPtr() { |
| 109 return weak_ptr_factory_.GetWeakPtr(); |
| 110 } |
| 111 |
115 private: | 112 private: |
116 // This makes the destructor public, and thus allows us to aggregate | 113 // This makes the destructor public, and thus allows us to aggregate |
117 // SupportsUserData. It is private by default to prevent incorrect | 114 // SupportsUserData. It is private by default to prevent incorrect |
118 // usage in class hierarchies where it is inherited by | 115 // usage in class hierarchies where it is inherited by |
119 // reference-counted objects. | 116 // reference-counted objects. |
120 class SupportsUserDataAggregatable : public base::SupportsUserData { | 117 class SupportsUserDataAggregatable : public base::SupportsUserData { |
121 public: | 118 public: |
122 SupportsUserDataAggregatable() {} | 119 SupportsUserDataAggregatable() {} |
123 virtual ~SupportsUserDataAggregatable() {} | 120 virtual ~SupportsUserDataAggregatable() {} |
124 private: | 121 private: |
125 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); | 122 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); |
126 }; | 123 }; |
127 | 124 |
128 void NotifyAutofillMultipleChangedOnUIThread(); | |
129 | |
130 // Storage for user data to be accessed only on the DB thread. May | 125 // Storage for user data to be accessed only on the DB thread. May |
131 // be used e.g. for SyncableService subclasses that need to be owned | 126 // be used e.g. for SyncableService subclasses that need to be owned |
132 // by this object. Is created on first call to |GetDBUserData()|. | 127 // by this object. Is created on first call to |GetDBUserData()|. |
133 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; | 128 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; |
134 | 129 |
135 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; | 130 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; |
136 | 131 |
137 // This factory is used on the UI thread. All vended weak pointers are | 132 // This factory is used on the UI thread. All vended weak pointers are |
138 // invalidated in ShutdownOnUIThread(). | 133 // invalidated in ShutdownOnUIThread(). |
139 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; | 134 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; |
140 | 135 |
141 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_; | 136 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_; |
142 | 137 |
143 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); | 138 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); |
144 }; | 139 }; |
145 | 140 |
146 } // namespace autofill | 141 } // namespace autofill |
147 | 142 |
148 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ | 143 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ |
OLD | NEW |