chromium/services/tracing/public/cpp/perfetto/perfetto_traced_process.h

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_TRACING_PUBLIC_CPP_PERFETTO_PERFETTO_TRACED_PROCESS_H_
#define SERVICES_TRACING_PUBLIC_CPP_PERFETTO_PERFETTO_TRACED_PROCESS_H_

#include "base/component_export.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/sequence_checker.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/thread_annotations.h"
#include "base/trace_event/trace_event.h"
#include "base/tracing/perfetto_task_runner.h"
#include "services/tracing/public/cpp/perfetto/perfetto_tracing_backend.h"
#include "services/tracing/public/mojom/perfetto_service.mojom.h"
#include "third_party/perfetto/include/perfetto/tracing/tracing.h"
#include "third_party/perfetto/include/perfetto/tracing/tracing_policy.h"

namespace base {
namespace trace_event {
class TraceConfig;
}  // namespace trace_event
namespace tracing {
class PerfettoPlatform;
}  // namespace tracing
}  // namespace base

namespace tracing {
namespace mojom {
class TracingService;
}  // namespace mojom

class PerfettoProducer;
class ProducerClient;
class SystemProducer;

// This represents global process level state that the Perfetto tracing system
// expects to exist. This includes a single base implementation of DataSources
// all implementors should use and the perfetto task runner that should be used
// when talking to the tracing system to prevent deadlocks.
//
// Implementations of new DataSources should:
// * Implement PerfettoTracedProcess::DataSourceBase.
// * Add a new data source name in perfetto_service.mojom.
// * Register the data source with Perfetto in ProducerHost::OnConnect.
// * Construct the new implementation when requested to
//   in PerfettoProducer::StartDataSource.
class COMPONENT_EXPORT(TRACING_CPP) PerfettoTracedProcess final
    : public perfetto::TracingPolicy {};

template <typename T>
PerfettoTracedProcess::DataSourceProxy<T>::DataSourceProxy(
    PerfettoTracedProcess::DataSourceBase* data_source)
    :{}

template <typename T>
PerfettoTracedProcess::DataSourceProxy<T>::DataSourceProxy(
    raw_ptr<PerfettoTracedProcess::DataSourceBase>* data_source_ptr)
    :{}

template <typename T>
PerfettoTracedProcess::DataSourceProxy<T>::~DataSourceProxy() = default;

template <typename T>
void PerfettoTracedProcess::DataSourceProxy<T>::OnSetup(
    const perfetto::DataSourceBase::SetupArgs& args) {}

template <typename T>
void PerfettoTracedProcess::DataSourceProxy<T>::OnStart(
    const perfetto::DataSourceBase::StartArgs&) {}

template <typename T>
void PerfettoTracedProcess::DataSourceProxy<T>::OnStop(
    const perfetto::DataSourceBase::StopArgs& args) {}

template <typename T>
void PerfettoTracedProcess::DataSourceProxy<T>::WillClearIncrementalState(
    const base::perfetto_track_event::TrackEvent::ClearIncrementalStateArgs&
        args) {}

template <typename T>
bool PerfettoTracedProcess::DataSourceProxy<T>::CanAdoptStartupSession(
    const perfetto::DataSourceConfig& startup_config,
    const perfetto::DataSourceConfig& service_config) {}

}  // namespace tracing
#endif  // SERVICES_TRACING_PUBLIC_CPP_PERFETTO_PERFETTO_TRACED_PROCESS_H_