Introduce TraceWriter and SharedMemoryArbiter for Producer(s)

These classes allow a Producer to get writer instances to allow
writing from several threads sharing the same per-Producer
SharedMemoryBuffer.

Test: perfetto_tests --gtest_filter=*SharedMemoryArbiter*
Test: perfetto_tests --gtest_filter=*TraceWriterImpl*
Bug: 70284518
Bug: 68854243
Change-Id: I56c4c699d9722bd34a8c5b32f514c6faa9cb95c5
diff --git a/src/tracing/BUILD.gn b/src/tracing/BUILD.gn
index 33697e5..bbfa964 100644
--- a/src/tracing/BUILD.gn
+++ b/src/tracing/BUILD.gn
@@ -23,6 +23,7 @@
   deps = [
     "../../gn:default_deps",
     "../../protos:lite",
+    "../../protos:zero",
     "../base",
   ]
   sources = [
@@ -35,8 +36,12 @@
     "core/service_impl.cc",
     "core/service_impl.h",
     "core/shared_memory_abi.cc",
+    "core/shared_memory_arbiter.cc",
+    "core/shared_memory_arbiter.h",
     "core/trace_config.cc",
     "core/trace_packet.cc",
+    "core/trace_writer_impl.cc",
+    "core/trace_writer_impl.h",
   ]
 }
 
@@ -76,6 +81,7 @@
     "../../gn:default_deps",
     "../../gn:gtest_deps",
     "../../protos:lite",
+    "../../protos:zero",
     "../base",
     "../base:test_support",
   ]
@@ -84,8 +90,12 @@
     "core/id_allocator_unittest.cc",
     "core/service_impl_unittest.cc",
     "core/shared_memory_abi_unittest.cc",
+    "core/shared_memory_arbiter_unittest.cc",
     "core/trace_packet_unittest.cc",
+    "core/trace_writer_impl_unittest.cc",
     "ipc/posix_shared_memory_unittest.cc",
+    "test/aligned_buffer_test.cc",
+    "test/aligned_buffer_test.h",
     "test/test_shared_memory.cc",
     "test/test_shared_memory.h",
   ]