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_SERVICE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_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 29 matching lines...) Expand all Loading... |
40 public WebDataServiceBase { | 40 public WebDataServiceBase { |
41 public: | 41 public: |
42 AutofillWebDataService(scoped_refptr<base::MessageLoopProxy> ui_thread, | 42 AutofillWebDataService(scoped_refptr<base::MessageLoopProxy> ui_thread, |
43 scoped_refptr<base::MessageLoopProxy> db_thread); | 43 scoped_refptr<base::MessageLoopProxy> db_thread); |
44 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, | 44 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, |
45 scoped_refptr<base::MessageLoopProxy> ui_thread, | 45 scoped_refptr<base::MessageLoopProxy> ui_thread, |
46 scoped_refptr<base::MessageLoopProxy> db_thread, | 46 scoped_refptr<base::MessageLoopProxy> db_thread, |
47 const ProfileErrorCallback& callback); | 47 const ProfileErrorCallback& callback); |
48 | 48 |
49 // WebDataServiceBase implementation. | 49 // WebDataServiceBase implementation. |
50 virtual void ShutdownOnUIThread() override; | 50 void ShutdownOnUIThread() override; |
51 | 51 |
52 // AutofillWebData implementation. | 52 // AutofillWebData implementation. |
53 virtual void AddFormFields( | 53 void AddFormFields(const std::vector<FormFieldData>& fields) override; |
54 const std::vector<FormFieldData>& fields) override; | 54 WebDataServiceBase::Handle GetFormValuesForElementName( |
55 virtual WebDataServiceBase::Handle GetFormValuesForElementName( | |
56 const base::string16& name, | 55 const base::string16& name, |
57 const base::string16& prefix, | 56 const base::string16& prefix, |
58 int limit, | 57 int limit, |
59 WebDataServiceConsumer* consumer) override; | 58 WebDataServiceConsumer* consumer) override; |
60 | 59 |
61 virtual WebDataServiceBase::Handle HasFormElements( | 60 WebDataServiceBase::Handle HasFormElements( |
62 WebDataServiceConsumer* consumer) override; | 61 WebDataServiceConsumer* consumer) override; |
63 virtual void RemoveFormElementsAddedBetween( | 62 void RemoveFormElementsAddedBetween(const base::Time& delete_begin, |
64 const base::Time& delete_begin, const base::Time& delete_end) override; | 63 const base::Time& delete_end) override; |
65 virtual void RemoveFormValueForElementName( | 64 void RemoveFormValueForElementName(const base::string16& name, |
66 const base::string16& name, | 65 const base::string16& value) override; |
67 const base::string16& value) override; | 66 void AddAutofillProfile(const AutofillProfile& profile) override; |
68 virtual void AddAutofillProfile(const AutofillProfile& profile) override; | 67 void UpdateAutofillProfile(const AutofillProfile& profile) override; |
69 virtual void UpdateAutofillProfile(const AutofillProfile& profile) override; | 68 void RemoveAutofillProfile(const std::string& guid) override; |
70 virtual void RemoveAutofillProfile(const std::string& guid) override; | 69 WebDataServiceBase::Handle GetAutofillProfiles( |
71 virtual WebDataServiceBase::Handle GetAutofillProfiles( | |
72 WebDataServiceConsumer* consumer) override; | 70 WebDataServiceConsumer* consumer) override; |
73 virtual void UpdateAutofillEntries( | 71 void UpdateAutofillEntries( |
74 const std::vector<AutofillEntry>& autofill_entries) override; | 72 const std::vector<AutofillEntry>& autofill_entries) override; |
75 virtual void AddCreditCard(const CreditCard& credit_card) override; | 73 void AddCreditCard(const CreditCard& credit_card) override; |
76 virtual void UpdateCreditCard(const CreditCard& credit_card) override; | 74 void UpdateCreditCard(const CreditCard& credit_card) override; |
77 virtual void RemoveCreditCard(const std::string& guid) override; | 75 void RemoveCreditCard(const std::string& guid) override; |
78 virtual WebDataServiceBase::Handle GetCreditCards( | 76 WebDataServiceBase::Handle GetCreditCards( |
79 WebDataServiceConsumer* consumer) override; | 77 WebDataServiceConsumer* consumer) override; |
80 virtual void RemoveAutofillDataModifiedBetween( | 78 void RemoveAutofillDataModifiedBetween(const base::Time& delete_begin, |
81 const base::Time& delete_begin, const base::Time& delete_end) override; | 79 const base::Time& delete_end) override; |
82 virtual void RemoveOriginURLsModifiedBetween( | 80 void RemoveOriginURLsModifiedBetween(const base::Time& delete_begin, |
83 const base::Time& delete_begin, const base::Time& delete_end) override; | 81 const base::Time& delete_end) override; |
84 | 82 |
85 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); | 83 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); |
86 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); | 84 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); |
87 | 85 |
88 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); | 86 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
89 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); | 87 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
90 | 88 |
91 // Returns a SupportsUserData objects that may be used to store data | 89 // Returns a SupportsUserData objects that may be used to store data |
92 // owned by the DB thread on this object. Should be called only from | 90 // owned by the DB thread on this object. Should be called only from |
93 // the DB thread, and will be destroyed on the DB thread soon after | 91 // the DB thread, and will be destroyed on the DB thread soon after |
94 // |ShutdownOnUIThread()| is called. | 92 // |ShutdownOnUIThread()| is called. |
95 base::SupportsUserData* GetDBUserData(); | 93 base::SupportsUserData* GetDBUserData(); |
96 | 94 |
97 // 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 |
98 // |AutofillWebdataBackend|. This backend can be used to access or update the | 96 // |AutofillWebdataBackend|. This backend can be used to access or update the |
99 // WebDatabase directly on the DB thread. | 97 // WebDatabase directly on the DB thread. |
100 void GetAutofillBackend( | 98 void GetAutofillBackend( |
101 const base::Callback<void(AutofillWebDataBackend*)>& callback); | 99 const base::Callback<void(AutofillWebDataBackend*)>& callback); |
102 | 100 |
103 protected: | 101 protected: |
104 virtual ~AutofillWebDataService(); | 102 ~AutofillWebDataService() override; |
105 | 103 |
106 virtual void NotifyAutofillMultipleChangedOnUIThread(); | 104 virtual void NotifyAutofillMultipleChangedOnUIThread(); |
107 | 105 |
108 base::WeakPtr<AutofillWebDataService> AsWeakPtr() { | 106 base::WeakPtr<AutofillWebDataService> AsWeakPtr() { |
109 return weak_ptr_factory_.GetWeakPtr(); | 107 return weak_ptr_factory_.GetWeakPtr(); |
110 } | 108 } |
111 | 109 |
112 private: | 110 private: |
113 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; | 111 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; |
114 | 112 |
115 // The MessageLoopProxy that this class uses as its UI thread. | 113 // The MessageLoopProxy that this class uses as its UI thread. |
116 scoped_refptr<base::MessageLoopProxy> ui_thread_; | 114 scoped_refptr<base::MessageLoopProxy> ui_thread_; |
117 | 115 |
118 // The MessageLoopProxy that this class uses as its DB thread. | 116 // The MessageLoopProxy that this class uses as its DB thread. |
119 scoped_refptr<base::MessageLoopProxy> db_thread_; | 117 scoped_refptr<base::MessageLoopProxy> db_thread_; |
120 | 118 |
121 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_; | 119 scoped_refptr<AutofillWebDataBackendImpl> autofill_backend_; |
122 | 120 |
123 // This factory is used on the UI thread. All vended weak pointers are | 121 // This factory is used on the UI thread. All vended weak pointers are |
124 // invalidated in ShutdownOnUIThread(). | 122 // invalidated in ShutdownOnUIThread(). |
125 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; | 123 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; |
126 | 124 |
127 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); | 125 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); |
128 }; | 126 }; |
129 | 127 |
130 } // namespace autofill | 128 } // namespace autofill |
131 | 129 |
132 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ | 130 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ |
OLD | NEW |