Reduce ProducerID 64 -> 16 bits

This saves some space in the upcoming ChunkRecord in TraceBuffer.
We are not going to be able to deal with > 64k producers anyways
as each of them requires at least one file descriptor.

Also this fixes a minor bug in the page_owners initialization
in TraceBuffer::Create().

Bug: 73612642
Test: perfetto_unittest --gtest_filter=ServiceImplTest.ProducerIDWrapping
Change-Id: Id105760ad8cfbb6f0e8ab8edc65954d5ed3ae395
diff --git a/src/tracing/core/service_impl.h b/src/tracing/core/service_impl.h
index d4b4947..60b8587 100644
--- a/src/tracing/core/service_impl.h
+++ b/src/tracing/core/service_impl.h
@@ -150,6 +150,8 @@
   ProducerEndpointImpl* GetProducer(ProducerID) const;
 
  private:
+  FRIEND_TEST(ServiceImplTest, ProducerIDWrapping);
+
   struct RegisteredDataSource {
     ProducerID producer_id;
     DataSourceID data_source_id;
@@ -168,7 +170,7 @@
     TraceBuffer(TraceBuffer&&) noexcept;
     TraceBuffer& operator=(TraceBuffer&&);
 
-    bool Create(size_t size);
+    bool Create(size_t size_in_bytes);
     size_t num_pages() const { return size / kBufferPageSize; }
 
     uint8_t* get_page(size_t page) {
@@ -230,6 +232,9 @@
                                 const RegisteredDataSource&,
                                 TracingSession*);
 
+  // Returns the next available ProducerID that is not in |producers_|.
+  ProducerID GetNextProducerID();
+
   // Returns a pointer to the |tracing_sessions_| entry or nullptr if the
   // session doesn't exists.
   TracingSession* GetTracingSession(TracingSessionID);