| 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 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 5 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 9 #include "components/autofill/core/browser/autofill_country.h" | 10 #include "components/autofill/core/browser/autofill_country.h" |
| 10 #include "components/autofill/core/browser/autofill_profile.h" | 11 #include "components/autofill/core/browser/autofill_profile.h" |
| 11 #include "components/autofill/core/browser/credit_card.h" | 12 #include "components/autofill/core/browser/credit_card.h" |
| 12 #include "components/autofill/core/browser/webdata/autofill_change.h" | 13 #include "components/autofill/core/browser/webdata/autofill_change.h" |
| 13 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 14 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
| 14 #include "components/autofill/core/browser/webdata/autofill_table.h" | 15 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 15 #include "components/autofill/core/browser/webdata/autofill_webdata_backend_impl
.h" | 16 #include "components/autofill/core/browser/webdata/autofill_webdata_backend_impl
.h" |
| 16 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" | 17 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" |
| 17 #include "components/autofill/core/common/form_field_data.h" | 18 #include "components/autofill/core/common/form_field_data.h" |
| 18 #include "components/webdata/common/web_data_service_backend.h" | 19 #include "components/webdata/common/web_data_service_backend.h" |
| 19 #include "components/webdata/common/web_database_service.h" | 20 #include "components/webdata/common/web_database_service.h" |
| 21 #include "content/public/browser/browser_thread.h" |
| 20 | 22 |
| 21 using base::Bind; | 23 using base::Bind; |
| 22 using base::Time; | 24 using base::Time; |
| 23 using content::BrowserThread; | 25 using content::BrowserThread; |
| 24 | 26 |
| 25 namespace autofill { | 27 namespace autofill { |
| 26 | 28 |
| 27 AutofillWebDataService::AutofillWebDataService( | 29 AutofillWebDataService::AutofillWebDataService( |
| 28 scoped_refptr<WebDatabaseService> wdbs, | 30 scoped_refptr<WebDatabaseService> wdbs, |
| 29 const ProfileErrorCallback& callback) | 31 const ProfileErrorCallback& callback) |
| 30 : WebDataServiceBase(wdbs, callback, | 32 : WebDataServiceBase(wdbs, callback, |
| 31 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), | 33 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), |
| 32 weak_ptr_factory_(this), | 34 weak_ptr_factory_(this), |
| 33 autofill_backend_(NULL) { | 35 autofill_backend_(NULL) { |
| 34 | 36 |
| 35 base::Closure on_changed_callback = Bind( | 37 base::Closure on_changed_callback = Bind( |
| 36 &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, | 38 &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, |
| 37 weak_ptr_factory_.GetWeakPtr()); | 39 weak_ptr_factory_.GetWeakPtr()); |
| 38 | 40 |
| 39 autofill_backend_ = new AutofillWebDataBackendImpl( | 41 autofill_backend_ = new AutofillWebDataBackendImpl( |
| 40 wdbs_->GetBackend(), | 42 wdbs_->GetBackend(), |
| 43 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 44 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 41 on_changed_callback); | 45 on_changed_callback); |
| 42 } | 46 } |
| 43 | 47 |
| 44 AutofillWebDataService::AutofillWebDataService() | 48 AutofillWebDataService::AutofillWebDataService() |
| 45 : WebDataServiceBase(NULL, WebDataServiceBase::ProfileErrorCallback(), | 49 : WebDataServiceBase(NULL, WebDataServiceBase::ProfileErrorCallback(), |
| 46 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), | 50 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), |
| 47 weak_ptr_factory_(this), | 51 weak_ptr_factory_(this), |
| 48 autofill_backend_(new AutofillWebDataBackendImpl(NULL, base::Closure())) { | 52 autofill_backend_(new AutofillWebDataBackendImpl(NULL, |
| 53 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 54 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 55 base::Closure())) { |
| 49 } | 56 } |
| 50 | 57 |
| 51 void AutofillWebDataService::ShutdownOnUIThread() { | 58 void AutofillWebDataService::ShutdownOnUIThread() { |
| 52 weak_ptr_factory_.InvalidateWeakPtrs(); | 59 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 53 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 60 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 54 Bind(&AutofillWebDataBackendImpl::ResetUserData, | 61 Bind(&AutofillWebDataBackendImpl::ResetUserData, |
| 55 autofill_backend_)); | 62 autofill_backend_)); |
| 56 WebDataServiceBase::ShutdownOnUIThread(); | 63 WebDataServiceBase::ShutdownOnUIThread(); |
| 57 } | 64 } |
| 58 | 65 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 215 } |
| 209 | 216 |
| 210 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { | 217 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { |
| 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 212 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, | 219 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
| 213 ui_observer_list_, | 220 ui_observer_list_, |
| 214 AutofillMultipleChanged()); | 221 AutofillMultipleChanged()); |
| 215 } | 222 } |
| 216 | 223 |
| 217 } // namespace autofill | 224 } // namespace autofill |
| OLD | NEW |