| 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 #ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_ |
| 7 | 7 |
| 8 #include "sync/internal_api/public/engine/model_safe_worker.h" | 8 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 | 14 |
| 15 class PasswordStore; | 15 class PasswordStore; |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class WaitableEvent; | 18 class WaitableEvent; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace browser_sync { | 21 namespace browser_sync { |
| 22 | 22 |
| 23 // A syncer::ModelSafeWorker for password models that accepts requests | 23 // A syncer::ModelSafeWorker for password models that accepts requests |
| 24 // from the syncapi that need to be fulfilled on the password thread, | 24 // from the syncapi that need to be fulfilled on the password thread, |
| 25 // which is the DB thread on Linux and Windows. | 25 // which is the DB thread on Linux and Windows. |
| 26 class PasswordModelWorker : public syncer::ModelSafeWorker { | 26 class PasswordModelWorker : public syncer::ModelSafeWorker { |
| 27 public: | 27 public: |
| 28 explicit PasswordModelWorker( | 28 PasswordModelWorker(const scoped_refptr<PasswordStore>& password_store, |
| 29 const scoped_refptr<PasswordStore>& password_store); | 29 syncer::WorkerObserver* observer); |
| 30 | 30 |
| 31 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread. | 31 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread. |
| 32 virtual void RegisterForLoopDestruction() OVERRIDE; |
| 33 virtual syncer::ModelSafeGroup GetModelSafeGroup() OVERRIDE; |
| 34 |
| 35 protected: |
| 32 virtual syncer::SyncerError DoWorkAndWaitUntilDone( | 36 virtual syncer::SyncerError DoWorkAndWaitUntilDone( |
| 33 const syncer::WorkCallback& work) OVERRIDE; | 37 const syncer::WorkCallback& work, base::WaitableEvent* done) OVERRIDE; |
| 34 virtual syncer::ModelSafeGroup GetModelSafeGroup() OVERRIDE; | |
| 35 | 38 |
| 36 private: | 39 private: |
| 37 virtual ~PasswordModelWorker(); | 40 virtual ~PasswordModelWorker(); |
| 38 | 41 |
| 39 void CallDoWorkAndSignalTask( | 42 void CallDoWorkAndSignalTask( |
| 40 const syncer::WorkCallback& work, | 43 const syncer::WorkCallback& work, |
| 41 base::WaitableEvent* done, | 44 base::WaitableEvent* done, |
| 42 syncer::SyncerError* error); | 45 syncer::SyncerError* error); |
| 43 | 46 |
| 47 // Called on password thread to add PasswordModelWorker as destruction |
| 48 // observer. |
| 49 void RegisterForPasswordLoopDestruction(); |
| 50 |
| 44 scoped_refptr<PasswordStore> password_store_; | 51 scoped_refptr<PasswordStore> password_store_; |
| 45 DISALLOW_COPY_AND_ASSIGN(PasswordModelWorker); | 52 DISALLOW_COPY_AND_ASSIGN(PasswordModelWorker); |
| 46 }; | 53 }; |
| 47 | 54 |
| 48 } // namespace browser_sync | 55 } // namespace browser_sync |
| 49 | 56 |
| 50 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_ | 57 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_WORKER_H_ |
| OLD | NEW |