class ProducerEndpoint
Defined at line 58 of file ../../third_party/perfetto/include/perfetto/ext/tracing/core/tracing_service.h
The API for the Producer port of the Service.
Subclassed by:
1. The tracing_service_impl.cc business logic when returning it in response
to the ConnectProducer() method.
2. The transport layer (e.g., src/ipc) when the producer and
the service don't talk locally but via some IPC mechanism.
Public Methods
void ~ProducerEndpoint ()
void Disconnect ()
Disconnects the endpoint from the service, while keeping the shared memory
valid. After calling this, the endpoint will no longer call any methods
on the Producer.
void RegisterDataSource (const DataSourceDescriptor & )
Called by the Producer to (un)register data sources. Data sources are
identified by their name (i.e. DataSourceDescriptor.name)
void UpdateDataSource (const DataSourceDescriptor & )
void UnregisterDataSource (const std::string & name)
void RegisterTraceWriter (uint32_t writer_id, uint32_t target_buffer)
Associate the trace writer with the given |writer_id| with
|target_buffer|. The service may use this information to retrieve and
copy uncommitted chunks written by the trace writer into its associated
buffer, e.g. when a producer process crashes or when a flush is
necessary.
void UnregisterTraceWriter (uint32_t writer_id)
Remove the association of the trace writer previously created via
RegisterTraceWriter.
void CommitData (const CommitDataRequest & , CommitDataCallback callback)
SharedMemory * shared_memory ()
size_t shared_buffer_page_size_kb ()
Size of shared memory buffer pages. It's always a multiple of 4K.
See shared_memory_abi.h
std::unique_ptr<TraceWriter> CreateTraceWriter (BufferID target_buffer, BufferExhaustedPolicy buffer_exhausted_policy)
Creates a trace writer, which allows to create events, handling the
underying shared memory buffer and signalling to the Service. This method
is thread-safe but the returned object is not. A TraceWriter should be
used only from a single thread, or the caller has to handle sequencing
via a mutex or equivalent. This method can only be called if
TracingService::ConnectProducer was called with |in_process=true|.
Args:
|target_buffer| is the target buffer ID where the data produced by the
writer should be stored by the tracing service. This value is passed
upon creation of the data source (StartDataSource()) in the
DataSourceConfig.target_buffer().
SharedMemoryArbiter * MaybeSharedMemoryArbiter ()
In some cases you can access the producer's SharedMemoryArbiter (for
example if TracingService::ConnectProducer is called with
|in_process=true|). The SharedMemoryArbiter can be used to create
TraceWriters which is able to directly commit chunks. For the
|in_process=true| case this can be done without going through an IPC layer.
bool IsShmemProvidedByProducer ()
Whether the service accepted a shared memory buffer provided by the
producer.
void NotifyFlushComplete (FlushRequestID )
Called in response to a Producer::Flush(request_id) call after all data
for the flush request has been committed.
void NotifyDataSourceStarted (DataSourceInstanceID )
Called in response to one or more Producer::StartDataSource(),
if the data source registered setting the flag
DataSourceDescriptor.will_notify_on_start.
void NotifyDataSourceStopped (DataSourceInstanceID )
Called in response to one or more Producer::StopDataSource(),
if the data source registered setting the flag
DataSourceDescriptor.will_notify_on_stop.
void ActivateTriggers (const std::vector<std::string> & )
This informs the service to activate any of these triggers if any tracing
session was waiting for them.
void Sync (std::function<void ()> callback)
Emits a synchronization barrier to linearize with the service. When
|callback| is invoked, the caller has the guarantee that the service has
seen and processed all the requests sent by this producer prior to the
Sync() call. Used mainly in tests.