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

Side by Side Diff: components/autofill/browser/webdata/autofill_webdata_backend.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 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_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
9 #include "base/observer_list.h" 10 #include "base/observer_list.h"
10 #include "components/autofill/browser/webdata/autofill_webdata.h" 11 #include "components/autofill/browser/webdata/autofill_webdata.h"
12 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
11 #include "components/autofill/common/form_field_data.h" 13 #include "components/autofill/common/form_field_data.h"
12 #include "components/webdata/common/web_data_results.h" 14 #include "components/webdata/common/web_data_results.h"
13 #include "components/webdata/common/web_data_service_base.h" 15 #include "components/webdata/common/web_data_service_base.h"
14 #include "components/webdata/common/web_data_service_consumer.h" 16 #include "components/webdata/common/web_data_service_consumer.h"
15 #include "components/webdata/common/web_database.h" 17 #include "components/webdata/common/web_database.h"
16 18
17 namespace autofill { 19 namespace autofill {
18 20
19 class AutofillChange; 21 class AutofillChange;
20 class AutofillProfile; 22 class AutofillProfile;
21 class AutofillWebDataServiceObserverOnDBThread; 23 class AutofillWebDataServiceObserverOnDBThread;
22 class CreditCard; 24 class CreditCard;
25 class SyncableAutofillDelegate;
23 26
24 // Backend implentation for the AutofillWebDataService. This class runs on the 27 // Backend implentation for the AutofillWebDataService. This class runs on the
25 // DB thread, as it handles reads and writes to the WebDatabase, and functions 28 // DB thread, as it handles reads and writes to the WebDatabase, and functions
26 // in it should only be called from that thread. Most functions here are just 29 // in it should only be called from that thread. Most functions here are just
27 // the implementations of the corresponding functions in the Autofill 30 // the implementations of the corresponding functions in the Autofill
28 // WebDataService. 31 // WebDataService.
29 class AutofillWebDataBackend 32 class AutofillWebDataBackend
30 : public base::RefCountedThreadSafe<AutofillWebDataBackend, 33 : public base::RefCountedThreadSafe<AutofillWebDataBackend,
31 content::BrowserThread::DeleteOnDBThread> { 34 content::BrowserThread::DeleteOnDBThread> {
32 public: 35 public:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 const base::Time& delete_begin, 97 const base::Time& delete_begin,
95 const base::Time& delete_end, 98 const base::Time& delete_end,
96 WebDatabase* db); 99 WebDatabase* db);
97 100
98 // Add an observer to be notified of changes on the DB thread. 101 // Add an observer to be notified of changes on the DB thread.
99 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer); 102 void AddObserver(AutofillWebDataServiceObserverOnDBThread* observer);
100 103
101 // Remove an observer. 104 // Remove an observer.
102 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer); 105 void RemoveObserver(AutofillWebDataServiceObserverOnDBThread* observer);
103 106
107 // Initializes |delegate_| if it has not already been initialized, and returns
108 // a ptr to it asynchonously via |callback|.
109 void GetDelegate(
110 const AutofillWebDataService::DelegateOnDBCallback& callback,
111 const base::Closure& on_changed_callback,
Ilya Sherman 2013/05/07 00:02:43 nit: Docs for this param
112 WebDatabase* db);
113
104 protected: 114 protected:
105 virtual ~AutofillWebDataBackend(); 115 virtual ~AutofillWebDataBackend();
106 116
107 private: 117 private:
108 friend struct content::BrowserThread::DeleteOnThread< 118 friend struct content::BrowserThread::DeleteOnThread<
109 content::BrowserThread::DB>; 119 content::BrowserThread::DB>;
110 friend class base::DeleteHelper<AutofillWebDataBackend>; 120 friend class base::DeleteHelper<AutofillWebDataBackend>;
111 // We have to friend RCTS<> so WIN shared-lib build is happy 121 // We have to friend RCTS<> so WIN shared-lib build is happy
112 // (http://crbug/112250). 122 // (http://crbug/112250).
113 friend class base::RefCountedThreadSafe<AutofillWebDataBackend, 123 friend class base::RefCountedThreadSafe<AutofillWebDataBackend,
114 content::BrowserThread::DeleteOnDBThread>; 124 content::BrowserThread::DeleteOnDBThread>;
115 125
116 // Callbacks to ensure that sensitive info is destroyed if request is 126 // Callbacks to ensure that sensitive info is destroyed if request is
117 // cancelled. 127 // cancelled.
118 void DestroyAutofillProfileResult(const WDTypedResult* result); 128 void DestroyAutofillProfileResult(const WDTypedResult* result);
119 void DestroyAutofillCreditCardResult(const WDTypedResult* result); 129 void DestroyAutofillCreditCardResult(const WDTypedResult* result);
120 130
121 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_; 131 ObserverList<AutofillWebDataServiceObserverOnDBThread> db_observer_list_;
122 132
133 // Delegate which allows clients to do autofill work directly on th DB thread.
134 // Owned by us.
135 scoped_ptr<SyncableAutofillDelegate> delegate_;
136
123 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend); 137 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataBackend);
124 }; 138 };
125 139
126 } // namespace autofill 140 } // namespace autofill
127 141
128 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_ 142 #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698