Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: components/autofill/browser/webdata/autofill_webdata_service.h

Issue 14679005: Create an AutofillBackend interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 SyncableServiceDelegate;
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:
41 typedef base::Callback<void(base::WeakPtr<SyncableServiceDelegate>)>
42 DelegateOnDBCallback;
43
39 AutofillWebDataService(); 44 AutofillWebDataService();
40 45
41 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, 46 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs,
42 const ProfileErrorCallback& callback); 47 const ProfileErrorCallback& callback);
43 48
44 // Retrieve an AutofillWebDataService for the given context. 49 // Retrieve an AutofillWebDataService for the given context.
45 // Can return NULL in some contexts. 50 // Can return NULL in some contexts.
46 static scoped_refptr<AutofillWebDataService> FromBrowserContext( 51 static scoped_refptr<AutofillWebDataService> FromBrowserContext(
47 content::BrowserContext* context); 52 content::BrowserContext* context);
48 53
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 94
90 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer); 95 void AddObserver(AutofillWebDataServiceObserverOnUIThread* observer);
91 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer); 96 void RemoveObserver(AutofillWebDataServiceObserverOnUIThread* observer);
92 97
93 // Returns a SupportsUserData objects that may be used to store data 98 // 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 99 // 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 100 // the DB thread, and will be destroyed on the DB thread soon after
96 // |ShutdownOnUIThread()| is called. 101 // |ShutdownOnUIThread()| is called.
97 base::SupportsUserData* GetDBUserData(); 102 base::SupportsUserData* GetDBUserData();
98 103
104 // Asynchronously gets an instance of |AutofillBackendDelegate|, which can be
105 // used to do work on the DB thread. This method is meant to be called from
106 // the UI thread, but the callback will be called on the DB thread.
107 // The delegate instance is owned by |AutofillWebDataBackend|, and so has the
108 // same lifetime as |AutofillWebDataService|.
109 void GetDelegateOnDB(const DelegateOnDBCallback& del_callback);
Ilya Sherman 2013/05/07 00:02:43 nit: Please don't use abbreviations like "del" in
110
99 protected: 111 protected:
100 virtual ~AutofillWebDataService(); 112 virtual ~AutofillWebDataService();
101 113
102 virtual void ShutdownOnDBThread(); 114 virtual void ShutdownOnDBThread();
103 115
116 // All vended weak pointers are invalidated in ShutdownDatabase().
Jói 2013/05/06 23:08:39 Suggest documenting which thread this factory is u
Cait (Slow) 2013/05/07 19:22:07 Done.
117 base::WeakPtrFactory<AutofillWebDataService> weak_ptr_factory_;
118
104 private: 119 private:
105 // This makes the destructor public, and thus allows us to aggregate 120 // This makes the destructor public, and thus allows us to aggregate
106 // SupportsUserData. It is private by default to prevent incorrect 121 // SupportsUserData. It is private by default to prevent incorrect
107 // usage in class hierarchies where it is inherited by 122 // usage in class hierarchies where it is inherited by
108 // reference-counted objects. 123 // reference-counted objects.
109 class SupportsUserDataAggregatable : public base::SupportsUserData { 124 class SupportsUserDataAggregatable : public base::SupportsUserData {
110 public: 125 public:
111 SupportsUserDataAggregatable() {} 126 SupportsUserDataAggregatable() {}
112 virtual ~SupportsUserDataAggregatable() {} 127 virtual ~SupportsUserDataAggregatable() {}
113 private: 128 private:
(...skipping 10 matching lines...) Expand all
124 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_; 139 ObserverList<AutofillWebDataServiceObserverOnUIThread> ui_observer_list_;
125 140
126 scoped_refptr<AutofillWebDataBackend> autofill_backend_; 141 scoped_refptr<AutofillWebDataBackend> autofill_backend_;
127 142
128 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); 143 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService);
129 }; 144 };
130 145
131 } // namespace autofill 146 } // namespace autofill
132 147
133 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ 148 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698