| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/sync/base/syncer_error.h" | 11 #include "components/sync/base/syncer_error.h" |
| 12 #include "components/sync/engine/model_safe_worker.h" | 12 #include "components/sync/engine/model_safe_worker.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class SingleThreadTaskRunner; | 15 class SingleThreadTaskRunner; |
| 16 class WaitableEvent; | 16 class WaitableEvent; |
| 17 } | 17 } // namespace base |
| 18 | 18 |
| 19 namespace browser_sync { | 19 namespace syncer { |
| 20 | 20 |
| 21 // A syncer::ModelSafeWorker for models that accept requests from the | 21 // A ModelSafeWorker for models that accept requests from the |
| 22 // syncapi that need to be fulfilled on a browser thread, for example | 22 // syncapi that need to be fulfilled on a browser thread, for example |
| 23 // autofill on the DB thread. | 23 // autofill on the DB thread. |
| 24 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc). | 24 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc). |
| 25 class BrowserThreadModelWorker : public syncer::ModelSafeWorker { | 25 class BrowserThreadModelWorker : public ModelSafeWorker { |
| 26 public: | 26 public: |
| 27 BrowserThreadModelWorker( | 27 BrowserThreadModelWorker( |
| 28 const scoped_refptr<base::SingleThreadTaskRunner>& runner, | 28 const scoped_refptr<base::SingleThreadTaskRunner>& runner, |
| 29 syncer::ModelSafeGroup group, | 29 ModelSafeGroup group, |
| 30 syncer::WorkerLoopDestructionObserver* observer); | 30 WorkerLoopDestructionObserver* observer); |
| 31 | 31 |
| 32 // syncer::ModelSafeWorker implementation. Called on the sync thread. | 32 // ModelSafeWorker implementation. Called on the sync thread. |
| 33 void RegisterForLoopDestruction() override; | 33 void RegisterForLoopDestruction() override; |
| 34 syncer::ModelSafeGroup GetModelSafeGroup() override; | 34 ModelSafeGroup GetModelSafeGroup() override; |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 ~BrowserThreadModelWorker() override; | 37 ~BrowserThreadModelWorker() override; |
| 38 | 38 |
| 39 syncer::SyncerError DoWorkAndWaitUntilDoneImpl( | 39 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override; |
| 40 const syncer::WorkCallback& work) override; | |
| 41 | 40 |
| 42 // Marked pure virtual so subclasses have to override, but there is | 41 // Marked pure virtual so subclasses have to override, but there is |
| 43 // an implementation that subclasses should use. This is so that | 42 // an implementation that subclasses should use. This is so that |
| 44 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks. | 43 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks. |
| 45 virtual void CallDoWorkAndSignalTask(const syncer::WorkCallback& work, | 44 virtual void CallDoWorkAndSignalTask(const WorkCallback& work, |
| 46 base::WaitableEvent* done, | 45 base::WaitableEvent* done, |
| 47 syncer::SyncerError* error); | 46 SyncerError* error); |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 scoped_refptr<base::SingleThreadTaskRunner> runner_; | 49 scoped_refptr<base::SingleThreadTaskRunner> runner_; |
| 51 syncer::ModelSafeGroup group_; | 50 ModelSafeGroup group_; |
| 52 | 51 |
| 53 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); | 52 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 } // namespace browser_sync | 55 } // namespace syncer |
| 57 | 56 |
| 58 #endif // COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 57 #endif // COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| OLD | NEW |