| 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" |
| 11 #include "base/memory/weak_ptr.h" |
| 11 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 12 #include "base/supports_user_data.h" | 13 #include "base/supports_user_data.h" |
| 13 #include "components/autofill/browser/webdata/autofill_webdata.h" | 14 #include "components/autofill/browser/webdata/autofill_webdata.h" |
| 14 #include "components/autofill/common/form_field_data.h" | 15 #include "components/autofill/common/form_field_data.h" |
| 15 #include "components/webdata/common/web_data_results.h" | 16 #include "components/webdata/common/web_data_results.h" |
| 16 #include "components/webdata/common/web_data_service_base.h" | 17 #include "components/webdata/common/web_data_service_base.h" |
| 17 #include "components/webdata/common/web_data_service_consumer.h" | 18 #include "components/webdata/common/web_data_service_consumer.h" |
| 18 #include "components/webdata/common/web_database.h" | 19 #include "components/webdata/common/web_database.h" |
| 19 | 20 |
| 20 class WebDatabaseService; | 21 class WebDatabaseService; |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 class BrowserContext; | 24 class BrowserContext; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace autofill { | 27 namespace autofill { |
| 27 | 28 |
| 28 class AutofillChange; | 29 class AutofillChange; |
| 29 class AutofillProfile; | 30 class AutofillProfile; |
| 30 class AutofillWebDataBackend; | 31 class AutofillWebDataBackend; |
| 32 class AutofillWebDataBackendImpl; |
| 31 class AutofillWebDataServiceObserverOnDBThread; | 33 class AutofillWebDataServiceObserverOnDBThread; |
| 32 class AutofillWebDataServiceObserverOnUIThread; | 34 class AutofillWebDataServiceObserverOnUIThread; |
| 33 class CreditCard; | 35 class CreditCard; |
| 34 | 36 |
| 35 // API for Autofill web data. | 37 // API for Autofill web data. |
| 36 class AutofillWebDataService : public AutofillWebData, | 38 class AutofillWebDataService : public AutofillWebData, |
| 37 public WebDataServiceBase { | 39 public WebDataServiceBase { |
| 38 public: | 40 public: |
| 39 AutofillWebDataService(); | 41 AutofillWebDataService(); |
| 40 | 42 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 94 |
| 93 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); | 95 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
| 94 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); | 96 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
| 95 | 97 |
| 96 // Returns a SupportsUserData objects that may be used to store data | 98 // Returns a SupportsUserData objects that may be used to store data |
| 97 // owned by the DB thread on this object. Should be called only from | 99 // owned by the DB thread on this object. Should be called only from |
| 98 // the DB thread, and will be destroyed on the DB thread soon after | 100 // the DB thread, and will be destroyed on the DB thread soon after |
| 99 // |ShutdownOnUIThread()| is called. | 101 // |ShutdownOnUIThread()| is called. |
| 100 base::SupportsUserData* GetDBUserData(); | 102 base::SupportsUserData* GetDBUserData(); |
| 101 | 103 |
| 104 // 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 |
| 106 // WebDatabase directly on the DB thread. |
| 107 void GetAutofillBackend( |
| 108 const base::Callback<void(AutofillWebDataBackend*)>& callback); |
| 109 |
| 102 protected: | 110 protected: |
| 103 virtual ~AutofillWebDataService(); | 111 virtual ~AutofillWebDataService(); |
| 104 | 112 |
| 105 virtual void ShutdownOnDBThread(); | 113 virtual void ShutdownOnDBThread(); |
| 106 | 114 |
| 107 private: | 115 private: |
| 108 // This makes the destructor public, and thus allows us to aggregate | 116 // This makes the destructor public, and thus allows us to aggregate |
| 109 // SupportsUserData. It is private by default to prevent incorrect | 117 // SupportsUserData. It is private by default to prevent incorrect |
| 110 // usage in class hierarchies where it is inherited by | 118 // usage in class hierarchies where it is inherited by |
| 111 // reference-counted objects. | 119 // reference-counted objects. |
| 112 class SupportsUserDataAggregatable : public base::SupportsUserData { | 120 class SupportsUserDataAggregatable : public base::SupportsUserData { |
| 113 public: | 121 public: |
| 114 SupportsUserDataAggregatable() {} | 122 SupportsUserDataAggregatable() {} |
| 115 virtual ~SupportsUserDataAggregatable() {} | 123 virtual ~SupportsUserDataAggregatable() {} |
| 116 private: | 124 private: |
| 117 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); | 125 DISALLOW_COPY_AND_ASSIGN(SupportsUserDataAggregatable); |
| 118 }; | 126 }; |
| 119 | 127 |
| 120 void NotifyAutofillMultipleChangedOnUIThread(); | 128 void NotifyAutofillMultipleChangedOnUIThread(); |
| 121 | 129 |
| 122 // Storage for user data to be accessed only on the DB thread. May | 130 // Storage for user data to be accessed only on the DB thread. May |
| 123 // be used e.g. for SyncableService subclasses that need to be owned | 131 // be used e.g. for SyncableService subclasses that need to be owned |
| 124 // by this object. Is created on first call to |GetDBUserData()|. | 132 // by this object. Is created on first call to |GetDBUserData()|. |
| 125 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; | 133 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; |
| 126 | 134 |
| 127 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; | 135 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; |
| 128 | 136 |
| 129 scoped_refptr<AutofillWebDataBackend> autofill_backend_; | 137 // This factory is used on the UI thread. All vended weak pointers are |
| 138 // invalidated in ShutdownOnUIThread(). |
| 139 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; |
| 140 |
| 141 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_; |
| 130 | 142 |
| 131 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); | 143 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); |
| 132 }; | 144 }; |
| 133 | 145 |
| 134 } // namespace autofill | 146 } // namespace autofill |
| 135 | 147 |
| 136 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ | 148 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ |
| OLD | NEW |