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

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: Fix memory leak in tests Created 6 years, 11 months 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
« no previous file with comments | « sync/sessions/sync_session_context.h ('k') | sync/sessions/sync_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/sessions/sync_session_context.cc
diff --git a/sync/sessions/sync_session_context.cc b/sync/sessions/sync_session_context.cc
index f8bc275b304bd22326f6bf94b08804bb063859da..36e6343b0fa59904e2ba3303fda8fd740f4972dd 100644
--- a/sync/sessions/sync_session_context.cc
+++ b/sync/sessions/sync_session_context.cc
@@ -13,33 +13,27 @@ namespace sessions {
SyncSessionContext::SyncSessionContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
ExtensionsActivity* extensions_activity,
const std::vector<SyncEngineEventListener*>& listeners,
DebugInfoGetter* debug_info_getter,
TrafficRecorder* traffic_recorder,
+ ModelTypeRegistry* model_type_registry,
bool keystore_encryption_enabled,
bool client_enabled_pre_commit_update_avoidance,
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),
debug_info_getter_(debug_info_getter),
traffic_recorder_(traffic_recorder),
+ model_type_registry_(model_type_registry),
keystore_encryption_enabled_(keystore_encryption_enabled),
invalidator_client_id_(invalidator_client_id),
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]));
- }
-
std::vector<SyncEngineEventListener*>::const_iterator it;
for (it = listeners.begin(); it != listeners.end(); ++it)
listeners_.AddObserver(*it);
@@ -48,31 +42,10 @@ 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));
- }
+ model_type_registry_->SetEnabledDirectoryTypes(routing_info);
}
} // namespace sessions
« no previous file with comments | « sync/sessions/sync_session_context.h ('k') | sync/sessions/sync_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698