| 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_MODEL_SAFE_WORKER_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 6 #define COMPONENTS_SYNC_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 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/synchronization/atomic_flag.h" | 15 #include "base/synchronization/atomic_flag.h" |
| 16 #include "components/sync/base/model_type.h" | 16 #include "components/sync/base/model_type.h" |
| 17 #include "components/sync/base/syncer_error.h" | 17 #include "components/sync/base/syncer_error.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class DictionaryValue; | 20 class DictionaryValue; |
| 21 } // namespace base | 21 } // namespace base |
| 22 | 22 |
| 23 namespace syncer { | 23 namespace syncer { |
| 24 | 24 |
| 25 typedef base::Callback<enum SyncerError(void)> WorkCallback; | 25 using WorkCallback = base::Callback<enum SyncerError(void)>; |
| 26 | 26 |
| 27 enum ModelSafeGroup { | 27 enum ModelSafeGroup { |
| 28 GROUP_PASSIVE = 0, // Models that are just "passively" being synced; e.g. | 28 GROUP_PASSIVE = 0, // Models that are just "passively" being synced; e.g. |
| 29 // changes to these models don't need to be pushed to a | 29 // changes to these models don't need to be pushed to a |
| 30 // native model. | 30 // native model. |
| 31 GROUP_UI, // Models that live on UI thread and are being synced. | 31 GROUP_UI, // Models that live on UI thread and are being synced. |
| 32 GROUP_DB, // Models that live on DB thread and are being synced. | 32 GROUP_DB, // Models that live on DB thread and are being synced. |
| 33 GROUP_FILE, // Models that live on FILE thread and are being synced. | 33 GROUP_FILE, // Models that live on FILE thread and are being synced. |
| 34 GROUP_HISTORY, // Models that live on history thread and are being | 34 GROUP_HISTORY, // Models that live on history thread and are being |
| 35 // synced. | 35 // synced. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 // Whether the worker should do more work. Set when sync is disabled. | 85 // Whether the worker should do more work. Set when sync is disabled. |
| 86 base::AtomicFlag stopped_; | 86 base::AtomicFlag stopped_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker); | 88 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // A map that details which ModelSafeGroup each ModelType | 91 // A map that details which ModelSafeGroup each ModelType |
| 92 // belongs to. Routing info can change in response to the user enabling / | 92 // belongs to. Routing info can change in response to the user enabling / |
| 93 // disabling sync for certain types, as well as model association completions. | 93 // disabling sync for certain types, as well as model association completions. |
| 94 typedef std::map<ModelType, ModelSafeGroup> ModelSafeRoutingInfo; | 94 using ModelSafeRoutingInfo = std::map<ModelType, ModelSafeGroup>; |
| 95 | 95 |
| 96 // Caller takes ownership of return value. | 96 // Caller takes ownership of return value. |
| 97 std::unique_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( | 97 std::unique_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue( |
| 98 const ModelSafeRoutingInfo& routing_info); | 98 const ModelSafeRoutingInfo& routing_info); |
| 99 | 99 |
| 100 std::string ModelSafeRoutingInfoToString( | 100 std::string ModelSafeRoutingInfoToString( |
| 101 const ModelSafeRoutingInfo& routing_info); | 101 const ModelSafeRoutingInfo& routing_info); |
| 102 | 102 |
| 103 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); | 103 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); |
| 104 | 104 |
| 105 ModelSafeGroup GetGroupForModelType(const ModelType type, | 105 ModelSafeGroup GetGroupForModelType(const ModelType type, |
| 106 const ModelSafeRoutingInfo& routes); | 106 const ModelSafeRoutingInfo& routes); |
| 107 | 107 |
| 108 } // namespace syncer | 108 } // namespace syncer |
| 109 | 109 |
| 110 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 110 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| OLD | NEW |