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

Unified Diff: components/sync/engine_impl/model_type_registry.cc

Issue 2420213002: [USS] Show USS counters in Types tab (Closed)
Patch Set: rebase Created 4 years, 2 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 | « components/sync/engine_impl/model_type_registry.h ('k') | components/sync/engine_impl/model_type_worker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/model_type_registry.cc
diff --git a/components/sync/engine_impl/model_type_registry.cc b/components/sync/engine_impl/model_type_registry.cc
index 8ba9b565e0758926ba0bc6b34e432f8f3e3a3a32..2d2079d9a814dd385822c15bb6abea163003dda0 100644
--- a/components/sync/engine_impl/model_type_registry.cc
+++ b/components/sync/engine_impl/model_type_registry.cc
@@ -17,6 +17,7 @@
#include "components/sync/engine/commit_queue.h"
#include "components/sync/engine/model_type_processor.h"
#include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h"
+#include "components/sync/engine_impl/cycle/non_blocking_type_debug_info_emitter.h"
#include "components/sync/engine_impl/directory_commit_contributor.h"
#include "components/sync/engine_impl/directory_update_handler.h"
#include "components/sync/engine_impl/model_type_worker.h"
@@ -99,7 +100,14 @@ void ModelTypeRegistry::SetEnabledDirectoryTypes(
DCHECK(worker_it != workers_map_.end());
scoped_refptr<ModelSafeWorker> worker = worker_it->second;
- DirectoryTypeDebugInfoEmitter* emitter = GetOrCreateEmitter(type);
+ DataTypeDebugInfoEmitter* emitter = GetEmitter(type);
+ if (emitter == nullptr) {
+ auto new_emitter = base::MakeUnique<DirectoryTypeDebugInfoEmitter>(
+ directory_, type, &type_debug_info_observers_);
+ emitter = new_emitter.get();
+ data_type_debug_info_emitter_map_.insert(
+ std::make_pair(type, std::move(new_emitter)));
+ }
auto updater = base::MakeUnique<DirectoryUpdateHandler>(directory_, type,
worker, emitter);
@@ -137,9 +145,18 @@ void ModelTypeRegistry::ConnectType(
if (encrypted_types_.Has(type))
cryptographer_copy = base::MakeUnique<Cryptographer>(*cryptographer_);
+ DataTypeDebugInfoEmitter* emitter = GetEmitter(type);
+ if (emitter == nullptr) {
+ auto new_emitter = base::MakeUnique<NonBlockingTypeDebugInfoEmitter>(
+ type, &type_debug_info_observers_);
+ emitter = new_emitter.get();
+ data_type_debug_info_emitter_map_.insert(
+ std::make_pair(type, std::move(new_emitter)));
+ }
+
auto worker = base::MakeUnique<ModelTypeWorker>(
type, activation_context->model_type_state, std::move(cryptographer_copy),
- nudge_handler_, std::move(activation_context->type_processor));
+ nudge_handler_, std::move(activation_context->type_processor), emitter);
// Initialize Processor -> Worker communication channel.
auto commit_queue_proxy = base::MakeUnique<CommitQueueProxy>(
@@ -223,7 +240,7 @@ bool ModelTypeRegistry::HasDirectoryTypeDebugInfoObserver(
}
void ModelTypeRegistry::RequestEmitDebugInfo() {
- for (const auto& kv : directory_type_debug_info_emitter_map_) {
+ for (const auto& kv : data_type_debug_info_emitter_map_) {
kv.second->EmitCommitCountersUpdate();
kv.second->EmitUpdateCountersUpdate();
kv.second->EmitStatusCountersUpdate();
@@ -284,18 +301,11 @@ void ModelTypeRegistry::OnEncryptionStateChanged() {
}
}
-DirectoryTypeDebugInfoEmitter* ModelTypeRegistry::GetOrCreateEmitter(
- ModelType type) {
- DirectoryTypeDebugInfoEmitter* raw_emitter = nullptr;
- auto it = directory_type_debug_info_emitter_map_.find(type);
- if (it != directory_type_debug_info_emitter_map_.end()) {
+DataTypeDebugInfoEmitter* ModelTypeRegistry::GetEmitter(ModelType type) {
+ DataTypeDebugInfoEmitter* raw_emitter = nullptr;
+ auto it = data_type_debug_info_emitter_map_.find(type);
+ if (it != data_type_debug_info_emitter_map_.end()) {
raw_emitter = it->second.get();
- } else {
- auto emitter = base::MakeUnique<DirectoryTypeDebugInfoEmitter>(
- directory_, type, &type_debug_info_observers_);
- raw_emitter = emitter.get();
- directory_type_debug_info_emitter_map_.insert(
- std::make_pair(type, std::move(emitter)));
}
return raw_emitter;
}
« no previous file with comments | « components/sync/engine_impl/model_type_registry.h ('k') | components/sync/engine_impl/model_type_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698