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