class DataSourceType

Defined at line 30 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

Represents a data source type (not an instance).

All the static state of a DataSource

<T

> lives here (including

DataSourceStaticState).

The C shared library API wrapper cannot use DataSource

<T

>, because it needs

to create new data source types at runtime, so it uses this directly.

The main reason why this intermediate class exist is to decouple the

DataSourceStaticState from the specific DataSource

<T

>. The C API cannot

dynamically create template instances and it needs a way to decouple those at

runtime.

Public Methods

bool Register (const DataSourceDescriptor & descriptor, TracingMuxer::DataSourceFactory factory, internal::DataSourceParams params, bool no_flush, CreateCustomTlsFn create_custom_tls_fn, CreateIncrementalStateFn create_incremental_state_fn, ClearIncrementalStateFn clear_incremental_state_fn, void * user_arg)

Registers the data source type with the central tracing muxer.

* `descriptor` is the data source protobuf descriptor.

* `factory` is a std::function used to create instances of the data source

type.

* `create_custom_tls_fn` and `create_incremental_state_fn` are function

pointers called to create custom state. They will receive `user_arg` as

an extra param.

* `clear_incremental_state_fn` is an optional function pointer called to

clear incremental state without destroying it. If nullptr or returns

false, the state will be destroyed and recreated.

Defined at line 64 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

void UpdateDescriptor (const DataSourceDescriptor & descriptor)

Updates the data source type descriptor.

Defined at line 82 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

template <typename DataSourceTraits, typename TracePointTraits>
bool TracePrologue (DataSourceThreadLocalState ** tls_state, uint32_t * instances, typename TracePointTraits::TracePointData trace_point_data)

The beginning of a trace point.

`tls_state` must point to a thread local variable that caches a pointer to

an internal per data source type thread local state.

`instances` must point to a copy of the current active instances for the

data source type.

`DataSourceTraits` can be used to customize the thread local storage used

for the data source type.

`TracePointTraits` and `trace_point_data` are customization point for

getting the active instances bitmap.

If this returns false, the trace point must be skipped.

Defined at line 103 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

void TraceEpilogue (DataSourceThreadLocalState * tls_state)

Must be called at the ending of a trace point that was not skipped.

Defined at line 156 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

template <typename TracePointTraits>
InstancesIterator BeginIteration (uint32_t cached_instances, DataSourceThreadLocalState * tls_state, typename TracePointTraits::TracePointData trace_point_data)

Returns an iterator to the active instances of this data source type.

`cached_instances` is a copy of the bitmap of the active instances for this

data source type (usually just a copy of ValidInstances(), but can be

customized).

`tls_state` is the thread local pointer obtained from TracePrologue.

`TracePointTraits` and `trace_point_data` are customization point for

getting the active instances bitmap.

Defined at line 180 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

template <typename TracePointTraits>
void NextIteration (InstancesIterator * iterator, DataSourceThreadLocalState * tls_state, typename TracePointTraits::TracePointData trace_point_data)

Advances `*iterator` to point to the next active instance of this data

source type.

`tls_state` is the thread local pointer obtained from TracePrologue.

`TracePointTraits` and `trace_point_data` are customization point for

getting the active instances bitmap.

Defined at line 198 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

void * GetIncrementalState (internal::DataSourceInstanceThreadLocalState * tls_inst, uint32_t instance_index)

Defined at line 207 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

std::atomic<uint32_t> * valid_instances ()

Defined at line 221 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

DataSourceStaticState * static_state ()

Defined at line 223 of file ../../third_party/perfetto/include/perfetto/tracing/internal/data_source_type.h

Records