#include "services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto.h"
#include "base/files/file_path.h"
#include "base/format_macros.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/traced_value.h"
#include "base/tracing/trace_time.h"
#include "build/build_config.h"
#include "services/tracing/public/cpp/perfetto/perfetto_traced_process.h"
#include "third_party/perfetto/protos/perfetto/trace/memory_graph.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/profiling/smaps.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/ps/process_stats.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/trace_packet.pbzero.h"
namespace memory_instrumentation {
ProcessMemoryDump;
namespace {
void OsDumpAsProtoInto(perfetto::protos::pbzero::ProcessStats::Process* process,
const mojom::OSMemDump& os_dump) { … }
perfetto::protos::pbzero::MemoryTrackerSnapshot::LevelOfDetail
MemoryDumpLevelOfDetailToProto(
const base::trace_event::MemoryDumpLevelOfDetail& level_of_detail) { … }
}
TracingObserverProto* TracingObserverProto::GetInstance() { … }
TracingObserverProto::TracingObserverProto() = default;
TracingObserverProto::~TracingObserverProto() = default;
void TracingObserverProto::ResetForTesting() { … }
bool TracingObserverProto::AddChromeDumpToTraceIfEnabled(
const base::trace_event::MemoryDumpRequestArgs& args,
const base::ProcessId pid,
const ProcessMemoryDump* process_memory_dump,
const base::TimeTicks& timestamp) { … }
bool TracingObserverProto::AddOsDumpToTraceIfEnabled(
const base::trace_event::MemoryDumpRequestArgs& args,
const base::ProcessId pid,
const mojom::OSMemDump& os_dump,
const std::vector<mojom::VmRegionPtr>& memory_maps,
const base::TimeTicks& timestamp) { … }
void TracingObserverProto::MemoryMapsAsProtoInto(
const std::vector<mojom::VmRegionPtr>& memory_maps,
perfetto::protos::pbzero::SmapsPacket* smaps,
bool is_argument_filtering_enabled) { … }
void TracingObserverProto::SetOnChromeDumpCallbackForTesting(
OnChromeDumpCallback callback) { … }
}