#include "src/tracing/core/shared_memory_arbiter_impl.h"
#include <algorithm>
#include <limits>
#include <utility>
#include "perfetto/base/logging.h"
#include "perfetto/base/task_runner.h"
#include "perfetto/base/time.h"
#include "perfetto/ext/tracing/core/commit_data_request.h"
#include "perfetto/ext/tracing/core/shared_memory.h"
#include "perfetto/ext/tracing/core/shared_memory_abi.h"
#include "src/tracing/core/null_trace_writer.h"
#include "src/tracing/core/trace_writer_impl.h"
namespace perfetto {
Chunk;
namespace {
static_assert …;
MaybeUnboundBufferID MakeTargetBufferIdForReservation(uint16_t reservation_id) { … }
bool IsReservationTargetBufferId(MaybeUnboundBufferID buffer_id) { … }
}
SharedMemoryABI::PageLayout SharedMemoryArbiterImpl::default_page_layout = …;
std::unique_ptr<SharedMemoryArbiter> SharedMemoryArbiter::CreateInstance(
SharedMemory* shared_memory,
size_t page_size,
ShmemMode mode,
TracingService::ProducerEndpoint* producer_endpoint,
base::TaskRunner* task_runner) { … }
std::unique_ptr<SharedMemoryArbiter> SharedMemoryArbiter::CreateUnboundInstance(
SharedMemory* shared_memory,
size_t page_size,
ShmemMode mode) { … }
SharedMemoryArbiterImpl::SharedMemoryArbiterImpl(
void* start,
size_t size,
ShmemMode mode,
size_t page_size,
TracingService::ProducerEndpoint* producer_endpoint,
base::TaskRunner* task_runner)
: … { … }
Chunk SharedMemoryArbiterImpl::GetNewChunk(
const SharedMemoryABI::ChunkHeader& header,
BufferExhaustedPolicy buffer_exhausted_policy) { … }
void SharedMemoryArbiterImpl::ReturnCompletedChunk(
Chunk chunk,
MaybeUnboundBufferID target_buffer,
PatchList* patch_list) { … }
void SharedMemoryArbiterImpl::SendPatches(WriterID writer_id,
MaybeUnboundBufferID target_buffer,
PatchList* patch_list) { … }
void SharedMemoryArbiterImpl::UpdateCommitDataRequest(
Chunk chunk,
WriterID writer_id,
MaybeUnboundBufferID target_buffer,
PatchList* patch_list) { … }
bool SharedMemoryArbiterImpl::TryDirectPatchLocked(
WriterID writer_id,
const Patch& patch,
bool chunk_needs_more_patching) { … }
void SharedMemoryArbiterImpl::SetBatchCommitsDuration(
uint32_t batch_commits_duration_ms) { … }
bool SharedMemoryArbiterImpl::EnableDirectSMBPatching() { … }
void SharedMemoryArbiterImpl::SetDirectSMBPatchingSupportedByService() { … }
void SharedMemoryArbiterImpl::FlushPendingCommitDataRequests(
std::function<void()> callback) { … }
bool SharedMemoryArbiterImpl::TryShutdown() { … }
std::unique_ptr<TraceWriter> SharedMemoryArbiterImpl::CreateTraceWriter(
BufferID target_buffer,
BufferExhaustedPolicy buffer_exhausted_policy) { … }
std::unique_ptr<TraceWriter> SharedMemoryArbiterImpl::CreateStartupTraceWriter(
uint16_t target_buffer_reservation_id) { … }
void SharedMemoryArbiterImpl::BindToProducerEndpoint(
TracingService::ProducerEndpoint* producer_endpoint,
base::TaskRunner* task_runner) { … }
void SharedMemoryArbiterImpl::BindStartupTargetBuffer(
uint16_t target_buffer_reservation_id,
BufferID target_buffer_id) { … }
void SharedMemoryArbiterImpl::AbortStartupTracingForReservation(
uint16_t target_buffer_reservation_id) { … }
void SharedMemoryArbiterImpl::BindStartupTargetBufferImpl(
std::unique_lock<std::mutex> scoped_lock,
uint16_t target_buffer_reservation_id,
BufferID target_buffer_id) { … }
std::function<void()>
SharedMemoryArbiterImpl::TakePendingFlushCallbacksLocked() { … }
void SharedMemoryArbiterImpl::NotifyFlushComplete(FlushRequestID req_id) { … }
std::unique_ptr<TraceWriter> SharedMemoryArbiterImpl::CreateTraceWriterInternal(
MaybeUnboundBufferID target_buffer,
BufferExhaustedPolicy buffer_exhausted_policy) { … }
void SharedMemoryArbiterImpl::ReleaseWriterID(WriterID id) { … }
bool SharedMemoryArbiterImpl::ReplaceCommitPlaceholderBufferIdsLocked() { … }
bool SharedMemoryArbiterImpl::UpdateFullyBoundLocked() { … }
}