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