chromium/components/ui_devtools/tracing_agent.cc

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/ui_devtools/tracing_agent.h"

#include <algorithm>
#include <memory>
#include <unordered_set>
#include <vector>

#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/process/process.h"
#include "base/timer/timer.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "components/ui_devtools/connector_delegate.h"
#include "components/ui_devtools/devtools_base_agent.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/data_pipe_drainer.h"
#include "services/tracing/public/cpp/perfetto/perfetto_config.h"
#include "services/tracing/public/cpp/tracing_features.h"
#include "services/tracing/public/mojom/constants.mojom.h"
#include "services/tracing/public/mojom/perfetto_service.mojom.h"
#include "third_party/inspector_protocol/crdtp/json.h"

namespace ui_devtools {

Response;

namespace {

// Minimum reporting interval for the buffer usage status.
const double kMinimumReportingInterval =;

// We currently don't support concurrent tracing sessions, but are planning to.
// For the time being, we're using this flag as a workaround to prevent devtools
// users from accidentally starting two concurrent sessions.
// TODO(eseckler): Remove once we add support for concurrent sessions to the
// perfetto backend.
static bool g_any_agent_tracing =;

base::trace_event::TraceConfig::ProcessFilterConfig CreateProcessFilterConfig(
    base::ProcessId gpu_pid) {}

}  // namespace

// This class is passed to StopTracing() and receives the trace data followed by
// a notification that data collection is over.
class TracingAgent::DevToolsTraceEndpointProxy
    : public base::RefCountedThreadSafe<DevToolsTraceEndpointProxy> {};

// Class used to communicate with the Perfetto Consumer interface.
class TracingAgent::PerfettoTracingSession
    : public tracing::mojom::TracingSessionClient,
      public mojo::DataPipeDrainer::Client {};

TracingAgent::TracingAgent(std::unique_ptr<ConnectorDelegate> connector)
    :{}

TracingAgent::~TracingAgent() = default;

namespace {
class TracingNotification : public crdtp::Serializable {};
}  // namespace

void TracingAgent::OnTraceDataCollected(
    std::unique_ptr<std::string> trace_fragment) {}

void TracingAgent::OnTraceComplete() {}

void TracingAgent::start(
    protocol::Maybe<std::string> categories,
    protocol::Maybe<std::string> options,
    protocol::Maybe<double> buffer_usage_reporting_interval,
    std::unique_ptr<StartCallback> callback) {}

Response TracingAgent::end() {}

void TracingAgent::StartTracing(std::unique_ptr<StartCallback> callback) {}

void TracingAgent::OnRecordingEnabled(std::unique_ptr<StartCallback> callback) {}

void TracingAgent::EditTraceDataForFrontend() {}

void TracingAgent::SetupTimer(double usage_reporting_interval) {}

void TracingAgent::OnBufferUsage(float percent_full,
                                 size_t approximate_event_count) {}

void TracingAgent::UpdateBufferUsage() {}

void TracingAgent::StopTracing(
    const scoped_refptr<DevToolsTraceEndpointProxy>& endpoint,
    const std::string& agent_label) {}

std::string TracingAgent::UpdateTraceDataBuffer(
    const std::string& trace_fragment) {}

}  // namespace ui_devtools