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

Unified Diff: sync/sessions/model_type_registry.cc

Issue 260613002: sync: Expose DirectoryDebugInfoEmitters in engine (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor reconfiguration logic Created 6 years, 8 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/engine/directory_update_handler_unittest.cc ('k') | sync/sessions/model_type_registry_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/sessions/model_type_registry.cc
diff --git a/sync/sessions/model_type_registry.cc b/sync/sessions/model_type_registry.cc
index a41a7f30c3fff43ae50d79aab4f50af7054a9a78..63e0d98fc50eb601d02df195030f020c46e37610 100644
--- a/sync/sessions/model_type_registry.cc
+++ b/sync/sessions/model_type_registry.cc
@@ -31,21 +31,20 @@ ModelTypeRegistry::~ModelTypeRegistry() {}
void ModelTypeRegistry::SetEnabledDirectoryTypes(
const ModelSafeRoutingInfo& routing_info) {
// Remove all existing directory processors and delete them.
+ // The DebugInfoEmitters are not deleted, since we want to keep their counts
tim (not reviewing) 2014/04/30 23:24:50 I wouldn't use the term "not deleted" or "never de
rlarocque 2014/04/30 23:44:13 I figured that including disabled types would be a
+ // in case the type is ever re-enabled.
for (ModelTypeSet::Iterator it = enabled_directory_types_.First();
it.Good(); it.Inc()) {
size_t result1 = update_handler_map_.erase(it.Get());
size_t result2 = commit_contributor_map_.erase(it.Get());
- size_t result3 = directory_type_debug_info_emitter_map_.erase(it.Get());
DCHECK_EQ(1U, result1);
DCHECK_EQ(1U, result2);
- DCHECK_EQ(1U, result3);
}
// Clear the old instances of directory update handlers and commit
// contributors, deleting their contents in the processs.
directory_update_handlers_.clear();
directory_commit_contributors_.clear();
- directory_type_debug_info_emitters_.clear();
// Create new ones and add them to the appropriate containers.
for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin();
@@ -57,18 +56,28 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
DCHECK(worker_it != workers_map_.end());
scoped_refptr<ModelSafeWorker> worker = worker_it->second;
- DirectoryTypeDebugInfoEmitter* emitter =
- new DirectoryTypeDebugInfoEmitter(directory_, type,
- &type_debug_info_observers_);
+ // DebugInfoEmitters are never deleted. Use existing one if we have it.
+ DirectoryTypeDebugInfoEmitter* emitter = NULL;
+ DirectoryTypeDebugInfoEmitterMap::iterator it =
+ directory_type_debug_info_emitter_map_.find(type);
+ if (it != directory_type_debug_info_emitter_map_.end()) {
+ emitter = it->second;
+ } else {
+ emitter = new DirectoryTypeDebugInfoEmitter(directory_, type,
+ &type_debug_info_observers_);
+ directory_type_debug_info_emitter_map_.insert(
+ std::make_pair(type, emitter));
+ directory_type_debug_info_emitters_.push_back(emitter);
+ }
+
DirectoryCommitContributor* committer =
- new DirectoryCommitContributor(directory_, type);
+ new DirectoryCommitContributor(directory_, type, emitter);
DirectoryUpdateHandler* updater =
- new DirectoryUpdateHandler(directory_, type, worker);
+ new DirectoryUpdateHandler(directory_, type, worker, emitter);
// These containers take ownership of their contents.
directory_commit_contributors_.push_back(committer);
directory_update_handlers_.push_back(updater);
- directory_type_debug_info_emitters_.push_back(emitter);
bool inserted1 =
update_handler_map_.insert(std::make_pair(type, updater)).second;
@@ -77,11 +86,6 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
bool inserted2 =
commit_contributor_map_.insert(std::make_pair(type, committer)).second;
DCHECK(inserted2) << "Attempt to override existing type handler in map";
-
- bool inserted3 =
- directory_type_debug_info_emitter_map_.insert(
- std::make_pair(type, emitter)).second;
- DCHECK(inserted3) << "Attempt to override existing type handler in map";
}
enabled_directory_types_ = GetRoutingInfoTypes(routing_info);
« no previous file with comments | « sync/engine/directory_update_handler_unittest.cc ('k') | sync/sessions/model_type_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698