protos: Add v0 of new TrackEvent protos

Adds the new TrackEvent protos for events emitted by the TRACE_EVENT
macro instrumentation in client applications. Also adds the necessary
infrastructure for interned data to TracePacket.

The TrackEvent proto will eventually replace the ChromeTraceEvent and
ChromeEventBundle proto.

Bug: 123864183
Change-Id: I32963b8f53afcfe4892de919d8b27cd0a46a965a
diff --git a/Android.bp b/Android.bp
index 4d8e723..217284a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -27,11 +27,13 @@
     ":perfetto_protos_perfetto_trace_chrome_zero_gen",
     ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
     ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_zero_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_zero_gen",
     ":perfetto_protos_perfetto_trace_profiling_zero_gen",
     ":perfetto_protos_perfetto_trace_ps_zero_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_zero_gen",
+    ":perfetto_protos_perfetto_trace_track_event_zero_gen",
     ":perfetto_protos_perfetto_trace_trusted_lite_gen",
     ":perfetto_protos_perfetto_trace_zero_gen",
     ":perfetto_src_ipc_wire_protocol_gen",
@@ -124,11 +126,13 @@
     "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_zero_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_wire_protocol_gen_headers",
@@ -201,11 +205,13 @@
     ":perfetto_protos_perfetto_trace_chrome_zero_gen",
     ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
     ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_zero_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_zero_gen",
     ":perfetto_protos_perfetto_trace_profiling_zero_gen",
     ":perfetto_protos_perfetto_trace_ps_zero_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_zero_gen",
+    ":perfetto_protos_perfetto_trace_track_event_zero_gen",
     ":perfetto_protos_perfetto_trace_trusted_lite_gen",
     ":perfetto_protos_perfetto_trace_zero_gen",
     ":perfetto_src_ipc_wire_protocol_gen",
@@ -312,11 +318,13 @@
     "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_zero_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_wire_protocol_gen_headers",
@@ -372,11 +380,13 @@
     ":perfetto_protos_perfetto_trace_chrome_zero_gen",
     ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
     ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_zero_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_zero_gen",
     ":perfetto_protos_perfetto_trace_profiling_zero_gen",
     ":perfetto_protos_perfetto_trace_ps_zero_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_zero_gen",
+    ":perfetto_protos_perfetto_trace_track_event_zero_gen",
     ":perfetto_protos_perfetto_trace_trusted_lite_gen",
     ":perfetto_protos_perfetto_trace_zero_gen",
     ":perfetto_src_ipc_wire_protocol_gen",
@@ -466,11 +476,13 @@
     "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_zero_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_wire_protocol_gen_headers",
@@ -528,6 +540,8 @@
     ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
     ":perfetto_protos_perfetto_trace_ftrace_lite_gen",
     ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_lite_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_zero_gen",
     ":perfetto_protos_perfetto_trace_lite_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_lite_gen",
@@ -538,6 +552,8 @@
     ":perfetto_protos_perfetto_trace_ps_zero_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_lite_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_zero_gen",
+    ":perfetto_protos_perfetto_trace_track_event_lite_gen",
+    ":perfetto_protos_perfetto_trace_track_event_zero_gen",
     ":perfetto_protos_perfetto_trace_trusted_lite_gen",
     ":perfetto_protos_perfetto_trace_zero_gen",
     ":perfetto_src_ipc_wire_protocol_gen",
@@ -672,6 +688,8 @@
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_lite_gen_headers",
@@ -682,6 +700,8 @@
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_lite_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_wire_protocol_gen_headers",
@@ -1512,6 +1532,74 @@
   ],
 }
 
+// GN target: //protos/perfetto/trace/interned_data:lite_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_interned_data_lite_gen",
+  srcs: [
+    "protos/perfetto/trace/interned_data/interned_data.proto",
+  ],
+  tools: [
+    "aprotoc",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/interned_data/interned_data.pb.cc",
+  ],
+}
+
+// GN target: //protos/perfetto/trace/interned_data:lite_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_interned_data_lite_gen_headers",
+  srcs: [
+    "protos/perfetto/trace/interned_data/interned_data.proto",
+  ],
+  tools: [
+    "aprotoc",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/interned_data/interned_data.pb.h",
+  ],
+  export_include_dirs: [
+    "protos",
+  ],
+}
+
+// GN target: //protos/perfetto/trace/interned_data:zero_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_interned_data_zero_gen",
+  srcs: [
+    "protos/perfetto/trace/interned_data/interned_data.proto",
+  ],
+  tools: [
+    "aprotoc",
+    "perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/interned_data/interned_data.pbzero.cc",
+  ],
+}
+
+// GN target: //protos/perfetto/trace/interned_data:zero_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
+  srcs: [
+    "protos/perfetto/trace/interned_data/interned_data.proto",
+  ],
+  tools: [
+    "aprotoc",
+    "perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/interned_data/interned_data.pbzero.h",
+  ],
+  export_include_dirs: [
+    "protos",
+  ],
+}
+
 // GN target: //protos/perfetto/trace:lite_gen
 genrule {
   name: "perfetto_protos_perfetto_trace_lite_gen",
@@ -1915,6 +2003,106 @@
   ],
 }
 
+// GN target: //protos/perfetto/trace/track_event:lite_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_track_event_lite_gen",
+  srcs: [
+    "protos/perfetto/trace/track_event/debug_annotation.proto",
+    "protos/perfetto/trace/track_event/process_descriptor.proto",
+    "protos/perfetto/trace/track_event/task_execution.proto",
+    "protos/perfetto/trace/track_event/thread_descriptor.proto",
+    "protos/perfetto/trace/track_event/track_event.proto",
+  ],
+  tools: [
+    "aprotoc",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/track_event/debug_annotation.pb.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/process_descriptor.pb.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/task_execution.pb.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/thread_descriptor.pb.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/track_event.pb.cc",
+  ],
+}
+
+// GN target: //protos/perfetto/trace/track_event:lite_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_track_event_lite_gen_headers",
+  srcs: [
+    "protos/perfetto/trace/track_event/debug_annotation.proto",
+    "protos/perfetto/trace/track_event/process_descriptor.proto",
+    "protos/perfetto/trace/track_event/task_execution.proto",
+    "protos/perfetto/trace/track_event/thread_descriptor.proto",
+    "protos/perfetto/trace/track_event/track_event.proto",
+  ],
+  tools: [
+    "aprotoc",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/track_event/debug_annotation.pb.h",
+    "external/perfetto/protos/perfetto/trace/track_event/process_descriptor.pb.h",
+    "external/perfetto/protos/perfetto/trace/track_event/task_execution.pb.h",
+    "external/perfetto/protos/perfetto/trace/track_event/thread_descriptor.pb.h",
+    "external/perfetto/protos/perfetto/trace/track_event/track_event.pb.h",
+  ],
+  export_include_dirs: [
+    "protos",
+  ],
+}
+
+// GN target: //protos/perfetto/trace/track_event:zero_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_track_event_zero_gen",
+  srcs: [
+    "protos/perfetto/trace/track_event/debug_annotation.proto",
+    "protos/perfetto/trace/track_event/process_descriptor.proto",
+    "protos/perfetto/trace/track_event/task_execution.proto",
+    "protos/perfetto/trace/track_event/thread_descriptor.proto",
+    "protos/perfetto/trace/track_event/track_event.proto",
+  ],
+  tools: [
+    "aprotoc",
+    "perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/track_event/debug_annotation.pbzero.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/process_descriptor.pbzero.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/task_execution.pbzero.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/thread_descriptor.pbzero.cc",
+    "external/perfetto/protos/perfetto/trace/track_event/track_event.pbzero.cc",
+  ],
+}
+
+// GN target: //protos/perfetto/trace/track_event:zero_gen
+genrule {
+  name: "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
+  srcs: [
+    "protos/perfetto/trace/track_event/debug_annotation.proto",
+    "protos/perfetto/trace/track_event/process_descriptor.proto",
+    "protos/perfetto/trace/track_event/task_execution.proto",
+    "protos/perfetto/trace/track_event/thread_descriptor.proto",
+    "protos/perfetto/trace/track_event/track_event.proto",
+  ],
+  tools: [
+    "aprotoc",
+    "perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_",
+  ],
+  cmd: "mkdir -p $(genDir)/external/perfetto/protos && $(location aprotoc) --cpp_out=$(genDir)/external/perfetto/protos --proto_path=external/perfetto/protos --plugin=protoc-gen-plugin=$(location perfetto_src_protozero_protoc_plugin_protoc_plugin___gn_standalone_toolchain_gcc_like_host_) --plugin_out=wrapper_namespace=pbzero:$(genDir)/external/perfetto/protos $(in)",
+  out: [
+    "external/perfetto/protos/perfetto/trace/track_event/debug_annotation.pbzero.h",
+    "external/perfetto/protos/perfetto/trace/track_event/process_descriptor.pbzero.h",
+    "external/perfetto/protos/perfetto/trace/track_event/task_execution.pbzero.h",
+    "external/perfetto/protos/perfetto/trace/track_event/thread_descriptor.pbzero.h",
+    "external/perfetto/protos/perfetto/trace/track_event/track_event.pbzero.h",
+  ],
+  export_include_dirs: [
+    "protos",
+  ],
+}
+
 // GN target: //protos/perfetto/trace:trusted_lite_gen
 genrule {
   name: "perfetto_protos_perfetto_trace_trusted_lite_gen",
@@ -2360,11 +2548,13 @@
     ":perfetto_protos_perfetto_trace_chrome_zero_gen",
     ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
     ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_zero_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_zero_gen",
     ":perfetto_protos_perfetto_trace_profiling_zero_gen",
     ":perfetto_protos_perfetto_trace_ps_zero_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_zero_gen",
+    ":perfetto_protos_perfetto_trace_track_event_zero_gen",
     ":perfetto_protos_perfetto_trace_trusted_lite_gen",
     ":perfetto_protos_perfetto_trace_zero_gen",
     ":perfetto_src_ipc_wire_protocol_gen",
@@ -2449,11 +2639,13 @@
     "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_zero_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_wire_protocol_gen_headers",
@@ -2468,11 +2660,13 @@
     "perfetto_protos_perfetto_trace_chrome_zero_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_zero_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_wire_protocol_gen_headers",
@@ -2497,12 +2691,14 @@
     ":perfetto_protos_perfetto_trace_chrome_lite_gen",
     ":perfetto_protos_perfetto_trace_filesystem_lite_gen",
     ":perfetto_protos_perfetto_trace_ftrace_lite_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_lite_gen",
     ":perfetto_protos_perfetto_trace_lite_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_lite_gen",
     ":perfetto_protos_perfetto_trace_profiling_lite_gen",
     ":perfetto_protos_perfetto_trace_ps_lite_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_lite_gen",
+    ":perfetto_protos_perfetto_trace_track_event_lite_gen",
   ],
   shared_libs: [
     "libprotobuf-cpp-lite",
@@ -2518,12 +2714,14 @@
     "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_lite_gen_headers",
     "perfetto_protos_perfetto_trace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_lite_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ps_lite_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_lite_gen_headers",
   ],
   export_generated_headers: [
     "perfetto_protos_perfetto_common_lite_gen_headers",
@@ -2532,12 +2730,14 @@
     "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_lite_gen_headers",
     "perfetto_protos_perfetto_trace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_lite_gen_headers",
     "perfetto_protos_perfetto_trace_profiling_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ps_lite_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_lite_gen_headers",
   ],
   defaults: [
     "perfetto_defaults",
@@ -2565,6 +2765,8 @@
     ":perfetto_protos_perfetto_trace_filesystem_zero_gen",
     ":perfetto_protos_perfetto_trace_ftrace_lite_gen",
     ":perfetto_protos_perfetto_trace_ftrace_zero_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_lite_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_zero_gen",
     ":perfetto_protos_perfetto_trace_lite_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_lite_gen",
@@ -2575,6 +2777,8 @@
     ":perfetto_protos_perfetto_trace_ps_zero_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_lite_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_zero_gen",
+    ":perfetto_protos_perfetto_trace_track_event_lite_gen",
+    ":perfetto_protos_perfetto_trace_track_event_zero_gen",
     ":perfetto_protos_perfetto_trace_trusted_lite_gen",
     ":perfetto_protos_perfetto_trace_zero_gen",
     ":perfetto_src_ipc_test_messages_gen",
@@ -2810,6 +3014,8 @@
     "perfetto_protos_perfetto_trace_filesystem_zero_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_zero_gen_headers",
     "perfetto_protos_perfetto_trace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_lite_gen_headers",
@@ -2820,6 +3026,8 @@
     "perfetto_protos_perfetto_trace_ps_zero_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_lite_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_zero_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_zero_gen_headers",
     "perfetto_protos_perfetto_trace_trusted_lite_gen_headers",
     "perfetto_protos_perfetto_trace_zero_gen_headers",
     "perfetto_src_ipc_test_messages_gen_headers",
@@ -2855,6 +3063,7 @@
     ":perfetto_protos_perfetto_trace_chrome_lite_gen",
     ":perfetto_protos_perfetto_trace_filesystem_lite_gen",
     ":perfetto_protos_perfetto_trace_ftrace_lite_gen",
+    ":perfetto_protos_perfetto_trace_interned_data_lite_gen",
     ":perfetto_protos_perfetto_trace_lite_gen",
     ":perfetto_protos_perfetto_trace_minimal_lite_gen",
     ":perfetto_protos_perfetto_trace_power_lite_gen",
@@ -2862,6 +3071,7 @@
     ":perfetto_protos_perfetto_trace_profiling_lite_gen",
     ":perfetto_protos_perfetto_trace_ps_lite_gen",
     ":perfetto_protos_perfetto_trace_sys_stats_lite_gen",
+    ":perfetto_protos_perfetto_trace_track_event_lite_gen",
     ":perfetto_protos_third_party_pprof_lite_gen",
     "src/base/event.cc",
     "src/base/file_utils.cc",
@@ -2943,6 +3153,7 @@
     "perfetto_protos_perfetto_trace_chrome_lite_gen_headers",
     "perfetto_protos_perfetto_trace_filesystem_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ftrace_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_interned_data_lite_gen_headers",
     "perfetto_protos_perfetto_trace_lite_gen_headers",
     "perfetto_protos_perfetto_trace_minimal_lite_gen_headers",
     "perfetto_protos_perfetto_trace_power_lite_gen_headers",
@@ -2950,6 +3161,7 @@
     "perfetto_protos_perfetto_trace_profiling_lite_gen_headers",
     "perfetto_protos_perfetto_trace_ps_lite_gen_headers",
     "perfetto_protos_perfetto_trace_sys_stats_lite_gen_headers",
+    "perfetto_protos_perfetto_trace_track_event_lite_gen_headers",
     "perfetto_protos_third_party_pprof_lite_gen_headers",
   ],
   defaults: [
diff --git a/protos/perfetto/trace/BUILD.gn b/protos/perfetto/trace/BUILD.gn
index 3dbef21..8c0cb0d 100644
--- a/protos/perfetto/trace/BUILD.gn
+++ b/protos/perfetto/trace/BUILD.gn
@@ -36,10 +36,12 @@
     "chrome:zero",
     "filesystem:zero",
     "ftrace:zero",
+    "interned_data:zero",
     "power:zero",
     "profiling:zero",
     "ps:zero",
     "sys_stats:zero",
+    "track_event:zero",
   ]
   sources = proto_sources_minimal + proto_sources
   proto_in_dir = "$perfetto_root_path/protos"
@@ -57,10 +59,12 @@
     "chrome:lite",
     "filesystem:lite",
     "ftrace:lite",
+    "interned_data:lite",
     "power:lite",
     "profiling:lite",
     "ps:lite",
     "sys_stats:lite",
+    "track_event:lite",
   ]
   if (perfetto_build_standalone) {
     generate_descriptor = "$perfetto_root_path/protos/trace/trace.descriptor"
diff --git a/protos/perfetto/trace/chrome/BUILD.gn b/protos/perfetto/trace/chrome/BUILD.gn
index 967a08c..f6ca853 100644
--- a/protos/perfetto/trace/chrome/BUILD.gn
+++ b/protos/perfetto/trace/chrome/BUILD.gn
@@ -26,6 +26,10 @@
 }
 
 protozero_library("zero") {
+  deps = [
+    "../interned_data:zero",
+    "../track_event:zero",
+  ]
   sources = chrome_proto_names
   proto_in_dir = "$perfetto_root_path/protos"
   proto_out_dir = "$perfetto_root_path/protos"
@@ -38,6 +42,8 @@
     ":lite",
     "../:minimal_lite",
     "../../config:lite",
+    "../interned_data:lite",
+    "../track_event:lite",
   ]
   sources = minimal_chrome_proto_names
   proto_in_dir = "$perfetto_root_path/protos"
diff --git a/protos/perfetto/trace/chrome/chrome_trace_packet.proto b/protos/perfetto/trace/chrome/chrome_trace_packet.proto
index 0c72eae..43b16e5 100644
--- a/protos/perfetto/trace/chrome/chrome_trace_packet.proto
+++ b/protos/perfetto/trace/chrome/chrome_trace_packet.proto
@@ -30,6 +30,10 @@
 import "perfetto/config/trace_config.proto";
 import "perfetto/trace/chrome/chrome_trace_event.proto";
 import "perfetto/trace/clock_snapshot.proto";
+import "perfetto/trace/interned_data/interned_data.proto";
+import "perfetto/trace/track_event/process_descriptor.proto";
+import "perfetto/trace/track_event/thread_descriptor.proto";
+import "perfetto/trace/track_event/track_event.proto";
 
 package perfetto.protos;
 
@@ -41,9 +45,19 @@
 message ChromeTracePacket {
   ChromeEventBundle chrome_events = 5;
 
+  ClockSnapshot clock_snapshot = 6;
+  TrackEvent track_event = 11;
+  ProcessDescriptor process_descriptor = 43;
+  ThreadDescriptor thread_descriptor = 44;
+
   // The original trace config.
   TraceConfig trace_config = 33;
   TraceStats trace_stats = 35;
 
-  ClockSnapshot clock_snapshot = 6;
+  uint32 trusted_packet_sequence_id = 10;
+
+  InternedData interned_data = 12;
+
+  bool incremental_state_cleared = 41;
+  bool previous_packet_dropped = 42;
 }
diff --git a/protos/perfetto/trace/interned_data/BUILD.gn b/protos/perfetto/trace/interned_data/BUILD.gn
new file mode 100644
index 0000000..6b68d81
--- /dev/null
+++ b/protos/perfetto/trace/interned_data/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("../../../../gn/perfetto.gni")
+import("../../../../gn/proto_library.gni")
+import("../../../../gn/protozero_library.gni")
+
+event_proto_names = [ "interned_data.proto" ]
+
+proto_library("lite") {
+  deps = [
+    "../track_event:lite",
+  ]
+  generate_python = false
+  sources = event_proto_names
+  proto_in_dir = "$perfetto_root_path/protos"
+  proto_out_dir = "$perfetto_root_path/protos"
+}
+
+protozero_library("zero") {
+  deps = [
+    "../track_event:zero",
+  ]
+  sources = event_proto_names
+  proto_in_dir = "$perfetto_root_path/protos"
+  proto_out_dir = "$perfetto_root_path/protos"
+  generator_plugin_options = "wrapper_namespace=pbzero"
+}
diff --git a/protos/perfetto/trace/interned_data/interned_data.proto b/protos/perfetto/trace/interned_data/interned_data.proto
new file mode 100644
index 0000000..266b061
--- /dev/null
+++ b/protos/perfetto/trace/interned_data/interned_data.proto
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+import "perfetto/trace/track_event/debug_annotation.proto";
+import "perfetto/trace/track_event/task_execution.proto";
+import "perfetto/trace/track_event/track_event.proto";
+
+package perfetto.protos;
+
+// ------------------------------ DATA INTERNING: ------------------------------
+// Interning indexes are built up gradually by adding the entries contained in
+// each TracePacket of the same packet sequence (packets emitted by the same
+// producer and TraceWriter, see |trusted_packet_sequence_id|). Thus, packets
+// can only refer to interned data from other packets in the same sequence.
+//
+// The writer will emit new entries when it encounters new internable values
+// that aren't yet in the index. Data in current and subsequent TracePackets can
+// then refer to the entry by its position (interning ID, abbreviated "iid") in
+// its index.
+//
+// Because of the incremental build-up, the interning index will miss data when
+// TracePackets are lost, e.g. because a chunk was overridden in the central
+// ring buffer. To avoid invalidation of the whole trace in such a case, the
+// index is periodically reset (see |incremental_state_cleared| in TracePacket).
+// When packet loss occurs, the reader will only lose interning data up to the
+// next reset.
+// -----------------------------------------------------------------------------
+
+// Message that contains new entries for the interning indices of a packet
+// sequence.
+//
+// The writer will usually emit new entries in the same TracePacket that first
+// refers to them (since the last reset of interning state). They may also be
+// emitted proactively in advance of referring to them in later packets.
+//
+// Next id: 5.
+message InternedData {
+  // Each field's message type needs to specify an |iid| field, which is the ID
+  // of the entry in the field's interning index. Each field constructs its own
+  // index, thus interning IDs are scoped to the tracing session and field
+  // (usually as a counter for efficient var-int encoding). It is illegal to
+  // override entries in an index (using the same iid for two different values)
+  // within the same tracing session, even after a reset of the emitted
+  // interning state.
+  repeated EventCategory event_categories = 1;
+  repeated LegacyEventName legacy_event_names = 2;
+  repeated DebugAnnotationName debug_annotation_names = 3;
+  repeated SourceLocation source_locations = 4;
+  // Note: field IDs up to 15 should be used for frequent data only.
+}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 72014a8..ee6fb8f 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -2305,6 +2305,52 @@
 
 // End of protos/perfetto/trace/ftrace/vmscan.proto
 
+// Begin of protos/perfetto/trace/interned_data/interned_data.proto
+
+// ------------------------------ DATA INTERNING: ------------------------------
+// Interning indexes are built up gradually by adding the entries contained in
+// each TracePacket of the same packet sequence (packets emitted by the same
+// producer and TraceWriter, see |trusted_packet_sequence_id|). Thus, packets
+// can only refer to interned data from other packets in the same sequence.
+//
+// The writer will emit new entries when it encounters new internable values
+// that aren't yet in the index. Data in current and subsequent TracePackets can
+// then refer to the entry by its position (interning ID, abbreviated "iid") in
+// its index.
+//
+// Because of the incremental build-up, the interning index will miss data when
+// TracePackets are lost, e.g. because a chunk was overridden in the central
+// ring buffer. To avoid invalidation of the whole trace in such a case, the
+// index is periodically reset (see |incremental_state_cleared| in TracePacket).
+// When packet loss occurs, the reader will only lose interning data up to the
+// next reset.
+// -----------------------------------------------------------------------------
+
+// Message that contains new entries for the interning indices of a packet
+// sequence.
+//
+// The writer will usually emit new entries in the same TracePacket that first
+// refers to them (since the last reset of interning state). They may also be
+// emitted proactively in advance of referring to them in later packets.
+//
+// Next id: 5.
+message InternedData {
+  // Each field's message type needs to specify an |iid| field, which is the ID
+  // of the entry in the field's interning index. Each field constructs its own
+  // index, thus interning IDs are scoped to the tracing session and field
+  // (usually as a counter for efficient var-int encoding). It is illegal to
+  // override entries in an index (using the same iid for two different values)
+  // within the same tracing session, even after a reset of the emitted
+  // interning state.
+  repeated EventCategory event_categories = 1;
+  repeated LegacyEventName legacy_event_names = 2;
+  repeated DebugAnnotationName debug_annotation_names = 3;
+  repeated SourceLocation source_locations = 4;
+  // Note: field IDs up to 15 should be used for frequent data only.
+}
+
+// End of protos/perfetto/trace/interned_data/interned_data.proto
+
 // Begin of protos/perfetto/trace/power/battery_counters.proto
 
 message BatteryCounters {
@@ -2505,8 +2551,8 @@
 // The root object emitted by Perfetto. A perfetto trace is just a stream of
 // TracePacket(s).
 //
-// Next reserved id: 11.
-// Next id: 41.
+// Next reserved id: 13 (up to 15).
+// Next id: 45.
 message TracePacket {
   // TODO(primiano): in future we should add a timestamp_clock_domain field to
   // allow mixing timestamps from different clock domains.
@@ -2520,9 +2566,10 @@
     // removed field with id 5
     ClockSnapshot clock_snapshot = 6;
     SysStats sys_stats = 7;
+    TrackEvent track_event = 11;
 
-    // IDs up to 32 are reserved for events that are quite frequent because they
-    // take only one byte to encode their preamble.
+    // IDs up to 15 are reserved. They take only one byte to encode their
+    // preamble so should be used for freqeuent events.
 
     // removed field with id 33
     FtraceStats ftrace_stats = 34;
@@ -2532,6 +2579,10 @@
     PowerRails power_rails = 40;
     AndroidLogPacket android_log = 39;
 
+    // Only used by TrackEvent.
+    ProcessDescriptor process_descriptor = 43;
+    ThreadDescriptor thread_descriptor = 44;
+
     // This field is emitted at periodic intervals (~10s) and
     // contains always the binary representation of the UUID
     // {82477a76-b28d-42ba-81dc-33326d57a079}. This is used to be able to
@@ -2556,10 +2607,286 @@
   oneof optional_trusted_packet_sequence_id {
     uint32 trusted_packet_sequence_id = 10;
   }
+
+  // Incrementally emitted interned data, valid only on the packet's sequence
+  // (packets with the same |trusted_packet_sequence_id|). The writer will
+  // usually emit new interned data in the same TracePacket that first refers to
+  // it (since the last reset of interning state). It may also be emitted
+  // proactively in advance of referring to them in later packets.
+  optional InternedData interned_data = 12;
+
+  // Set to true by the writer to indicate that it will re-emit any incremental
+  // data for the packet's sequence before referring to it again. This includes
+  // interned data as well as periodically emitted data like
+  // Process/ThreadDescriptors. This flag only affects the current packet
+  // sequence (see |trusted_packet_sequence_id|).
+  //
+  // When set to true, this TracePacket and subsequent TracePackets on the same
+  // sequence will not refer to any incremental data emitted before this
+  // TracePacket. For example, previously emitted interned data will be
+  // re-emitted if it is referred to again.
+  //
+  // When the reader detects packet loss (|previous_packet_dropped|), it needs
+  // to skip packets in the sequence until the next one with this flag set, to
+  // ensure intact incremental data.
+  optional bool incremental_state_cleared = 41;
+
+  // Flag set by the service if one or multiple packets on the packet's sequence
+  // were dropped since the last packet that the consumer read from the
+  // sequence. This can happen if chunks in the trace buffer are overridden
+  // before the consumer could read them when the trace is configured in ring
+  // buffer mode. This flag only affects the current packet sequence (see
+  // |trusted_packet_sequence_id|).
+  //
+  // When packet loss occurs, incrementally emitted data (including interned
+  // data) on the sequence should be considered invalid up until the next packet
+  // with |incremental_state_cleared| set. In such a situation, the reader
+  // should skip to the next packet with this flag set.
+  optional bool previous_packet_dropped = 42;
 }
 
 // End of protos/perfetto/trace/trace_packet.proto
 
+// Begin of protos/perfetto/trace/track_event/debug_annotation.proto
+
+// Key/value annotations provided in untyped TRACE_EVENT macros. These
+// annotations are intended for debug use and are not considered a stable API
+// surface. As such, they should not be relied upon to implement (new) metrics.
+message DebugAnnotation {
+  message NestedValue {
+    enum NestedType {
+      UNSPECIFIED = 0;  // leaf value.
+      DICT = 1;
+      ARRAY = 2;
+    }
+    optional NestedType nested_type = 1;
+
+    repeated string dict_keys = 2;
+    repeated NestedValue dict_values = 3;
+    repeated NestedValue array_values = 4;
+    optional int64 int_value = 5;
+    optional double double_value = 6;
+    optional bool bool_value = 7;
+    optional string string_value = 8;
+  }
+
+  optional uint32 name_iid = 1;  // interned DebugAnnotationName.
+
+  oneof value {
+    bool bool_value = 2;
+    uint64 uint_value = 3;
+    int64 int_value = 4;
+    double double_value = 5;
+    string string_value = 6;
+    // Pointers are stored in a separate type as the JSON output treats them
+    // differently from other uint64 values.
+    uint64 pointer_value = 7;
+    NestedValue nested_value = 8;
+
+    // Legacy instrumentation may not support conversion of nested data to
+    // NestedValue yet.
+    string legacy_json_value = 9;
+  }
+}
+
+// --------------------
+// Interned data types:
+// --------------------
+
+message DebugAnnotationName {
+  optional uint32 iid = 1;
+  optional string name = 2;
+}
+
+// End of protos/perfetto/trace/track_event/debug_annotation.proto
+
+// Begin of protos/perfetto/trace/track_event/process_descriptor.proto
+
+// Process-wide data that is periodically emitted by one thread per process.
+// Valid for all events in packet sequences emitted by the same process.
+//
+// Next id: 5.
+message ProcessDescriptor {
+  optional int32 pid = 1;
+  repeated string cmdline = 2;
+
+  // To support old UI. New UI should determine default sorting by process_type.
+  optional int32 legacy_sort_index = 3;
+
+  // See chromium's content::ProcessType.
+  enum ChromeProcessType {
+    UNSPECIFIED = 0;
+    BROWSER = 1;
+    RENDERER = 2;
+    UTILITY = 3;
+    ZYGOTE = 4;
+    SANDBOX_HELPER = 5;
+    GPU = 6;
+    PPAPI_PLUGIN = 7;
+    PPAPI_BROKER = 8;
+  }
+  optional ChromeProcessType chrome_process_type = 4;
+}
+
+// End of protos/perfetto/trace/track_event/process_descriptor.proto
+
+// Begin of protos/perfetto/trace/track_event/task_execution.proto
+
+// TrackEvent arguments describing the execution of a task.
+message TaskExecution {
+  // Source location that the task was posted from.
+  optional uint32 posted_from_iid = 1;  // interned SourceLocation.
+}
+
+// --------------------
+// Interned data types:
+// --------------------
+
+message SourceLocation {
+  optional uint32 iid = 1;
+
+  // We intend to add a binary symbol version of this in the future.
+  optional string file_name = 2;
+  optional string function_name = 3;
+}
+
+// End of protos/perfetto/trace/track_event/task_execution.proto
+
+// Begin of protos/perfetto/trace/track_event/thread_descriptor.proto
+
+// Periodically emitted data that's common to all events emitted by the same
+// thread, i.e. all events in the same packet sequence. Valid for all subsequent
+// events in the same sequence.
+//
+// Next id: 8.
+message ThreadDescriptor {
+  optional int32 pid = 1;
+  optional int32 tid = 2;
+
+  // To support old UI. New UI should determine default sorting by thread_type.
+  optional int32 legacy_sort_index = 3;
+
+  enum ChromeThreadType {
+    UNSPECIFIED = 0;
+    BROWSER_UI = 1;
+    BROWSER_IO = 2;
+    // TODO(eseckler): Add other thread types.
+  };
+  optional ChromeThreadType thread_type = 4;
+
+  // TODO(eseckler): Replace this with ChromeThreadType where possible.
+  optional string thread_name = 5;
+
+  // Absolute reference values. Clock values in subsequent TrackEvents can be
+  // encoded accumulatively and relative to these. This reduces their var-int
+  // encoding size.
+  optional int64 reference_timestamp_us = 6;
+  optional int64 reference_thread_time_us = 7;
+}
+
+// End of protos/perfetto/trace/track_event/thread_descriptor.proto
+
+// Begin of protos/perfetto/trace/track_event/track_event.proto
+
+// Trace events emitted by client instrumentation library (TRACE_EVENT macros),
+// which describe activity on a track, such as a thread, task sequence, or
+// asynchronous track.
+//
+// This message is optimized for writing and makes heavy use of data interning
+// and delta encoding (e.g. of timestamps) to reduce data repetition and encoded
+// data size.
+//
+// A TrackEvent exists in the context of its packet sequence (TracePackets
+// emitted by the same producer + writer) and refers to data in preceding
+// TracePackets emitted on the same sequence, both directly and indirectly. For
+// example, interned data entries are emitted as part of a TracePacket and
+// directly referred to from TrackEvents by their interning IDs. Attributes
+// shared by all events on the same sequence (e.g. their thread and process
+// association) are emitted as part of ProcessDescriptor and ThreadDescriptor
+// messages in separate TracePackets instead.
+//
+// Next reserved id: 7 (up to 15).
+// Next id: 20.
+message TrackEvent {
+  // Timestamp in microseconds (usually CLOCK_MONOTONIC).
+  oneof timestamp {
+    // Delta timestamp value since the last TrackEvent or ThreadDescriptor. To
+    // calculate the absolute timestamp value, sum up all delta values of the
+    // preceding TrackEvents since the last ThreadDescriptor and add the sum to
+    // the |reference_timestamp| in ThreadDescriptor. This value should always
+    // be positive.
+    int64 timestamp_delta_us = 1;
+    // Absolute value (e.g. a manually specified timestamp in the macro).
+    // This is a one-off value that does not affect delta timestamp computation
+    // in subsequent TrackEvents.
+    int64 timestamp_absolute_us = 16;
+  }
+
+  // CPU time for the current thread (e.g., CLOCK_THREAD_CPUTIME_ID) in
+  // microseconds.
+  oneof thread_time {
+    // Same encoding as |timestamp| fields above.
+    int64 thread_time_delta_us = 2;
+    // TODO(eseckler): Consider removing absolute thread time support. It's
+    // currently required to support writing PHASE_COMPLETE events out-of-order,
+    // but shouldn't be required anymore when we split them into begin/end.
+    int64 thread_time_absolute_us = 17;
+  }
+
+  // We intend to add a binary symbol version of this in the future.
+  repeated uint32 category_iids = 3;  // interned EventCategoryName.
+
+  // TODO(eseckler): May also want a debug_name for untyped debug-only events.
+
+  // Unstable key/value annotations shown in the trace viewer but not intended
+  // for metrics use.
+  repeated DebugAnnotation debug_annotations = 4;
+
+  // Typed event arguments:
+  optional TaskExecution task_execution = 5;
+  // TODO(eseckler): New argument types go here :)
+
+  // Apart from {category, time, thread time, tid, pid}, other legacy trace
+  // event attributes are initially simply proxied for conversion to a JSON
+  // trace. We intend to gradually transition these attributes to similar native
+  // features in TrackEvent (e.g. async + flow events), or deprecate them
+  // without replacement where transition is unsuitable.
+  message LegacyEvent {
+    optional uint32 name_iid = 1;  // interned LegacyEventName.
+    optional int32 phase = 2;
+    optional int64 duration = 3;
+    optional int64 thread_duration = 4;
+    optional uint32 flags = 5;  // e.g. global/process/thread scope, flow, ...
+    optional uint64 id = 6;
+    optional string scope = 7;
+    optional uint64 bind_id = 8;
+
+    // Override the pid/tid if the writer needs to emit events on behalf of
+    // another process/thread. This should be the exception. Normally, the
+    // pid+tid from ThreadDescriptor is used.
+    optional int32 pid_override = 18;
+    optional int32 tid_override = 19;
+  }
+
+  optional LegacyEvent legacy_event = 6;
+}
+
+// --------------------
+// Interned data types:
+// --------------------
+
+message EventCategory {
+  optional uint32 iid = 1;
+  optional string name = 2;
+}
+
+message LegacyEventName {
+  optional uint32 iid = 1;
+  optional string name = 2;
+}
+
+// End of protos/perfetto/trace/track_event/track_event.proto
+
 // Begin of protos/perfetto/trace/profiling/profile_packet.proto
 
 message ProfilePacket {
diff --git a/protos/perfetto/trace/trace_packet.proto b/protos/perfetto/trace/trace_packet.proto
index 6f0156a..44f61ac 100644
--- a/protos/perfetto/trace/trace_packet.proto
+++ b/protos/perfetto/trace/trace_packet.proto
@@ -22,9 +22,13 @@
 import "perfetto/trace/android/android_log.proto";
 import "perfetto/trace/chrome/chrome_trace_event.proto";
 import "perfetto/trace/clock_snapshot.proto";
+import "perfetto/trace/track_event/process_descriptor.proto";
+import "perfetto/trace/track_event/thread_descriptor.proto";
+import "perfetto/trace/track_event/track_event.proto";
 import "perfetto/trace/filesystem/inode_file_map.proto";
 import "perfetto/trace/ftrace/ftrace_event_bundle.proto";
 import "perfetto/trace/ftrace/ftrace_stats.proto";
+import "perfetto/trace/interned_data/interned_data.proto";
 import "perfetto/trace/power/battery_counters.proto";
 import "perfetto/trace/power/power_rails.proto";
 import "perfetto/trace/profiling/profile_packet.proto";
@@ -38,8 +42,8 @@
 // The root object emitted by Perfetto. A perfetto trace is just a stream of
 // TracePacket(s).
 //
-// Next reserved id: 11.
-// Next id: 41.
+// Next reserved id: 13 (up to 15).
+// Next id: 45.
 message TracePacket {
   // TODO(primiano): in future we should add a timestamp_clock_domain field to
   // allow mixing timestamps from different clock domains.
@@ -53,9 +57,10 @@
     ChromeEventBundle chrome_events = 5;
     ClockSnapshot clock_snapshot = 6;
     SysStats sys_stats = 7;
+    TrackEvent track_event = 11;
 
-    // IDs up to 32 are reserved for events that are quite frequent because they
-    // take only one byte to encode their preamble.
+    // IDs up to 15 are reserved. They take only one byte to encode their
+    // preamble so should be used for freqeuent events.
 
     TraceConfig trace_config = 33;
     FtraceStats ftrace_stats = 34;
@@ -65,6 +70,10 @@
     PowerRails power_rails = 40;
     AndroidLogPacket android_log = 39;
 
+    // Only used by TrackEvent.
+    ProcessDescriptor process_descriptor = 43;
+    ThreadDescriptor thread_descriptor = 44;
+
     // This field is emitted at periodic intervals (~10s) and
     // contains always the binary representation of the UUID
     // {82477a76-b28d-42ba-81dc-33326d57a079}. This is used to be able to
@@ -89,4 +98,40 @@
   oneof optional_trusted_packet_sequence_id {
     uint32 trusted_packet_sequence_id = 10;
   }
+
+  // Incrementally emitted interned data, valid only on the packet's sequence
+  // (packets with the same |trusted_packet_sequence_id|). The writer will
+  // usually emit new interned data in the same TracePacket that first refers to
+  // it (since the last reset of interning state). It may also be emitted
+  // proactively in advance of referring to them in later packets.
+  optional InternedData interned_data = 12;
+
+  // Set to true by the writer to indicate that it will re-emit any incremental
+  // data for the packet's sequence before referring to it again. This includes
+  // interned data as well as periodically emitted data like
+  // Process/ThreadDescriptors. This flag only affects the current packet
+  // sequence (see |trusted_packet_sequence_id|).
+  //
+  // When set to true, this TracePacket and subsequent TracePackets on the same
+  // sequence will not refer to any incremental data emitted before this
+  // TracePacket. For example, previously emitted interned data will be
+  // re-emitted if it is referred to again.
+  //
+  // When the reader detects packet loss (|previous_packet_dropped|), it needs
+  // to skip packets in the sequence until the next one with this flag set, to
+  // ensure intact incremental data.
+  optional bool incremental_state_cleared = 41;
+
+  // Flag set by the service if one or multiple packets on the packet's sequence
+  // were dropped since the last packet that the consumer read from the
+  // sequence. This can happen if chunks in the trace buffer are overridden
+  // before the consumer could read them when the trace is configured in ring
+  // buffer mode. This flag only affects the current packet sequence (see
+  // |trusted_packet_sequence_id|).
+  //
+  // When packet loss occurs, incrementally emitted data (including interned
+  // data) on the sequence should be considered invalid up until the next packet
+  // with |incremental_state_cleared| set. In such a situation, the reader
+  // should skip to the next packet with this flag set.
+  optional bool previous_packet_dropped = 42;
 }
diff --git a/protos/perfetto/trace/track_event/BUILD.gn b/protos/perfetto/trace/track_event/BUILD.gn
new file mode 100644
index 0000000..2646a09
--- /dev/null
+++ b/protos/perfetto/trace/track_event/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("../../../../gn/perfetto.gni")
+import("../../../../gn/proto_library.gni")
+import("../../../../gn/protozero_library.gni")
+
+event_proto_names = [
+  "debug_annotation.proto",
+  "process_descriptor.proto",
+  "task_execution.proto",
+  "thread_descriptor.proto",
+  "track_event.proto",
+]
+
+proto_library("lite") {
+  generate_python = false
+  sources = event_proto_names
+  proto_in_dir = "$perfetto_root_path/protos"
+  proto_out_dir = "$perfetto_root_path/protos"
+}
+
+protozero_library("zero") {
+  sources = event_proto_names
+  proto_in_dir = "$perfetto_root_path/protos"
+  proto_out_dir = "$perfetto_root_path/protos"
+  generator_plugin_options = "wrapper_namespace=pbzero"
+}
diff --git a/protos/perfetto/trace/track_event/debug_annotation.proto b/protos/perfetto/trace/track_event/debug_annotation.proto
new file mode 100644
index 0000000..8e06a7c
--- /dev/null
+++ b/protos/perfetto/trace/track_event/debug_annotation.proto
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+package perfetto.protos;
+
+// Key/value annotations provided in untyped TRACE_EVENT macros. These
+// annotations are intended for debug use and are not considered a stable API
+// surface. As such, they should not be relied upon to implement (new) metrics.
+message DebugAnnotation {
+  message NestedValue {
+    enum NestedType {
+      UNSPECIFIED = 0;  // leaf value.
+      DICT = 1;
+      ARRAY = 2;
+    }
+    optional NestedType nested_type = 1;
+
+    repeated string dict_keys = 2;
+    repeated NestedValue dict_values = 3;
+    repeated NestedValue array_values = 4;
+    optional int64 int_value = 5;
+    optional double double_value = 6;
+    optional bool bool_value = 7;
+    optional string string_value = 8;
+  }
+
+  optional uint32 name_iid = 1;  // interned DebugAnnotationName.
+
+  oneof value {
+    bool bool_value = 2;
+    uint64 uint_value = 3;
+    int64 int_value = 4;
+    double double_value = 5;
+    string string_value = 6;
+    // Pointers are stored in a separate type as the JSON output treats them
+    // differently from other uint64 values.
+    uint64 pointer_value = 7;
+    NestedValue nested_value = 8;
+
+    // Legacy instrumentation may not support conversion of nested data to
+    // NestedValue yet.
+    string legacy_json_value = 9;
+  }
+}
+
+// --------------------
+// Interned data types:
+// --------------------
+
+message DebugAnnotationName {
+  optional uint32 iid = 1;
+  optional string name = 2;
+}
diff --git a/protos/perfetto/trace/track_event/process_descriptor.proto b/protos/perfetto/trace/track_event/process_descriptor.proto
new file mode 100644
index 0000000..29f6dcc
--- /dev/null
+++ b/protos/perfetto/trace/track_event/process_descriptor.proto
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+package perfetto.protos;
+
+// Process-wide data that is periodically emitted by one thread per process.
+// Valid for all events in packet sequences emitted by the same process.
+//
+// Next id: 5.
+message ProcessDescriptor {
+  optional int32 pid = 1;
+  repeated string cmdline = 2;
+
+  // To support old UI. New UI should determine default sorting by process_type.
+  optional int32 legacy_sort_index = 3;
+
+  // See chromium's content::ProcessType.
+  enum ChromeProcessType {
+    UNSPECIFIED = 0;
+    BROWSER = 1;
+    RENDERER = 2;
+    UTILITY = 3;
+    ZYGOTE = 4;
+    SANDBOX_HELPER = 5;
+    GPU = 6;
+    PPAPI_PLUGIN = 7;
+    PPAPI_BROKER = 8;
+  }
+  optional ChromeProcessType chrome_process_type = 4;
+}
diff --git a/protos/perfetto/trace/track_event/task_execution.proto b/protos/perfetto/trace/track_event/task_execution.proto
new file mode 100644
index 0000000..a4964f8
--- /dev/null
+++ b/protos/perfetto/trace/track_event/task_execution.proto
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+package perfetto.protos;
+
+// TrackEvent arguments describing the execution of a task.
+message TaskExecution {
+  // Source location that the task was posted from.
+  optional uint32 posted_from_iid = 1;  // interned SourceLocation.
+}
+
+// --------------------
+// Interned data types:
+// --------------------
+
+message SourceLocation {
+  optional uint32 iid = 1;
+
+  // We intend to add a binary symbol version of this in the future.
+  optional string file_name = 2;
+  optional string function_name = 3;
+}
diff --git a/protos/perfetto/trace/track_event/thread_descriptor.proto b/protos/perfetto/trace/track_event/thread_descriptor.proto
new file mode 100644
index 0000000..89d5398
--- /dev/null
+++ b/protos/perfetto/trace/track_event/thread_descriptor.proto
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+package perfetto.protos;
+
+// Periodically emitted data that's common to all events emitted by the same
+// thread, i.e. all events in the same packet sequence. Valid for all subsequent
+// events in the same sequence.
+//
+// Next id: 8.
+message ThreadDescriptor {
+  optional int32 pid = 1;
+  optional int32 tid = 2;
+
+  // To support old UI. New UI should determine default sorting by thread_type.
+  optional int32 legacy_sort_index = 3;
+
+  enum ChromeThreadType {
+    UNSPECIFIED = 0;
+    BROWSER_UI = 1;
+    BROWSER_IO = 2;
+    // TODO(eseckler): Add other thread types.
+  };
+  optional ChromeThreadType thread_type = 4;
+
+  // TODO(eseckler): Replace this with ChromeThreadType where possible.
+  optional string thread_name = 5;
+
+  // Absolute reference values. Clock values in subsequent TrackEvents can be
+  // encoded accumulatively and relative to these. This reduces their var-int
+  // encoding size.
+  optional int64 reference_timestamp_us = 6;
+  optional int64 reference_thread_time_us = 7;
+}
diff --git a/protos/perfetto/trace/track_event/track_event.proto b/protos/perfetto/trace/track_event/track_event.proto
new file mode 100644
index 0000000..72b9a67
--- /dev/null
+++ b/protos/perfetto/trace/track_event/track_event.proto
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+option optimize_for = LITE_RUNTIME;
+
+import "perfetto/trace/track_event/debug_annotation.proto";
+import "perfetto/trace/track_event/task_execution.proto";
+
+package perfetto.protos;
+
+// Trace events emitted by client instrumentation library (TRACE_EVENT macros),
+// which describe activity on a track, such as a thread, task sequence, or
+// asynchronous track.
+//
+// This message is optimized for writing and makes heavy use of data interning
+// and delta encoding (e.g. of timestamps) to reduce data repetition and encoded
+// data size.
+//
+// A TrackEvent exists in the context of its packet sequence (TracePackets
+// emitted by the same producer + writer) and refers to data in preceding
+// TracePackets emitted on the same sequence, both directly and indirectly. For
+// example, interned data entries are emitted as part of a TracePacket and
+// directly referred to from TrackEvents by their interning IDs. Attributes
+// shared by all events on the same sequence (e.g. their thread and process
+// association) are emitted as part of ProcessDescriptor and ThreadDescriptor
+// messages in separate TracePackets instead.
+//
+// Next reserved id: 7 (up to 15).
+// Next id: 20.
+message TrackEvent {
+  // Timestamp in microseconds (usually CLOCK_MONOTONIC).
+  oneof timestamp {
+    // Delta timestamp value since the last TrackEvent or ThreadDescriptor. To
+    // calculate the absolute timestamp value, sum up all delta values of the
+    // preceding TrackEvents since the last ThreadDescriptor and add the sum to
+    // the |reference_timestamp| in ThreadDescriptor. This value should always
+    // be positive.
+    int64 timestamp_delta_us = 1;
+    // Absolute value (e.g. a manually specified timestamp in the macro).
+    // This is a one-off value that does not affect delta timestamp computation
+    // in subsequent TrackEvents.
+    int64 timestamp_absolute_us = 16;
+  }
+
+  // CPU time for the current thread (e.g., CLOCK_THREAD_CPUTIME_ID) in
+  // microseconds.
+  oneof thread_time {
+    // Same encoding as |timestamp| fields above.
+    int64 thread_time_delta_us = 2;
+    // TODO(eseckler): Consider removing absolute thread time support. It's
+    // currently required to support writing PHASE_COMPLETE events out-of-order,
+    // but shouldn't be required anymore when we split them into begin/end.
+    int64 thread_time_absolute_us = 17;
+  }
+
+  // We intend to add a binary symbol version of this in the future.
+  repeated uint32 category_iids = 3;  // interned EventCategoryName.
+
+  // TODO(eseckler): May also want a debug_name for untyped debug-only events.
+
+  // Unstable key/value annotations shown in the trace viewer but not intended
+  // for metrics use.
+  repeated DebugAnnotation debug_annotations = 4;
+
+  // Typed event arguments:
+  optional TaskExecution task_execution = 5;
+  // TODO(eseckler): New argument types go here :)
+
+  // Apart from {category, time, thread time, tid, pid}, other legacy trace
+  // event attributes are initially simply proxied for conversion to a JSON
+  // trace. We intend to gradually transition these attributes to similar native
+  // features in TrackEvent (e.g. async + flow events), or deprecate them
+  // without replacement where transition is unsuitable.
+  message LegacyEvent {
+    optional uint32 name_iid = 1;  // interned LegacyEventName.
+    optional int32 phase = 2;
+    optional int64 duration = 3;
+    optional int64 thread_duration = 4;
+    optional uint32 flags = 5;  // e.g. global/process/thread scope, flow, ...
+    optional uint64 id = 6;
+    optional string scope = 7;
+    optional uint64 bind_id = 8;
+
+    // Override the pid/tid if the writer needs to emit events on behalf of
+    // another process/thread. This should be the exception. Normally, the
+    // pid+tid from ThreadDescriptor is used.
+    optional int32 pid_override = 18;
+    optional int32 tid_override = 19;
+  }
+
+  optional LegacyEvent legacy_event = 6;
+}
+
+// --------------------
+// Interned data types:
+// --------------------
+
+message EventCategory {
+  optional uint32 iid = 1;
+  optional string name = 2;
+}
+
+message LegacyEventName {
+  optional uint32 iid = 1;
+  optional string name = 2;
+}
diff --git a/tools/gen_merged_protos b/tools/gen_merged_protos
index a88ba6d..0b7628e 100755
--- a/tools/gen_merged_protos
+++ b/tools/gen_merged_protos
@@ -64,6 +64,7 @@
   'protos/perfetto/trace/ftrace/signal.proto',
   'protos/perfetto/trace/ftrace/task.proto',
   'protos/perfetto/trace/ftrace/vmscan.proto',
+  'protos/perfetto/trace/interned_data/interned_data.proto',
   'protos/perfetto/trace/power/battery_counters.proto',
   'protos/perfetto/trace/power/power_rails.proto',
   'protos/perfetto/trace/ps/process_stats.proto',
@@ -71,6 +72,11 @@
   'protos/perfetto/trace/sys_stats/sys_stats.proto',
   'protos/perfetto/trace/trace.proto',
   'protos/perfetto/trace/trace_packet.proto',
+  'protos/perfetto/trace/track_event/debug_annotation.proto',
+  'protos/perfetto/trace/track_event/process_descriptor.proto',
+  'protos/perfetto/trace/track_event/task_execution.proto',
+  'protos/perfetto/trace/track_event/thread_descriptor.proto',
+  'protos/perfetto/trace/track_event/track_event.proto',
   'protos/perfetto/trace/profiling/profile_packet.proto',
 )
 
@@ -114,7 +120,8 @@
   definitions = re.finditer(definitions_re, merged_content, re.MULTILINE)
   types = set((match.group(1) for match in definitions))
 
-  uses_re = r'^( +)(?:repeated)?\s?([A-Z]\w+.*)\s+[a-z]\w+\s*=\s*(\d+);'
+  uses_re = r'^( +)(?:repeated)?(?:optional)?\s'\
+            r'?([A-Z]\w+.*)\s+[a-z]\w+\s*=\s*(\d+);'
   uses = re.finditer(uses_re, merged_content, re.MULTILINE)
   substitutions = []
   for use in uses: