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; |
31 class AutofillWebDataServiceObserverOnDBThread; | 32 class AutofillWebDataServiceObserverOnDBThread; |
32 class AutofillWebDataServiceObserverOnUIThread; | 33 class AutofillWebDataServiceObserverOnUIThread; |
33 class CreditCard; | 34 class CreditCard; |
35 class SyncableServiceBackend; | |
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 |
41 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, | 43 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, |
42 const ProfileErrorCallback& callback); | 44 const ProfileErrorCallback& callback); |
43 | 45 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 91 |
90 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); | 92 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
91 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); | 93 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); |
92 | 94 |
93 // Returns a SupportsUserData objects that may be used to store data | 95 // Returns a SupportsUserData objects that may be used to store data |
94 // owned by the DB thread on this object. Should be called only from | 96 // owned by the DB thread on this object. Should be called only from |
95 // the DB thread, and will be destroyed on the DB thread soon after | 97 // the DB thread, and will be destroyed on the DB thread soon after |
96 // |ShutdownOnUIThread()| is called. | 98 // |ShutdownOnUIThread()| is called. |
97 base::SupportsUserData* GetDBUserData(); | 99 base::SupportsUserData* GetDBUserData(); |
98 | 100 |
101 // Takes a callback which will be called on the DBThread with a pointer to a | |
Ilya Sherman
2013/05/08 00:39:06
nit: "DBThread" -> "DB thread"; ditto below.
Cait (Slow)
2013/05/08 19:16:01
Done.
| |
102 // |SyncableServiceBackend|. This backend can be used to access or update the | |
103 // WebDatabase directly on the DBThread. | |
104 void GetSyncableBackend( | |
105 const base::Callback<void(SyncableServiceBackend*)>& callback); | |
Ilya Sherman
2013/05/08 00:39:06
Should this be returned as a scoped_refptr? What'
Cait (Slow)
2013/05/08 19:16:01
Both the backend and the syncable services are own
| |
106 | |
99 protected: | 107 protected: |
100 virtual ~AutofillWebDataService(); | 108 virtual ~AutofillWebDataService(); |
101 | 109 |
102 virtual void ShutdownOnDBThread(); | 110 virtual void ShutdownOnDBThread(); |
103 | 111 |
112 // This factory is used on the UIThread. All vended weak pointers are | |
Ilya Sherman
2013/05/08 00:39:06
nit: "UIThread" -> "UI thread"
Cait (Slow)
2013/05/08 19:16:01
Done.
| |
113 // invalidated in ShutdownOnUIThread(). | |
114 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_; | |
Ilya Sherman
2013/05/08 00:39:06
nit: Member variables should always have private v
Cait (Slow)
2013/05/08 19:16:01
Done.
| |
115 | |
104 private: | 116 private: |
105 // This makes the destructor public, and thus allows us to aggregate | 117 // This makes the destructor public, and thus allows us to aggregate |
106 // SupportsUserData. It is private by default to prevent incorrect | 118 // SupportsUserData. It is private by default to prevent incorrect |
107 // usage in class hierarchies where it is inherited by | 119 // usage in class hierarchies where it is inherited by |
108 // reference-counted objects. | 120 // reference-counted objects. |
109 class SupportsUserDataAggregatable : public base::SupportsUserData { | 121 class SupportsUserDataAggregatable : public base::SupportsUserData { |
110 public: | 122 public: |
111 SupportsUserDataAggregatable() {} | 123 SupportsUserDataAggregatable() {} |
112 virtual ~SupportsUserDataAggregatable() {} | 124 virtual ~SupportsUserDataAggregatable() {} |
113 private: | 125 private: |
(...skipping 10 matching lines...) Expand all Loading... | |
124 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; | 136 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; |
125 | 137 |
126 scoped_refptr<AutofillWebDataBackend> autofill_backend_; | 138 scoped_refptr<AutofillWebDataBackend> autofill_backend_; |
127 | 139 |
128 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); | 140 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); |
129 }; | 141 }; |
130 | 142 |
131 } // namespace autofill | 143 } // namespace autofill |
132 | 144 |
133 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ | 145 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ |
OLD | NEW |