Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: sync/sessions/sync_session_context.cc

Issue 93433006: sync: Introduce ModelTypeRegistry and helpers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split the type manager Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/sessions/sync_session_context.cc
diff --git a/sync/sessions/sync_session_context.cc b/sync/sessions/sync_session_context.cc
index aa5dfa54044d616eab9c216227762654164952eb..0ebfade9f6d92c8c0fad4f5078df3c3f156c41d0 100644
--- a/sync/sessions/sync_session_context.cc
+++ b/sync/sessions/sync_session_context.cc
@@ -23,8 +23,6 @@ SyncSessionContext::SyncSessionContext(
const std::string& invalidator_client_id)
: connection_manager_(connection_manager),
directory_(directory),
- update_handler_deleter_(&update_handler_map_),
- commit_contributor_deleter_(&commit_contributor_map_),
extensions_activity_(extensions_activity),
notifications_enabled_(false),
max_commit_batch_size_(kDefaultMaxCommitBatchSize),
@@ -35,10 +33,8 @@ SyncSessionContext::SyncSessionContext(
server_enabled_pre_commit_update_avoidance_(false),
client_enabled_pre_commit_update_avoidance_(
client_enabled_pre_commit_update_avoidance) {
- for (size_t i = 0u; i < workers.size(); ++i) {
- workers_.insert(
- std::make_pair(workers[i]->GetModelSafeGroup(), workers[i]));
- }
+ for (size_t i = 0u; i < workers.size(); ++i)
+ workers_.push_back(workers[i]);
std::vector<SyncEngineEventListener*>::const_iterator it;
for (it = listeners.begin(); it != listeners.end(); ++it)
@@ -48,31 +44,18 @@ SyncSessionContext::SyncSessionContext(
SyncSessionContext::~SyncSessionContext() {
}
-void SyncSessionContext::set_routing_info(
+void SyncSessionContext::SetRoutingInfo(
const ModelSafeRoutingInfo& routing_info) {
enabled_types_ = GetRoutingInfoTypes(routing_info);
- // TODO(rlarocque): This is not a good long-term solution. We must find a
- // better way to initialize the set of CommitContributors and UpdateHandlers.
- STLDeleteValues<UpdateHandlerMap>(&update_handler_map_);
- STLDeleteValues<CommitContributorMap>(&commit_contributor_map_);
- 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_.find(group);
- DCHECK(worker_it != workers_.end());
- scoped_refptr<ModelSafeWorker> worker = worker_it->second;
-
- SyncDirectoryUpdateHandler* handler =
- new SyncDirectoryUpdateHandler(directory(), type, worker);
- update_handler_map_.insert(std::make_pair(type, handler));
-
- SyncDirectoryCommitContributor* contributor =
- new SyncDirectoryCommitContributor(directory(), type);
- commit_contributor_map_.insert(std::make_pair(type, contributor));
- }
+ updater_list_.SetEnabledSyncDirectoryTypes(
+ workers_,
+ routing_info,
+ directory());
+ committer_list_.SetEnabledSyncDirectoryTypes(
+ workers_,
+ routing_info,
+ directory());
}
} // namespace sessions

Powered by Google App Engine
This is Rietveld 408576698