Chromium Code Reviews| 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 COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_UI_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 "base/synchronization/waitable_event.h" | |
| 11 #include "components/sync/engine/model_safe_worker.h" | 12 #include "components/sync/engine/model_safe_worker.h" |
| 12 | 13 |
| 13 namespace syncer { | 14 namespace syncer { |
| 14 | 15 |
| 15 // A ModelSafeWorker for UI models (e.g. bookmarks) that | 16 // A ModelSafeWorker for UI models (e.g. bookmarks) that |
| 16 // accepts work requests from the syncapi that need to be fulfilled | 17 // accepts work requests from the syncapi that need to be fulfilled |
| 17 // from the MessageLoop home to the native model. | 18 // from the MessageLoop home to the native model. |
| 18 class UIModelWorker : public ModelSafeWorker { | 19 class UIModelWorker : public ModelSafeWorker { |
| 19 public: | 20 public: |
| 20 explicit UIModelWorker(scoped_refptr<base::SingleThreadTaskRunner> ui_thread); | 21 explicit UIModelWorker( |
| 22 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread); | |
| 21 | 23 |
| 22 // ModelSafeWorker implementation. Called on syncapi SyncerThread. | 24 // ModelSafeWorker implementation. |
| 25 void RequestStop() override; | |
| 23 ModelSafeGroup GetModelSafeGroup() override; | 26 ModelSafeGroup GetModelSafeGroup() override; |
| 24 bool IsOnModelThread() override; | 27 bool IsOnModelThread() override; |
| 25 | 28 |
| 26 protected: | 29 protected: |
| 27 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override; | 30 SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) override; |
| 28 | 31 |
| 29 private: | 32 private: |
| 30 ~UIModelWorker() override; | 33 ~UIModelWorker() override; |
| 31 | 34 |
| 32 // A reference to the UI thread's task runner. | 35 // A reference to the UI thread's task runner. |
| 33 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; | 36 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; |
| 34 | 37 |
| 38 // Signal set when work on native thread is done, aborted due to the thread | |
| 39 // being torn down, or aborted do to sync stopping. | |
|
Nicolas Zea
2016/11/10 22:27:07
typo: do -> due
Nicolas Zea
2016/11/10 22:27:07
nit: i think it's worth explaining why we need thi
maxbogue
2016/11/12 03:19:52
Done.
maxbogue
2016/11/12 03:19:52
Done.
| |
| 40 base::WaitableEvent work_done_or_abandoned_; | |
| 41 | |
| 35 DISALLOW_COPY_AND_ASSIGN(UIModelWorker); | 42 DISALLOW_COPY_AND_ASSIGN(UIModelWorker); |
| 36 }; | 43 }; |
| 37 | 44 |
| 38 } // namespace syncer | 45 } // namespace syncer |
| 39 | 46 |
| 40 #endif // COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ | 47 #endif // COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_ |
| OLD | NEW |