| OLD | NEW |
| 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_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H
_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H
_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMPL_H
_ | 6 #define COMPONENTS_AUTOFILL_CORE_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/ref_counted_delete_on_message_loop.h" | 9 #include "base/memory/ref_counted_delete_on_message_loop.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
| 13 #include "components/autofill/core/browser/webdata/autofill_webdata.h" | 13 #include "components/autofill/core/browser/webdata/autofill_webdata.h" |
| 14 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" | 14 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" |
| 15 #include "components/autofill/core/common/form_field_data.h" | 15 #include "components/autofill/core/common/form_field_data.h" |
| 16 #include "components/webdata/common/web_data_results.h" | 16 #include "components/webdata/common/web_data_results.h" |
| 17 #include "components/webdata/common/web_data_service_base.h" | 17 #include "components/webdata/common/web_data_service_base.h" |
| 18 #include "components/webdata/common/web_data_service_consumer.h" | 18 #include "components/webdata/common/web_data_service_consumer.h" |
| 19 #include "components/webdata/common/web_database.h" | 19 #include "components/webdata/common/web_database.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class MessageLoopProxy; | 22 class SingleThreadTaskRunner; |
| 23 } | 23 } |
| 24 | 24 |
| 25 class WebDatabaseBackend; | 25 class WebDatabaseBackend; |
| 26 | 26 |
| 27 namespace autofill { | 27 namespace autofill { |
| 28 | 28 |
| 29 class AutofillProfile; | 29 class AutofillProfile; |
| 30 class AutofillWebDataServiceObserverOnDBThread; | 30 class AutofillWebDataServiceObserverOnDBThread; |
| 31 class CreditCard; | 31 class CreditCard; |
| 32 | 32 |
| 33 // Backend implentation for the AutofillWebDataService. This class runs on the | 33 // Backend implentation for the AutofillWebDataService. This class runs on the |
| 34 // DB thread, as it handles reads and writes to the WebDatabase, and functions | 34 // DB thread, as it handles reads and writes to the WebDatabase, and functions |
| 35 // in it should only be called from that thread. Most functions here are just | 35 // in it should only be called from that thread. Most functions here are just |
| 36 // the implementations of the corresponding functions in the Autofill | 36 // the implementations of the corresponding functions in the Autofill |
| 37 // WebDataService. | 37 // WebDataService. |
| 38 // This class is destroyed on the DB thread. | 38 // This class is destroyed on the DB thread. |
| 39 class AutofillWebDataBackendImpl | 39 class AutofillWebDataBackendImpl |
| 40 : public base::RefCountedDeleteOnMessageLoop<AutofillWebDataBackendImpl>, | 40 : public base::RefCountedDeleteOnMessageLoop<AutofillWebDataBackendImpl>, |
| 41 public AutofillWebDataBackend { | 41 public AutofillWebDataBackend { |
| 42 public: | 42 public: |
| 43 // |web_database_backend| is used to access the WebDatabase directly for | 43 // |web_database_backend| is used to access the WebDatabase directly for |
| 44 // Sync-related operations. |ui_thread| and |db_thread| are the threads that | 44 // Sync-related operations. |ui_thread| and |db_thread| are the threads that |
| 45 // this class uses as its UI and DB threads respectively. | 45 // this class uses as its UI and DB threads respectively. |
| 46 // |on_changed_callback| is a closure which can be used to notify the UI | 46 // |on_changed_callback| is a closure which can be used to notify the UI |
| 47 // thread of changes initiated by Sync (this callback may be called multiple | 47 // thread of changes initiated by Sync (this callback may be called multiple |
| 48 // times). | 48 // times). |
| 49 AutofillWebDataBackendImpl( | 49 AutofillWebDataBackendImpl( |
| 50 scoped_refptr<WebDatabaseBackend> web_database_backend, | 50 scoped_refptr<WebDatabaseBackend> web_database_backend, |
| 51 scoped_refptr<base::MessageLoopProxy> ui_thread, | 51 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, |
| 52 scoped_refptr<base::MessageLoopProxy> db_thread, | 52 scoped_refptr<base::SingleThreadTaskRunner> db_thread, |
| 53 const base::Closure& on_changed_callback); | 53 const base::Closure& on_changed_callback); |
| 54 | 54 |
| 55 // AutofillWebDataBackend implementation. | 55 // AutofillWebDataBackend implementation. |
| 56 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer) override; | 56 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer) override; |
| 57 void RemoveObserver( | 57 void RemoveObserver( |
| 58 AutofillWebDataServiceObserverOnDBThread* observer) override; | 58 AutofillWebDataServiceObserverOnDBThread* observer) override; |
| 59 WebDatabase* GetDatabase() override; | 59 WebDatabase* GetDatabase() override; |
| 60 void RemoveExpiredFormElements() override; | 60 void RemoveExpiredFormElements() override; |
| 61 void NotifyOfMultipleAutofillChanges() override; | 61 void NotifyOfMultipleAutofillChanges() override; |
| 62 | 62 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // reference-counted objects. | 180 // reference-counted objects. |
| 181 class SupportsUserDataAggregatable : public base::SupportsUserData { | 181 class SupportsUserDataAggregatable : public base::SupportsUserData { |
| 182 public: | 182 public: |
| 183 SupportsUserDataAggregatable() {} | 183 SupportsUserDataAggregatable() {} |
| 184 ~SupportsUserDataAggregatable() override {} | 184 ~SupportsUserDataAggregatable() override {} |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); | 187 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 // The MessageLoopProxy that this class uses as its UI thread. | 190 // The task runner that this class uses as its UI thread. |
| 191 scoped_refptr<base::MessageLoopProxy> ui_thread_; | 191 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; |
| 192 | 192 |
| 193 // The MessageLoopProxy that this class uses as its DB thread. | 193 // The task runner that this class uses as its DB thread. |
| 194 scoped_refptr<base::MessageLoopProxy> db_thread_; | 194 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
| 195 | 195 |
| 196 // Storage for user data to be accessed only on the DB thread. May | 196 // Storage for user data to be accessed only on the DB thread. May |
| 197 // be used e.g. for SyncableService subclasses that need to be owned | 197 // be used e.g. for SyncableService subclasses that need to be owned |
| 198 // by this object. Is created on first call to |GetDBUserData()|. | 198 // by this object. Is created on first call to |GetDBUserData()|. |
| 199 scoped_ptr<SupportsUserDataAggregatable> user_data_; | 199 scoped_ptr<SupportsUserDataAggregatable> user_data_; |
| 200 | 200 |
| 201 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); | 201 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); |
| 202 | 202 |
| 203 // Callbacks to ensure that sensitive info is destroyed if request is | 203 // Callbacks to ensure that sensitive info is destroyed if request is |
| 204 // cancelled. | 204 // cancelled. |
| 205 void DestroyAutofillProfileResult(const WDTypedResult* result); | 205 void DestroyAutofillProfileResult(const WDTypedResult* result); |
| 206 void DestroyAutofillCreditCardResult(const WDTypedResult* result); | 206 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
| 207 | 207 |
| 208 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; | 208 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; |
| 209 | 209 |
| 210 // WebDatabaseBackend allows direct access to DB. | 210 // WebDatabaseBackend allows direct access to DB. |
| 211 // TODO(caitkp): Make it so nobody but us needs direct DB access anymore. | 211 // TODO(caitkp): Make it so nobody but us needs direct DB access anymore. |
| 212 scoped_refptr<WebDatabaseBackend> web_database_backend_; | 212 scoped_refptr<WebDatabaseBackend> web_database_backend_; |
| 213 | 213 |
| 214 base::Closure on_changed_callback_; | 214 base::Closure on_changed_callback_; |
| 215 | 215 |
| 216 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackendImpl); | 216 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackendImpl); |
| 217 }; | 217 }; |
| 218 | 218 |
| 219 } // namespace autofill | 219 } // namespace autofill |
| 220 | 220 |
| 221 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMP
L_H_ | 221 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_IMP
L_H_ |
| OLD | NEW |