Commit 98256bd5 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[USS] Show mtime and other fields in sync-internals Node Browser

This CL copies over EntityMetadata fields into EntityData for USS types
in ClientTagBasedModelTypeProcessor::MergeDataWithMetadataForDebugging()
so that the right values appear in chrome://sync-internals.

Bug: 904376
Change-Id: Ifd8ef57d32677770ac61f2d3fceaed5f939ba048
Reviewed-on: https://chromium-review.googlesource.com/c/1341993
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609334}
parent 7218ea22
...@@ -1406,22 +1406,29 @@ void ClientTagBasedModelTypeProcessor::MergeDataWithMetadataForDebugging( ...@@ -1406,22 +1406,29 @@ void ClientTagBasedModelTypeProcessor::MergeDataWithMetadataForDebugging(
std::string type_string = ModelTypeToString(type_); std::string type_string = ModelTypeToString(type_);
while (batch->HasNext()) { while (batch->HasNext()) {
KeyAndData data = batch->Next(); KeyAndData key_and_data = batch->Next();
std::unique_ptr<base::DictionaryValue> node = std::unique_ptr<EntityData> data = std::move(key_and_data.second);
data.second->ToDictionaryValue();
ProcessorEntityTracker* entity = GetEntityForStorageKey(data.first); // There is an overlap between EntityData fields from the bridge and
// Entity could be null if there are some unapplied changes. // EntityMetadata fields from the processor's entity tracker, metadata is
// the authoritative source of truth.
ProcessorEntityTracker* entity = GetEntityForStorageKey(key_and_data.first);
// Tracker could be null if there are some unapplied changes.
if (entity != nullptr) { if (entity != nullptr) {
std::unique_ptr<base::DictionaryValue> metadata = const sync_pb::EntityMetadata& metadata = entity->metadata();
EntityMetadataToValue(entity->metadata()); // Set id value as directory, "s" means server.
base::Value* server_id = metadata->FindKey("server_id"); data->id = "s" + metadata.server_id();
if (server_id) { data->creation_time = ProtoTimeToTime(metadata.creation_time());
// Set ID value as directory, "s" means server. data->modification_time = ProtoTimeToTime(metadata.modification_time());
node->SetString("ID", "s" + server_id->GetString()); data->client_tag_hash = metadata.client_tag_hash();
}
node->Set("metadata", std::move(metadata));
} }
std::unique_ptr<base::DictionaryValue> node = data->ToDictionaryValue();
node->SetString("modelType", type_string); node->SetString("modelType", type_string);
// Copy the whole metadata message into the dictionary (if existing).
if (entity != nullptr) {
node->Set("metadata", EntityMetadataToValue(entity->metadata()));
}
all_nodes->Append(std::move(node)); all_nodes->Append(std::move(node));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment