| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "sync/sessions/model_type_registry.h" | 5 #include "sync/sessions/model_type_registry.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 size_t result2 = commit_contributor_map_.erase(it.Get()); | 79 size_t result2 = commit_contributor_map_.erase(it.Get()); |
| 80 DCHECK_EQ(1U, result1); | 80 DCHECK_EQ(1U, result1); |
| 81 DCHECK_EQ(1U, result2); | 81 DCHECK_EQ(1U, result2); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Clear the old instances of directory update handlers and commit | 84 // Clear the old instances of directory update handlers and commit |
| 85 // contributors, deleting their contents in the processs. | 85 // contributors, deleting their contents in the processs. |
| 86 directory_update_handlers_.clear(); | 86 directory_update_handlers_.clear(); |
| 87 directory_commit_contributors_.clear(); | 87 directory_commit_contributors_.clear(); |
| 88 | 88 |
| 89 enabled_directory_types_.Clear(); |
| 90 |
| 89 // Create new ones and add them to the appropriate containers. | 91 // Create new ones and add them to the appropriate containers. |
| 90 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin(); | 92 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin(); |
| 91 routing_iter != routing_info.end(); ++routing_iter) { | 93 routing_iter != routing_info.end(); ++routing_iter) { |
| 92 ModelType type = routing_iter->first; | 94 ModelType type = routing_iter->first; |
| 93 ModelSafeGroup group = routing_iter->second; | 95 ModelSafeGroup group = routing_iter->second; |
| 96 if (group == GROUP_NON_BLOCKING) |
| 97 continue; |
| 94 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator | 98 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator |
| 95 worker_it = workers_map_.find(group); | 99 worker_it = workers_map_.find(group); |
| 96 DCHECK(worker_it != workers_map_.end()); | 100 DCHECK(worker_it != workers_map_.end()); |
| 97 scoped_refptr<ModelSafeWorker> worker = worker_it->second; | 101 scoped_refptr<ModelSafeWorker> worker = worker_it->second; |
| 98 | 102 |
| 99 // DebugInfoEmitters are never deleted. Use existing one if we have it. | 103 // DebugInfoEmitters are never deleted. Use existing one if we have it. |
| 100 DirectoryTypeDebugInfoEmitter* emitter = NULL; | 104 DirectoryTypeDebugInfoEmitter* emitter = NULL; |
| 101 DirectoryTypeDebugInfoEmitterMap::iterator it = | 105 DirectoryTypeDebugInfoEmitterMap::iterator it = |
| 102 directory_type_debug_info_emitter_map_.find(type); | 106 directory_type_debug_info_emitter_map_.find(type); |
| 103 if (it != directory_type_debug_info_emitter_map_.end()) { | 107 if (it != directory_type_debug_info_emitter_map_.end()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 119 directory_commit_contributors_.push_back(committer); | 123 directory_commit_contributors_.push_back(committer); |
| 120 directory_update_handlers_.push_back(updater); | 124 directory_update_handlers_.push_back(updater); |
| 121 | 125 |
| 122 bool inserted1 = | 126 bool inserted1 = |
| 123 update_handler_map_.insert(std::make_pair(type, updater)).second; | 127 update_handler_map_.insert(std::make_pair(type, updater)).second; |
| 124 DCHECK(inserted1) << "Attempt to override existing type handler in map"; | 128 DCHECK(inserted1) << "Attempt to override existing type handler in map"; |
| 125 | 129 |
| 126 bool inserted2 = | 130 bool inserted2 = |
| 127 commit_contributor_map_.insert(std::make_pair(type, committer)).second; | 131 commit_contributor_map_.insert(std::make_pair(type, committer)).second; |
| 128 DCHECK(inserted2) << "Attempt to override existing type handler in map"; | 132 DCHECK(inserted2) << "Attempt to override existing type handler in map"; |
| 133 enabled_directory_types_.Put(type); |
| 129 } | 134 } |
| 130 | 135 |
| 131 enabled_directory_types_ = GetRoutingInfoTypes(routing_info); | |
| 132 DCHECK(Intersection(GetEnabledDirectoryTypes(), | 136 DCHECK(Intersection(GetEnabledDirectoryTypes(), |
| 133 GetEnabledNonBlockingTypes()).Empty()); | 137 GetEnabledNonBlockingTypes()).Empty()); |
| 134 } | 138 } |
| 135 | 139 |
| 136 void ModelTypeRegistry::ConnectSyncTypeToWorker( | 140 void ModelTypeRegistry::ConnectSyncTypeToWorker( |
| 137 ModelType type, | 141 ModelType type, |
| 138 scoped_ptr<syncer_v2::ActivationContext> activation_context) { | 142 scoped_ptr<syncer_v2::ActivationContext> activation_context) { |
| 139 DVLOG(1) << "Enabling an off-thread sync type: " << ModelTypeToString(type); | 143 DVLOG(1) << "Enabling an off-thread sync type: " << ModelTypeToString(type); |
| 140 | 144 |
| 141 // Initialize Worker -> Processor communication channel. | 145 // Initialize Worker -> Processor communication channel. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 model_type_workers_.begin(); | 288 model_type_workers_.begin(); |
| 285 it != model_type_workers_.end(); ++it) { | 289 it != model_type_workers_.end(); ++it) { |
| 286 if (encrypted_types_.Has((*it)->GetModelType())) { | 290 if (encrypted_types_.Has((*it)->GetModelType())) { |
| 287 (*it)->UpdateCryptographer( | 291 (*it)->UpdateCryptographer( |
| 288 make_scoped_ptr(new Cryptographer(*cryptographer_))); | 292 make_scoped_ptr(new Cryptographer(*cryptographer_))); |
| 289 } | 293 } |
| 290 } | 294 } |
| 291 } | 295 } |
| 292 | 296 |
| 293 ModelTypeSet ModelTypeRegistry::GetEnabledNonBlockingTypes() const { | 297 ModelTypeSet ModelTypeRegistry::GetEnabledNonBlockingTypes() const { |
| 294 ModelTypeSet enabled_off_thread_types; | 298 ModelTypeSet enabled_non_blocking_types; |
| 295 for (ScopedVector<syncer_v2::ModelTypeWorker>::const_iterator it = | 299 for (ScopedVector<syncer_v2::ModelTypeWorker>::const_iterator it = |
| 296 model_type_workers_.begin(); | 300 model_type_workers_.begin(); |
| 297 it != model_type_workers_.end(); ++it) { | 301 it != model_type_workers_.end(); ++it) { |
| 298 enabled_off_thread_types.Put((*it)->GetModelType()); | 302 enabled_non_blocking_types.Put((*it)->GetModelType()); |
| 299 } | 303 } |
| 300 return enabled_off_thread_types; | 304 return enabled_non_blocking_types; |
| 301 } | 305 } |
| 302 | 306 |
| 303 } // namespace syncer | 307 } // namespace syncer |
| OLD | NEW |