| 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" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "components/sync/base/scoped_event_signal.h" | 11 #include "components/sync/base/scoped_event_signal.h" |
| 12 #include "components/sync/base/syncer_error.h" | 12 #include "components/sync/base/syncer_error.h" |
| 13 #include "components/sync/engine/model_safe_worker.h" | 13 #include "components/sync/engine/model_safe_worker.h" |
| 14 | 14 |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 class WaitableEvent; | |
| 18 } // namespace base | |
| 19 | |
| 20 namespace syncer { | 15 namespace syncer { |
| 21 | 16 |
| 22 // A ModelSafeWorker for models that accept requests from the | 17 // A ModelSafeWorker for models that accept requests from the |
| 23 // syncapi that need to be fulfilled on a browser thread, for example | 18 // syncapi that need to be fulfilled on a browser thread, for example |
| 24 // autofill on the DB thread. | 19 // autofill on the DB thread. |
| 25 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc). | 20 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc). |
| 26 class BrowserThreadModelWorker : public ModelSafeWorker { | 21 class BrowserThreadModelWorker : public ModelSafeWorker { |
| 27 public: | 22 public: |
| 28 BrowserThreadModelWorker( | 23 BrowserThreadModelWorker( |
| 29 const scoped_refptr<base::SingleThreadTaskRunner>& runner, | 24 const scoped_refptr<base::SingleThreadTaskRunner>& runner, |
| 30 ModelSafeGroup group, | 25 ModelSafeGroup group); |
| 31 WorkerLoopDestructionObserver* observer); | |
| 32 | 26 |
| 33 // ModelSafeWorker implementation. Called on the sync thread. | 27 // ModelSafeWorker implementation. Called on the sync thread. |
| 34 void RegisterForLoopDestruction() override; | |
| 35 ModelSafeGroup GetModelSafeGroup() override; | 28 ModelSafeGroup GetModelSafeGroup() override; |
| 36 | 29 |
| 37 protected: | 30 protected: |
| 38 ~BrowserThreadModelWorker() override; | 31 ~BrowserThreadModelWorker() override; |
| 39 | 32 |
| 40 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override; | 33 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override; |
| 41 | 34 |
| 42 void CallDoWorkAndSignalTask(const WorkCallback& work, | 35 void CallDoWorkAndSignalTask(const WorkCallback& work, |
| 43 syncer::ScopedEventSignal scoped_event_signal, | 36 syncer::ScopedEventSignal scoped_event_signal, |
| 44 SyncerError* error); | 37 SyncerError* error); |
| 45 | 38 |
| 46 private: | 39 private: |
| 47 scoped_refptr<base::SingleThreadTaskRunner> runner_; | 40 scoped_refptr<base::SingleThreadTaskRunner> runner_; |
| 48 ModelSafeGroup group_; | 41 ModelSafeGroup group_; |
| 49 | 42 |
| 50 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); | 43 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); |
| 51 }; | 44 }; |
| 52 | 45 |
| 53 } // namespace syncer | 46 } // namespace syncer |
| 54 | 47 |
| 55 #endif // COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 48 #endif // COMPONENTS_SYNC_DRIVER_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| OLD | NEW |