#include "src/tracing/ipc/producer/producer_ipc_client_impl.h"
#include <cinttypes>
#include <string.h>
#include "perfetto/base/logging.h"
#include "perfetto/base/task_runner.h"
#include "perfetto/ext/base/unix_socket.h"
#include "perfetto/ext/base/version.h"
#include "perfetto/ext/ipc/client.h"
#include "perfetto/ext/tracing/core/commit_data_request.h"
#include "perfetto/ext/tracing/core/producer.h"
#include "perfetto/ext/tracing/core/shared_memory_abi.h"
#include "perfetto/ext/tracing/core/shared_memory_arbiter.h"
#include "perfetto/ext/tracing/core/trace_writer.h"
#include "perfetto/tracing/core/data_source_config.h"
#include "perfetto/tracing/core/data_source_descriptor.h"
#include "perfetto/tracing/core/trace_config.h"
#include "src/tracing/core/in_process_shared_memory.h"
#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
#include "src/tracing/ipc/shared_memory_windows.h"
#else
#include "src/tracing/ipc/posix_shared_memory.h"
#endif
namespace perfetto {
std::unique_ptr<TracingService::ProducerEndpoint> ProducerIPCClient::Connect(
const char* service_sock_name,
Producer* producer,
const std::string& producer_name,
base::TaskRunner* task_runner,
TracingService::ProducerSMBScrapingMode smb_scraping_mode,
size_t shared_memory_size_hint_bytes,
size_t shared_memory_page_size_hint_bytes,
std::unique_ptr<SharedMemory> shm,
std::unique_ptr<SharedMemoryArbiter> shm_arbiter,
ConnectionFlags conn_flags) { … }
std::unique_ptr<TracingService::ProducerEndpoint> ProducerIPCClient::Connect(
ipc::Client::ConnArgs conn_args,
Producer* producer,
const std::string& producer_name,
base::TaskRunner* task_runner,
TracingService::ProducerSMBScrapingMode smb_scraping_mode,
size_t shared_memory_size_hint_bytes,
size_t shared_memory_page_size_hint_bytes,
std::unique_ptr<SharedMemory> shm,
std::unique_ptr<SharedMemoryArbiter> shm_arbiter,
CreateSocketAsync create_socket_async) { … }
ProducerIPCClientImpl::ProducerIPCClientImpl(
ipc::Client::ConnArgs conn_args,
Producer* producer,
const std::string& producer_name,
base::TaskRunner* task_runner,
TracingService::ProducerSMBScrapingMode smb_scraping_mode,
size_t shared_memory_size_hint_bytes,
size_t shared_memory_page_size_hint_bytes,
std::unique_ptr<SharedMemory> shm,
std::unique_ptr<SharedMemoryArbiter> shm_arbiter,
CreateSocketAsync create_socket_async)
: … { … }
ProducerIPCClientImpl::~ProducerIPCClientImpl() { … }
void ProducerIPCClientImpl::Disconnect() { … }
void ProducerIPCClientImpl::OnConnect() { … }
void ProducerIPCClientImpl::OnDisconnect() { … }
void ProducerIPCClientImpl::ScheduleDisconnect() { … }
void ProducerIPCClientImpl::OnConnectionInitialized(
bool connection_succeeded,
bool using_shmem_provided_by_producer,
bool direct_smb_patching_supported,
bool use_shmem_emulation) { … }
void ProducerIPCClientImpl::OnServiceRequest(
const protos::gen::GetAsyncCommandResponse& cmd) { … }
void ProducerIPCClientImpl::RegisterDataSource(
const DataSourceDescriptor& descriptor) { … }
void ProducerIPCClientImpl::UpdateDataSource(
const DataSourceDescriptor& descriptor) { … }
void ProducerIPCClientImpl::UnregisterDataSource(const std::string& name) { … }
void ProducerIPCClientImpl::RegisterTraceWriter(uint32_t writer_id,
uint32_t target_buffer) { … }
void ProducerIPCClientImpl::UnregisterTraceWriter(uint32_t writer_id) { … }
void ProducerIPCClientImpl::CommitData(const CommitDataRequest& req,
CommitDataCallback callback) { … }
void ProducerIPCClientImpl::NotifyDataSourceStarted(DataSourceInstanceID id) { … }
void ProducerIPCClientImpl::NotifyDataSourceStopped(DataSourceInstanceID id) { … }
void ProducerIPCClientImpl::ActivateTriggers(
const std::vector<std::string>& triggers) { … }
void ProducerIPCClientImpl::Sync(std::function<void()> callback) { … }
std::unique_ptr<TraceWriter> ProducerIPCClientImpl::CreateTraceWriter(
BufferID target_buffer,
BufferExhaustedPolicy buffer_exhausted_policy) { … }
SharedMemoryArbiter* ProducerIPCClientImpl::MaybeSharedMemoryArbiter() { … }
bool ProducerIPCClientImpl::IsShmemProvidedByProducer() const { … }
void ProducerIPCClientImpl::NotifyFlushComplete(FlushRequestID req_id) { … }
SharedMemory* ProducerIPCClientImpl::shared_memory() const { … }
size_t ProducerIPCClientImpl::shared_buffer_page_size_kb() const { … }
}