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

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

Issue 13898011: Move SupportsUserData code into AutofillWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and test fix 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 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 5 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/autofill/browser/autofill_country.h" 9 #include "components/autofill/browser/autofill_country.h"
10 #include "components/autofill/browser/autofill_profile.h" 10 #include "components/autofill/browser/autofill_profile.h"
(...skipping 29 matching lines...) Expand all
40 scoped_refptr<WebDatabaseService> wdbs, 40 scoped_refptr<WebDatabaseService> wdbs,
41 const ProfileErrorCallback& callback) 41 const ProfileErrorCallback& callback)
42 : WebDataServiceBase(wdbs, callback) { 42 : WebDataServiceBase(wdbs, callback) {
43 } 43 }
44 44
45 AutofillWebDataService::AutofillWebDataService() 45 AutofillWebDataService::AutofillWebDataService()
46 : WebDataServiceBase(NULL, 46 : WebDataServiceBase(NULL,
47 WebDataServiceBase::ProfileErrorCallback()) { 47 WebDataServiceBase::ProfileErrorCallback()) {
48 } 48 }
49 49
50 void AutofillWebDataService::ShutdownOnUIThread() {
51 BrowserThread::PostTask(
52 BrowserThread::DB, FROM_HERE,
53 base::Bind(&AutofillWebDataService::ShutdownOnDBThread, this));
54 WebDataServiceBase::ShutdownOnUIThread();
55 }
56
50 void AutofillWebDataService::AddFormFields( 57 void AutofillWebDataService::AddFormFields(
51 const std::vector<FormFieldData>& fields) { 58 const std::vector<FormFieldData>& fields) {
52 wdbs_->ScheduleDBTask(FROM_HERE, 59 wdbs_->ScheduleDBTask(FROM_HERE,
53 Bind(&AutofillWebDataService::AddFormElementsImpl, this, fields)); 60 Bind(&AutofillWebDataService::AddFormElementsImpl, this, fields));
54 } 61 }
55 62
56 WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName( 63 WebDataServiceBase::Handle AutofillWebDataService::GetFormValuesForElementName(
57 const base::string16& name, const base::string16& prefix, int limit, 64 const base::string16& name, const base::string16& prefix, int limit,
58 WebDataServiceConsumer* consumer) { 65 WebDataServiceConsumer* consumer) {
59 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE, 66 return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 ui_observer_list_.AddObserver(observer); 165 ui_observer_list_.AddObserver(observer);
159 } 166 }
160 167
161 void AutofillWebDataService::RemoveObserver( 168 void AutofillWebDataService::RemoveObserver(
162 AutofillWebDataServiceObserverOnUIThread* observer) { 169 AutofillWebDataServiceObserverOnUIThread* observer) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164 ui_observer_list_.RemoveObserver(observer); 171 ui_observer_list_.RemoveObserver(observer);
165 } 172 }
166 173
167 AutofillWebDataService::~AutofillWebDataService() {} 174 base::SupportsUserData* AutofillWebDataService::GetDBUserData() {
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
176 if (!db_thread_user_data_)
177 db_thread_user_data_.reset(new SupportsUserDataAggregatable());
178 return db_thread_user_data_.get();
179 }
180
181 void AutofillWebDataService::ShutdownOnDBThread() {
182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
183 db_thread_user_data_.reset();
184 }
185
186 AutofillWebDataService::~AutofillWebDataService() {
187 DCHECK(!db_thread_user_data_.get()) << "Forgot to call ShutdownOnUIThread?";
188 }
168 189
169 //////////////////////////////////////////////////////////////////////////////// 190 ////////////////////////////////////////////////////////////////////////////////
170 // 191 //
171 // Autofill implementation. 192 // Autofill implementation.
172 // 193 //
173 //////////////////////////////////////////////////////////////////////////////// 194 ////////////////////////////////////////////////////////////////////////////////
174 195
175 WebDatabase::State AutofillWebDataService::AddFormElementsImpl( 196 WebDatabase::State AutofillWebDataService::AddFormElementsImpl(
176 const std::vector<FormFieldData>& fields, WebDatabase* db) { 197 const std::vector<FormFieldData>& fields, WebDatabase* db) {
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 469 }
449 470
450 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { 471 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() {
451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 472 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
452 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, 473 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread,
453 ui_observer_list_, 474 ui_observer_list_,
454 AutofillMultipleChanged()); 475 AutofillMultipleChanged());
455 } 476 }
456 477
457 } // namespace autofill 478 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/webdata/autofill_webdata_service.h ('k') | components/webdata/common/web_data_service_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698