template <typename DerivedDataSource, typename DataSourceTraits = DefaultDataSourceTraits>

class DataSource

Defined at line 264 of file ../../third_party/perfetto/include/perfetto/tracing/data_source.h

Templated base class meant to be derived by embedders to create a custom data

source. DerivedDataSource must be the type of the derived class itself, e.g.:

class MyDataSource : public DataSource

<MyDataSource

> {...}.

|DataSourceTraits| allows customizing the behavior of the data source. See

|DefaultDataSourceTraits|.

Public Members

static BufferExhaustedPolicy kBufferExhaustedPolicy
static const bool kBufferExhaustedPolicyConfigurable
static const bool kSupportsMultipleInstances
static const bool kRequiresCallbacksUnderLock

Public Methods

template <typename Lambda>
void Trace (Lambda tracing_fn)

The main tracing method. Tracing code should call this passing a lambda as

argument, with the following signature: void(TraceContext).

The lambda will be called synchronously (i.e., always before Trace()

returns) only if tracing is enabled and the data source has been enabled in

the tracing config.

The lambda can be called more than once per Trace() call, in the case of

concurrent tracing sessions (or even if the data source is instantiated

twice within the same trace config).

Defined at line 403 of file ../../third_party/perfetto/include/perfetto/tracing/data_source.h

template <typename Traits = DefaultTracePointTraits, typename Callback>
void CallIfEnabled (Callback callback, typename Traits::TracePointData trace_point_data)

An efficient trace point guard for checking if this data source is active.

|callback| is a function which will only be called if there are active

instances. It is given an instance state parameter, which should be passed

to TraceWithInstances() to actually record trace data.

Defined at line 415 of file ../../third_party/perfetto/include/perfetto/tracing/data_source.h

template <typename Traits = DefaultTracePointTraits, typename Lambda>
void TraceWithInstances (uint32_t cached_instances, Lambda tracing_fn, typename Traits::TracePointData trace_point_data)

The "lower half" of a trace point which actually performs tracing after

this data source has been determined to be active.

|instances| must be the instance state value retrieved through

CallIfEnabled().

|tracing_fn| will be called to record trace data as in Trace().

|trace_point_data| is an optional parameter given to |Traits::

GetActiveInstances| to make it possible to use custom storage for

the data source enabled state. This is, for example, used by TrackEvent to

implement per-tracing category enabled states.

Defined at line 449 of file ../../third_party/perfetto/include/perfetto/tracing/data_source.h

template <class... Args>
bool Register (const DataSourceDescriptor & descriptor, const Args &... constructor_args)

Registers the data source on all tracing backends, including ones that

connect after the registration. Doing so enables the data source to receive

Setup/Start/Stop notifications and makes the Trace() method work when

tracing is enabled and the data source is selected.

This must be called after Tracing::Initialize().

Can return false to signal failure if attemping to register more than

kMaxDataSources (32) data sources types or if tracing hasn't been

initialized.

The optional |constructor_args| will be passed to the data source when it

is constructed.

Defined at line 482 of file ../../third_party/perfetto/include/perfetto/tracing/data_source.h

void UpdateDescriptor (const DataSourceDescriptor & descriptor)

Updates the data source descriptor.

Defined at line 518 of file ../../third_party/perfetto/include/perfetto/tracing/data_source.h

Records

Friends

template <typename DerivedDataSource, typename DataSourceTraits = DefaultDataSourceTraits>
class TrackEvent
template <typename DerivedDataSourcetypename DataSourceTraits = DefaultDataSourceTraits>
class DataSourceInternalForTest