#include "services/tracing/public/cpp/perfetto/custom_event_recorder.h"
#include "base/base64.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/statistics_recorder.h"
#include "base/metrics/user_metrics.h"
#include "base/no_destructor.h"
#include "base/pickle.h"
#include "base/process/current_process.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
#include "base/trace_event/trace_config.h"
#include "base/trace_event/typed_macros.h"
#include "base/tracing/protos/chrome_track_event.pbzero.h"
#include "build/build_config.h"
#include "services/tracing/public/cpp/perfetto/perfetto_traced_process.h"
#include "services/tracing/public/cpp/perfetto/trace_string_lookup.h"
#include "third_party/perfetto/include/perfetto/tracing/internal/track_event_internal.h"
#include "third_party/perfetto/include/perfetto/tracing/track_event_interned_data_index.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_active_processes.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_histogram_sample.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_process_descriptor.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_user_event.pbzero.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/application_status_listener.h"
#include "base/trace_event/application_state_proto_android.h"
#endif
TraceConfig;
ChromeProcessDescriptor;
namespace tracing {
namespace {
constexpr char kHistogramSamplesCategory[] = …);
constexpr char kUserActionSamplesCategory[] = …);
base::SequencedTaskRunner* GetTaskRunner() { … }
struct InternedHistogramName
: public perfetto::TrackEventInternedDataIndex<
InternedHistogramName,
perfetto::protos::pbzero::InternedData::kHistogramNamesFieldNumber,
const char*> { … };
}
CustomEventRecorder::CustomEventRecorder() { … }
CustomEventRecorder::~CustomEventRecorder()
{ … }
CustomEventRecorder* CustomEventRecorder::GetInstance() { … }
void CustomEventRecorder::EmitRecurringUpdates() { … }
void CustomEventRecorder::OnSetup(
const perfetto::DataSourceBase::SetupArgs& args) { … }
void CustomEventRecorder::OnStop(
const perfetto::DataSourceBase::StopArgs& args) { … }
void CustomEventRecorder::WillClearIncrementalState(
const perfetto::DataSourceBase::ClearIncrementalStateArgs&) { … }
void CustomEventRecorder::OnStartupTracingStarted(
const TraceConfig& trace_config,
bool ) { … }
void CustomEventRecorder::OnTracingStarted(
const perfetto::DataSourceConfig& data_source_config) { … }
void CustomEventRecorder::OnTracingStopped(
base::OnceClosure stop_complete_callback) { … }
void CustomEventRecorder::OnUserActionSampleCallback(
const std::string& action,
base::TimeTicks action_time) { … }
void CustomEventRecorder::LogHistogram(base::HistogramBase* histogram) { … }
void CustomEventRecorder::ResetHistograms(const TraceConfig& trace_config) { … }
void CustomEventRecorder::LogHistograms() { … }
void CustomEventRecorder::OnMetricsSampleCallback(
const char* histogram_name,
uint64_t name_hash,
base::HistogramBase::Sample sample) { … }
}