chromium/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer.h

// Copyright 2017 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_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_TRACING_OBSERVER_H_
#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_TRACING_OBSERVER_H_

#include "base/component_export.h"
#include "base/memory/raw_ptr.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
#include "services/tracing/public/cpp/perfetto/perfetto_traced_process.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/trace_writer.h"

namespace memory_instrumentation {

// [Non-SDK build] Observes TraceLog for Enable/Disable events and when they
// occur enables and disables the MemoryDumpManager with the correct state
// based on reading the trace log.
// [SDK build] Acts as a Perfetto datasource, implementing StartTracingImpl and
// StopTracingImpl. Enables MemoryDumpManager based on the config passed by
// the tracing service.
// Also provides a method for adding a dump to the trace.
class COMPONENT_EXPORT(RESOURCE_COORDINATOR_PUBLIC_MEMORY_INSTRUMENTATION)
    TracingObserver :
    public tracing::PerfettoTracedProcess::DataSourceBase {};

}  // namespace memory_instrumentation

#endif  // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_TRACING_OBSERVER_H_