| 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 SYNC_INTERNAL_API_PUBLIC_ENGINE_MODEL_SAFE_WORKER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ENGINE_MODEL_SAFE_WORKER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 17 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 18 #include "sync/base/sync_export.h" | 19 #include "sync/base/sync_export.h" |
| 19 #include "sync/internal_api/public/base/model_type.h" | 20 #include "sync/internal_api/public/base/model_type.h" |
| 20 #include "sync/internal_api/public/util/syncer_error.h" | 21 #include "sync/internal_api/public/util/syncer_error.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class DictionaryValue; | 24 class DictionaryValue; |
| 24 } // namespace base | 25 } // namespace base |
| 25 | 26 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 // Signal set when work on native thread is finished or when native thread | 130 // Signal set when work on native thread is finished or when native thread |
| 130 // is to be destroyed so no more work can be done. | 131 // is to be destroyed so no more work can be done. |
| 131 base::WaitableEvent work_done_or_stopped_; | 132 base::WaitableEvent work_done_or_stopped_; |
| 132 | 133 |
| 133 // Notified when working thread of the worker is to be destroyed. | 134 // Notified when working thread of the worker is to be destroyed. |
| 134 WorkerLoopDestructionObserver* observer_; | 135 WorkerLoopDestructionObserver* observer_; |
| 135 | 136 |
| 136 // Remember working loop for posting task to unregister destruction | 137 // Remember working loop for posting task to unregister destruction |
| 137 // observation from sync thread when shutting down sync. | 138 // observation from sync thread when shutting down sync. |
| 138 base::Lock working_loop_lock_; | 139 base::Lock working_task_runner_lock_; |
| 139 base::MessageLoop* working_loop_; | 140 scoped_refptr<base::SingleThreadTaskRunner> working_task_runner_; |
| 140 | 141 |
| 141 // Callback passed with UnregisterForLoopDestruction. Normally this | 142 // Callback passed with UnregisterForLoopDestruction. Normally this |
| 142 // remains unset/unused and is stored only if |working_loop_| isn't | 143 // remains unset/unused and is stored only if |working_task_runner_| isn't |
| 143 // initialized by the time UnregisterForLoopDestruction is called. | 144 // initialized by the time UnregisterForLoopDestruction is called. |
| 144 // It is safe to copy and thread safe. | 145 // It is safe to copy and thread safe. |
| 145 // See comments in model_safe_worker.cc for more details. | 146 // See comments in model_safe_worker.cc for more details. |
| 146 base::Callback<void(ModelSafeGroup)> unregister_done_callback_; | 147 base::Callback<void(ModelSafeGroup)> unregister_done_callback_; |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 // A map that details which ModelSafeGroup each ModelType | 150 // A map that details which ModelSafeGroup each ModelType |
| 150 // belongs to. Routing info can change in response to the user enabling / | 151 // belongs to. Routing info can change in response to the user enabling / |
| 151 // disabling sync for certain types, as well as model association completions. | 152 // disabling sync for certain types, as well as model association completions. |
| 152 typedef std::map<ModelType, ModelSafeGroup> ModelSafeRoutingInfo; | 153 typedef std::map<ModelType, ModelSafeGroup> ModelSafeRoutingInfo; |
| 153 | 154 |
| 154 // Caller takes ownership of return value. | 155 // Caller takes ownership of return value. |
| 155 SYNC_EXPORT std::unique_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( | 156 SYNC_EXPORT std::unique_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( |
| 156 const ModelSafeRoutingInfo& routing_info); | 157 const ModelSafeRoutingInfo& routing_info); |
| 157 | 158 |
| 158 SYNC_EXPORT std::string ModelSafeRoutingInfoToString( | 159 SYNC_EXPORT std::string ModelSafeRoutingInfoToString( |
| 159 const ModelSafeRoutingInfo& routing_info); | 160 const ModelSafeRoutingInfo& routing_info); |
| 160 | 161 |
| 161 SYNC_EXPORT ModelTypeSet GetRoutingInfoTypes( | 162 SYNC_EXPORT ModelTypeSet GetRoutingInfoTypes( |
| 162 const ModelSafeRoutingInfo& routing_info); | 163 const ModelSafeRoutingInfo& routing_info); |
| 163 | 164 |
| 164 SYNC_EXPORT ModelSafeGroup GetGroupForModelType( | 165 SYNC_EXPORT ModelSafeGroup GetGroupForModelType( |
| 165 const ModelType type, | 166 const ModelType type, |
| 166 const ModelSafeRoutingInfo& routes); | 167 const ModelSafeRoutingInfo& routes); |
| 167 | 168 |
| 168 } // namespace syncer | 169 } // namespace syncer |
| 169 | 170 |
| 170 #endif // SYNC_INTERNAL_API_PUBLIC_ENGINE_MODEL_SAFE_WORKER_H_ | 171 #endif // SYNC_INTERNAL_API_PUBLIC_ENGINE_MODEL_SAFE_WORKER_H_ |
| OLD | NEW |