| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/macros.h" | 8 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 12 #include "components/sync/engine/model_safe_worker.h" | 10 #include "components/sync/engine/model_safe_worker.h" |
| 13 | 11 |
| 14 namespace password_manager { | 12 namespace password_manager { |
| 15 class PasswordStore; | 13 class PasswordStore; |
| 16 } | 14 } |
| 17 | 15 |
| 18 namespace browser_sync { | 16 namespace browser_sync { |
| 19 | 17 |
| 20 // A syncer::ModelSafeWorker for password models that accepts requests | 18 // A syncer::ModelSafeWorker for password models that accepts requests |
| 21 // from the syncapi that need to be fulfilled on the password thread, | 19 // from the syncapi that need to be fulfilled on the password thread, |
| 22 // which is the DB thread on Linux and Windows. | 20 // which is the DB thread on Linux and Windows. |
| 23 class PasswordModelWorker : public syncer::ModelSafeWorker { | 21 class PasswordModelWorker : public syncer::ModelSafeWorker { |
| 24 public: | 22 public: |
| 25 PasswordModelWorker( | 23 PasswordModelWorker( |
| 26 const scoped_refptr<password_manager::PasswordStore>& password_store, | 24 const scoped_refptr<password_manager::PasswordStore>& password_store); |
| 27 syncer::WorkerLoopDestructionObserver* observer); | |
| 28 | 25 |
| 29 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread. | 26 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread. |
| 30 void RegisterForLoopDestruction() override; | |
| 31 syncer::ModelSafeGroup GetModelSafeGroup() override; | 27 syncer::ModelSafeGroup GetModelSafeGroup() override; |
| 32 void RequestStop() override; | 28 void RequestStop() override; |
| 33 | 29 |
| 34 protected: | 30 protected: |
| 35 syncer::SyncerError DoWorkAndWaitUntilDoneImpl( | 31 syncer::SyncerError DoWorkAndWaitUntilDoneImpl( |
| 36 const syncer::WorkCallback& work) override; | 32 const syncer::WorkCallback& work) override; |
| 37 | 33 |
| 38 private: | 34 private: |
| 39 ~PasswordModelWorker() override; | 35 ~PasswordModelWorker() override; |
| 40 | 36 |
| 41 // Called on password thread to add PasswordModelWorker as destruction | |
| 42 // observer. | |
| 43 void RegisterForPasswordLoopDestruction(); | |
| 44 | |
| 45 // |password_store_| is used on password thread but released on UI thread. | 37 // |password_store_| is used on password thread but released on UI thread. |
| 46 // Protected by |password_store_lock_|. | 38 // Protected by |password_store_lock_|. |
| 47 base::Lock password_store_lock_; | 39 base::Lock password_store_lock_; |
| 48 scoped_refptr<password_manager::PasswordStore> password_store_; | 40 scoped_refptr<password_manager::PasswordStore> password_store_; |
| 49 DISALLOW_COPY_AND_ASSIGN(PasswordModelWorker); | 41 DISALLOW_COPY_AND_ASSIGN(PasswordModelWorker); |
| 50 }; | 42 }; |
| 51 | 43 |
| 52 } // namespace browser_sync | 44 } // namespace browser_sync |
| 53 | 45 |
| 54 #endif // COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_ | 46 #endif // COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_PASSWORD_MODEL_WORKER_H_ |
| OLD | NEW |