Commit bf6cbdd2 authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

netlog: Emit values of consistent type for params trace event arg

Trace processor now merges args from begin/end event pairs with the
same names, but it doesn't support merging if the value type of the arg
changes between the two events.

Netlog was previously emitting 'params: ""', i.e. setting the "params"
arg to an empty string, if there were no params to be emitted. However,
"params" is usually an JSON-object-type argument. Thus, the value types
between empty and present arguments are inconsistent and cannot be
merged successfully by trace processor.

This patch changes netlog to output an empty object ('params: {}')
when the argument is empty instead.

Bug: 1048815
Change-Id: Id20f66e78bd6f89f81cf6d456925cf7a01aa1d75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050689
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740596}
parent bb4493b5
...@@ -37,7 +37,7 @@ class TracedValue : public base::trace_event::ConvertableToTraceFormat { ...@@ -37,7 +37,7 @@ class TracedValue : public base::trace_event::ConvertableToTraceFormat {
base::JSONWriter::Write(value_, &tmp); base::JSONWriter::Write(value_, &tmp);
*out += tmp; *out += tmp;
} else { } else {
*out += "\"\""; *out += "{}";
} }
} }
......
...@@ -418,12 +418,12 @@ TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) { ...@@ -418,12 +418,12 @@ TEST_F(TraceNetLogObserverTest, EventsWithAndWithoutParameters) {
actual_item2.source_type); actual_item2.source_type);
std::string item1_params; std::string item1_params;
std::string item2_params; const base::DictionaryValue* item2_params;
EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params)); EXPECT_TRUE(item1->GetString("args.params.foo", &item1_params));
EXPECT_EQ("bar", item1_params); EXPECT_EQ("bar", item1_params);
EXPECT_TRUE(item2->GetString("args.params", &item2_params)); EXPECT_TRUE(item2->GetDictionary("args.params", &item2_params));
EXPECT_TRUE(item2_params.empty()); EXPECT_TRUE(item2_params->empty());
} }
TEST(TraceNetLogObserverCategoryTest, DisabledCategory) { TEST(TraceNetLogObserverCategoryTest, DisabledCategory) {
......
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