#include "base/metrics/statistics_recorder.h"
#include <string_view>
#include "base/at_exit.h"
#include "base/barrier_closure.h"
#include "base/containers/contains.h"
#include "base/debug/leak_annotations.h"
#include "base/json/string_escape.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_snapshot_manager.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/record_histogram_checker.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "build/build_config.h"
namespace base {
namespace {
bool HistogramNameLesser(const base::HistogramBase* a,
const base::HistogramBase* b) { … }
}
LazyInstance<Lock>::Leaky StatisticsRecorder::lock_ = …;
LazyInstance<Lock>::Leaky StatisticsRecorder::snapshot_lock_ = …;
StatisticsRecorder::SnapshotTransactionId
StatisticsRecorder::last_snapshot_transaction_id_ = …;
StatisticsRecorder* StatisticsRecorder::top_ = …;
bool StatisticsRecorder::is_vlog_initialized_ = …;
std::atomic<bool> StatisticsRecorder::have_active_callbacks_{ … };
std::atomic<StatisticsRecorder::GlobalSampleCallback>
StatisticsRecorder::global_sample_callback_{ … };
StatisticsRecorder::ScopedHistogramSampleObserver::
ScopedHistogramSampleObserver(const std::string& name,
OnSampleCallback callback)
: … { … }
StatisticsRecorder::ScopedHistogramSampleObserver::
~ScopedHistogramSampleObserver() { … }
void StatisticsRecorder::ScopedHistogramSampleObserver::RunCallback(
const char* histogram_name,
uint64_t name_hash,
HistogramBase::Sample sample) { … }
StatisticsRecorder::~StatisticsRecorder() { … }
void StatisticsRecorder::EnsureGlobalRecorderWhileLocked() { … }
void StatisticsRecorder::RegisterHistogramProvider(
const WeakPtr<HistogramProvider>& provider) { … }
HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
HistogramBase* histogram) { … }
const BucketRanges* StatisticsRecorder::RegisterOrDeleteDuplicateRanges(
const BucketRanges* ranges) { … }
void StatisticsRecorder::WriteGraph(const std::string& query,
std::string* output) { … }
std::string StatisticsRecorder::ToJSON(JSONVerbosityLevel verbosity_level) { … }
std::vector<const BucketRanges*> StatisticsRecorder::GetBucketRanges() { … }
HistogramBase* StatisticsRecorder::FindHistogram(std::string_view name) { … }
StatisticsRecorder::HistogramProviders
StatisticsRecorder::GetHistogramProviders() { … }
void StatisticsRecorder::ImportProvidedHistograms(bool async,
OnceClosure done_callback) { … }
void StatisticsRecorder::ImportProvidedHistogramsSync() { … }
StatisticsRecorder::SnapshotTransactionId StatisticsRecorder::PrepareDeltas(
bool include_persistent,
HistogramBase::Flags flags_to_set,
HistogramBase::Flags required_flags,
HistogramSnapshotManager* snapshot_manager) { … }
StatisticsRecorder::SnapshotTransactionId
StatisticsRecorder::SnapshotUnloggedSamples(
HistogramBase::Flags required_flags,
HistogramSnapshotManager* snapshot_manager) { … }
StatisticsRecorder::SnapshotTransactionId
StatisticsRecorder::GetLastSnapshotTransactionId() { … }
void StatisticsRecorder::InitLogOnShutdown() { … }
HistogramBase* StatisticsRecorder::FindHistogramByHashInternal(
uint64_t hash,
std::string_view name) const { … }
void StatisticsRecorder::AddHistogramSampleObserver(
const std::string& name,
StatisticsRecorder::ScopedHistogramSampleObserver* observer) { … }
void StatisticsRecorder::RemoveHistogramSampleObserver(
const std::string& name,
StatisticsRecorder::ScopedHistogramSampleObserver* observer) { … }
void StatisticsRecorder::FindAndRunHistogramCallbacks(
base::PassKey<HistogramBase>,
const char* histogram_name,
uint64_t name_hash,
HistogramBase::Sample sample) { … }
void StatisticsRecorder::SetGlobalSampleCallback(
const GlobalSampleCallback& new_global_sample_callback) { … }
size_t StatisticsRecorder::GetHistogramCount() { … }
void StatisticsRecorder::ForgetHistogramForTesting(std::string_view name) { … }
std::unique_ptr<StatisticsRecorder>
StatisticsRecorder::CreateTemporaryForTesting() { … }
void StatisticsRecorder::SetRecordChecker(
std::unique_ptr<RecordHistogramChecker> record_checker) { … }
bool StatisticsRecorder::ShouldRecordHistogram(uint32_t histogram_hash) { … }
StatisticsRecorder::Histograms StatisticsRecorder::GetHistograms(
bool include_persistent) { … }
StatisticsRecorder::Histograms StatisticsRecorder::Sort(Histograms histograms) { … }
StatisticsRecorder::Histograms StatisticsRecorder::WithName(
Histograms histograms,
const std::string& query,
bool case_sensitive) { … }
void StatisticsRecorder::ImportGlobalPersistentHistograms() { … }
StatisticsRecorder::StatisticsRecorder() { … }
void StatisticsRecorder::InitLogOnShutdownWhileLocked() { … }
}