Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sync/engine/model_type_registry.h" | |
| 6 | |
| 7 #include "sync/engine/committer_list.h" | |
| 8 #include "sync/engine/sync_directory_commit_contributor.h" | |
| 9 #include "sync/engine/sync_directory_update_handler.h" | |
| 10 #include "sync/engine/updater_list.h" | |
| 11 | |
| 12 namespace syncer { | |
| 13 | |
| 14 ModelTypeRegistry::ModelTypeRegistry( | |
| 15 syncable::Directory* directory, | |
| 16 const std::vector<ModelSafeWorker* >& workers) | |
| 17 : updater_list_(new UpdaterList()), | |
| 18 committer_list_(new CommitterList()), | |
| 19 directory_(directory) { | |
| 20 for (size_t i = 0u; i < workers.size(); ++i) { | |
| 21 workers_map_.insert( | |
| 22 std::make_pair(workers[i]->GetModelSafeGroup(), workers[i])); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 ModelTypeRegistry::~ModelTypeRegistry() {} | |
| 27 | |
| 28 void ModelTypeRegistry::SetEnabledDirectoryTypes( | |
| 29 const ModelSafeRoutingInfo& routing_info) { | |
| 30 updater_list_.reset(new UpdaterList()); | |
|
Nicolas Zea
2014/01/04 02:09:34
is it necessary to rebuild them on each reconfig?
rlarocque
2014/01/06 20:03:33
It's not necessary. However it is easy, and more
| |
| 31 committer_list_.reset(new CommitterList()); | |
| 32 | |
| 33 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin(); | |
| 34 routing_iter != routing_info.end(); ++routing_iter) { | |
| 35 ModelType type = routing_iter->first; | |
| 36 ModelSafeGroup group = routing_iter->second; | |
| 37 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator | |
| 38 worker_it = workers_map_.find(group); | |
| 39 DCHECK(worker_it != workers_map_.end()); | |
| 40 scoped_refptr<ModelSafeWorker> worker = worker_it->second; | |
| 41 | |
| 42 SyncDirectoryCommitContributor* committer = | |
| 43 new SyncDirectoryCommitContributor(directory_, type); | |
| 44 SyncDirectoryUpdateHandler* updater = | |
| 45 new SyncDirectoryUpdateHandler(directory_, type, worker); | |
| 46 | |
| 47 committer_list_->RegisterType(type, committer); | |
| 48 updater_list_->RegisterType(type, updater); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 UpdaterList* ModelTypeRegistry::updater_list() { | |
| 53 return updater_list_.get(); | |
| 54 } | |
| 55 | |
| 56 CommitterList* ModelTypeRegistry::committer_list() { | |
| 57 return committer_list_.get(); | |
| 58 } | |
| 59 | |
| 60 } // namespace syncer | |
| OLD | NEW |