OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_UI_MODEL_WORKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/condition_variable.h" | 10 #include "base/condition_variable.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // A ModelSafeWorker for UI models (e.g. bookmarks) that accepts work requests | 24 // A ModelSafeWorker for UI models (e.g. bookmarks) that accepts work requests |
25 // from the syncapi that need to be fulfilled from the MessageLoop home to the | 25 // from the syncapi that need to be fulfilled from the MessageLoop home to the |
26 // native model. | 26 // native model. |
27 // | 27 // |
28 // Lifetime note: Instances of this class will generally be owned by the | 28 // Lifetime note: Instances of this class will generally be owned by the |
29 // SyncerThread. When the SyncerThread _object_ is destroyed, the | 29 // SyncerThread. When the SyncerThread _object_ is destroyed, the |
30 // UIModelWorker will be destroyed. The SyncerThread object is destroyed | 30 // UIModelWorker will be destroyed. The SyncerThread object is destroyed |
31 // after the actual syncer pthread has exited. | 31 // after the actual syncer pthread has exited. |
32 class UIModelWorker : public browser_sync::ModelSafeWorker { | 32 class UIModelWorker : public browser_sync::ModelSafeWorker { |
33 public: | 33 public: |
34 explicit UIModelWorker(MessageLoop* ui_loop) | 34 explicit UIModelWorker(MessageLoop* ui_loop); |
35 : state_(WORKING), | |
36 pending_work_(NULL), | |
37 syncapi_has_shutdown_(false), | |
38 ui_loop_(ui_loop), | |
39 syncapi_event_(&lock_) { | |
40 } | |
41 virtual ~UIModelWorker(); | 35 virtual ~UIModelWorker(); |
42 | 36 |
43 // A simple task to signal a waitable event after Run()ning a Closure. | 37 // A simple task to signal a waitable event after Run()ning a Closure. |
44 class CallDoWorkAndSignalTask : public Task { | 38 class CallDoWorkAndSignalTask : public Task { |
45 public: | 39 public: |
46 CallDoWorkAndSignalTask(Callback0::Type* work, | 40 CallDoWorkAndSignalTask(Callback0::Type* work, |
47 base::WaitableEvent* work_done, | 41 base::WaitableEvent* work_done, |
48 UIModelWorker* scheduler) | 42 UIModelWorker* scheduler) |
49 : work_(work), work_done_(work_done), scheduler_(scheduler) { | 43 : work_(work), work_done_(work_done), scheduler_(scheduler) { |
50 } | 44 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // SyncerThread has terminated. We only care about (1) when we are in Stop(), | 127 // SyncerThread has terminated. We only care about (1) when we are in Stop(), |
134 // because we have to manually Run() the task. | 128 // because we have to manually Run() the task. |
135 ConditionVariable syncapi_event_; | 129 ConditionVariable syncapi_event_; |
136 | 130 |
137 DISALLOW_COPY_AND_ASSIGN(UIModelWorker); | 131 DISALLOW_COPY_AND_ASSIGN(UIModelWorker); |
138 }; | 132 }; |
139 | 133 |
140 } // namespace browser_sync | 134 } // namespace browser_sync |
141 | 135 |
142 #endif // CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ | 136 #endif // CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ |
OLD | NEW |