| Index: sync/engine/model_type_registry.cc
|
| diff --git a/sync/engine/model_type_registry.cc b/sync/engine/model_type_registry.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..023c87262e7e68fd3da99510b43b390bd4e482d3
|
| --- /dev/null
|
| +++ b/sync/engine/model_type_registry.cc
|
| @@ -0,0 +1,60 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "sync/engine/model_type_registry.h"
|
| +
|
| +#include "sync/engine/committer_list.h"
|
| +#include "sync/engine/sync_directory_commit_contributor.h"
|
| +#include "sync/engine/sync_directory_update_handler.h"
|
| +#include "sync/engine/updater_list.h"
|
| +
|
| +namespace syncer {
|
| +
|
| +ModelTypeRegistry::ModelTypeRegistry(
|
| + const std::vector<ModelSafeWorker* >& workers,
|
| + syncable::Directory* directory)
|
| + : updater_list_(new UpdaterList()),
|
| + committer_list_(new CommitterList()),
|
| + directory_(directory) {
|
| + for (size_t i = 0u; i < workers.size(); ++i) {
|
| + workers_map_.insert(
|
| + std::make_pair(workers[i]->GetModelSafeGroup(), workers[i]));
|
| + }
|
| +}
|
| +
|
| +ModelTypeRegistry::~ModelTypeRegistry() {}
|
| +
|
| +void ModelTypeRegistry::SetEnabledDirectoryTypes(
|
| + const ModelSafeRoutingInfo& routing_info) {
|
| + updater_list_.reset(new UpdaterList());
|
| + committer_list_.reset(new CommitterList());
|
| +
|
| + for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin();
|
| + routing_iter != routing_info.end(); ++routing_iter) {
|
| + ModelType type = routing_iter->first;
|
| + ModelSafeGroup group = routing_iter->second;
|
| + std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator
|
| + worker_it = workers_map_.find(group);
|
| + DCHECK(worker_it != workers_map_.end());
|
| + scoped_refptr<ModelSafeWorker> worker = worker_it->second;
|
| +
|
| + SyncDirectoryCommitContributor* committer =
|
| + new SyncDirectoryCommitContributor(directory_, type);
|
| + SyncDirectoryUpdateHandler* updater =
|
| + new SyncDirectoryUpdateHandler(directory_, type, worker);
|
| +
|
| + committer_list_->RegisterType(type, committer);
|
| + updater_list_->RegisterType(type, updater);
|
| + }
|
| +}
|
| +
|
| +UpdaterList* ModelTypeRegistry::updater_list() {
|
| + return updater_list_.get();
|
| +}
|
| +
|
| +CommitterList* ModelTypeRegistry::committer_list() {
|
| + return committer_list_.get();
|
| +}
|
| +
|
| +} // namespace syncer
|
|
|