| 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/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace autofill { | 27 namespace autofill { |
| 28 | 28 |
| 29 AutofillWebDataService::AutofillWebDataService( | 29 AutofillWebDataService::AutofillWebDataService( |
| 30 scoped_refptr<WebDatabaseService> wdbs, | 30 scoped_refptr<WebDatabaseService> wdbs, |
| 31 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, | 31 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, |
| 32 scoped_refptr<base::SingleThreadTaskRunner> db_thread, | 32 scoped_refptr<base::SingleThreadTaskRunner> db_thread, |
| 33 const ProfileErrorCallback& callback) | 33 const ProfileErrorCallback& callback) |
| 34 : WebDataServiceBase(wdbs, callback, ui_thread), | 34 : WebDataServiceBase(wdbs, callback, ui_thread), |
| 35 ui_thread_(ui_thread), | 35 ui_thread_(ui_thread), |
| 36 db_thread_(db_thread), | 36 db_thread_(db_thread), |
| 37 autofill_backend_(NULL), | 37 autofill_backend_(nullptr), |
| 38 weak_ptr_factory_(this) { | 38 weak_ptr_factory_(this) { |
| 39 base::Closure on_changed_callback = Bind( | 39 base::Closure on_changed_callback = Bind( |
| 40 &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, | 40 &AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread, |
| 41 weak_ptr_factory_.GetWeakPtr()); | 41 weak_ptr_factory_.GetWeakPtr()); |
| 42 | 42 base::Callback<void(syncer::ModelType)> on_sync_started_callback = Bind( |
| 43 &AutofillWebDataService::NotifySyncStartedOnUIThread, |
| 44 weak_ptr_factory_.GetWeakPtr()); |
| 43 autofill_backend_ = new AutofillWebDataBackendImpl( | 45 autofill_backend_ = new AutofillWebDataBackendImpl( |
| 44 wdbs_->GetBackend(), ui_thread_, db_thread_, on_changed_callback); | 46 wdbs_->GetBackend(), ui_thread_, db_thread_, on_changed_callback, |
| 47 on_sync_started_callback); |
| 45 } | 48 } |
| 46 | 49 |
| 47 AutofillWebDataService::AutofillWebDataService( | 50 AutofillWebDataService::AutofillWebDataService( |
| 48 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, | 51 scoped_refptr<base::SingleThreadTaskRunner> ui_thread, |
| 49 scoped_refptr<base::SingleThreadTaskRunner> db_thread) | 52 scoped_refptr<base::SingleThreadTaskRunner> db_thread) |
| 50 : WebDataServiceBase(NULL, | 53 : WebDataServiceBase(nullptr, |
| 51 WebDataServiceBase::ProfileErrorCallback(), | 54 WebDataServiceBase::ProfileErrorCallback(), |
| 52 ui_thread), | 55 ui_thread), |
| 53 ui_thread_(ui_thread), | 56 ui_thread_(ui_thread), |
| 54 db_thread_(db_thread), | 57 db_thread_(db_thread), |
| 55 autofill_backend_(new AutofillWebDataBackendImpl(NULL, | 58 autofill_backend_(new AutofillWebDataBackendImpl( |
| 56 ui_thread_, | 59 nullptr, |
| 57 db_thread_, | 60 ui_thread_, |
| 58 base::Closure())), | 61 db_thread_, |
| 59 weak_ptr_factory_(this) { | 62 base::Closure(), |
| 60 } | 63 base::Callback<void(syncer::ModelType)>())), |
| 64 weak_ptr_factory_(this) {} |
| 61 | 65 |
| 62 void AutofillWebDataService::ShutdownOnUIThread() { | 66 void AutofillWebDataService::ShutdownOnUIThread() { |
| 63 weak_ptr_factory_.InvalidateWeakPtrs(); | 67 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 64 db_thread_->PostTask(FROM_HERE, | 68 db_thread_->PostTask(FROM_HERE, |
| 65 Bind(&AutofillWebDataBackendImpl::ResetUserData, autofill_backend_)); | 69 Bind(&AutofillWebDataBackendImpl::ResetUserData, autofill_backend_)); |
| 66 WebDataServiceBase::ShutdownOnUIThread(); | 70 WebDataServiceBase::ShutdownOnUIThread(); |
| 67 } | 71 } |
| 68 | 72 |
| 69 void AutofillWebDataService::AddFormFields( | 73 void AutofillWebDataService::AddFormFields( |
| 70 const std::vector<FormFieldData>& fields) { | 74 const std::vector<FormFieldData>& fields) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 AutofillWebDataService::~AutofillWebDataService() { | 293 AutofillWebDataService::~AutofillWebDataService() { |
| 290 } | 294 } |
| 291 | 295 |
| 292 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { | 296 void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { |
| 293 DCHECK(ui_thread_->BelongsToCurrentThread()); | 297 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 294 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, | 298 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
| 295 ui_observer_list_, | 299 ui_observer_list_, |
| 296 AutofillMultipleChanged()); | 300 AutofillMultipleChanged()); |
| 297 } | 301 } |
| 298 | 302 |
| 303 void AutofillWebDataService::NotifySyncStartedOnUIThread( |
| 304 syncer::ModelType model_type) { |
| 305 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 306 FOR_EACH_OBSERVER(AutofillWebDataServiceObserverOnUIThread, |
| 307 ui_observer_list_, |
| 308 SyncStarted(model_type)); |
| 309 } |
| 310 |
| 299 } // namespace autofill | 311 } // namespace autofill |
| OLD | NEW |