processor: Translate duplicate pids/tids during json export

The old trace viewer / TBMv2 can't handle it when there are multiple
"main" threads in the same process. It doesn't have the concept of
"pid/tid reuse", i.e. unique pids/tids, like trace processor.

Instead, we have to detect duplicate pids/tids when we export to json
and translate them to unique substitute values instead. This patch does
this by choosing unused values at the upper end of the uint32 space.

This patch also refactors ExportJson to use a helper object
(JsonExporter) to store some state.

Also updates thread/process name parsing in TrackEventParser to not set
thread/process names from UNSPECIFIED chrome types.

Bug: 130786269
Change-Id: I4b6ac5c7b892604e3fd4d3415bd239bd507df0fc
diff --git a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
index c6b789d..b963c4f 100644
--- a/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
+++ b/src/trace_processor/importers/proto/proto_trace_parser_unittest.cc
@@ -1050,8 +1050,8 @@
   EXPECT_CALL(*slice_,
               Scoped(1050000, process_2_track, StringId(3), StringId(4), 0, _))
       .WillOnce(DoAll(InvokeArgument<5>(&inserter), Return(3u)));
-  // Second slice should have a legacy_event.original_tid arg.
-  EXPECT_CALL(inserter, AddArg(_, _, Variadic::Integer(16)));
+  // Second slice should have a legacy_event.passthrough_utid arg.
+  EXPECT_CALL(inserter, AddArg(_, _, Variadic::UnsignedInteger(1u)));
 
   context_.sorter->ExtractEventsForced();