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 "sync/engine/sync_directory_commit_contributor.h" | 7 #include "sync/engine/directory_commit_contributor.h" |
8 #include "sync/engine/sync_directory_update_handler.h" | 8 #include "sync/engine/directory_update_handler.h" |
9 | 9 |
10 namespace syncer { | 10 namespace syncer { |
11 | 11 |
12 ModelTypeRegistry::ModelTypeRegistry( | 12 ModelTypeRegistry::ModelTypeRegistry( |
13 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | 13 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, |
14 syncable::Directory* directory) | 14 syncable::Directory* directory) |
15 : update_handler_deleter_(&update_handler_map_), | 15 : update_handler_deleter_(&update_handler_map_), |
16 commit_contributor_deleter_(&commit_contributor_map_), | 16 commit_contributor_deleter_(&commit_contributor_map_), |
17 directory_(directory) { | 17 directory_(directory) { |
18 for (size_t i = 0u; i < workers.size(); ++i) { | 18 for (size_t i = 0u; i < workers.size(); ++i) { |
(...skipping 13 matching lines...) Expand all Loading... |
32 | 32 |
33 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin(); | 33 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin(); |
34 routing_iter != routing_info.end(); ++routing_iter) { | 34 routing_iter != routing_info.end(); ++routing_iter) { |
35 ModelType type = routing_iter->first; | 35 ModelType type = routing_iter->first; |
36 ModelSafeGroup group = routing_iter->second; | 36 ModelSafeGroup group = routing_iter->second; |
37 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator | 37 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator |
38 worker_it = workers_map_.find(group); | 38 worker_it = workers_map_.find(group); |
39 DCHECK(worker_it != workers_map_.end()); | 39 DCHECK(worker_it != workers_map_.end()); |
40 scoped_refptr<ModelSafeWorker> worker = worker_it->second; | 40 scoped_refptr<ModelSafeWorker> worker = worker_it->second; |
41 | 41 |
42 SyncDirectoryCommitContributor* committer = | 42 DirectoryCommitContributor* committer = |
43 new SyncDirectoryCommitContributor(directory_, type); | 43 new DirectoryCommitContributor(directory_, type); |
44 SyncDirectoryUpdateHandler* updater = | 44 DirectoryUpdateHandler* updater = |
45 new SyncDirectoryUpdateHandler(directory_, type, worker); | 45 new DirectoryUpdateHandler(directory_, type, worker); |
46 | 46 |
47 bool inserted1 = | 47 bool inserted1 = |
48 update_handler_map_.insert(std::make_pair(type, updater)).second; | 48 update_handler_map_.insert(std::make_pair(type, updater)).second; |
49 DCHECK(inserted1) << "Attempt to override existing type handler in map"; | 49 DCHECK(inserted1) << "Attempt to override existing type handler in map"; |
50 | 50 |
51 bool inserted2 = | 51 bool inserted2 = |
52 commit_contributor_map_.insert(std::make_pair(type, committer)).second; | 52 commit_contributor_map_.insert(std::make_pair(type, committer)).second; |
53 DCHECK(inserted2) << "Attempt to override existing type handler in map"; | 53 DCHECK(inserted2) << "Attempt to override existing type handler in map"; |
54 | 54 |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 UpdateHandlerMap* ModelTypeRegistry::update_handler_map() { | 58 UpdateHandlerMap* ModelTypeRegistry::update_handler_map() { |
59 return &update_handler_map_; | 59 return &update_handler_map_; |
60 } | 60 } |
61 | 61 |
62 CommitContributorMap* ModelTypeRegistry::commit_contributor_map() { | 62 CommitContributorMap* ModelTypeRegistry::commit_contributor_map() { |
63 return &commit_contributor_map_; | 63 return &commit_contributor_map_; |
64 } | 64 } |
65 | 65 |
66 } // namespace syncer | 66 } // namespace syncer |
OLD | NEW |