0

Remove HistogramBase::Sample type.

Rename HistogramBase::Sample to Sample32.
Add size to type name so the size is known without needing to lookup
the typedef.

Bug: 40899968
Change-Id: Id26bae46a516d62034570f4614779497810836f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6171182
Commit-Queue: Ramon Cano Aparicio <rcanoaparicio@google.com>
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Vigen Issahhanjan <vigeni@google.com>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1408608}
This commit is contained in:
Ramon Cano Aparicio
2025-01-20 05:00:17 -08:00
committed by Chromium LUCI CQ
parent 2cb2ff35bc
commit 4a39d12c4e
67 changed files with 259 additions and 262 deletions
ash/wm
base
cc
chrome
chromecast
components/segmentation_platform/internal/signals
content/browser
extensions/browser/api/metrics_private
gpu/ipc/client
media/midi
services
third_party/blink/renderer
ui/display/util

@@ -44,7 +44,7 @@
namespace ash { namespace ash {
using ::chromeos::WindowStateType; using ::chromeos::WindowStateType;
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
class PipWindowResizerTest : public AshTestBase, class PipWindowResizerTest : public AshTestBase,
public ::testing::WithParamInterface< public ::testing::WithParamInterface<
@@ -663,7 +663,7 @@ TEST_P(PipWindowResizerTest, PipStartAndFinishFreeResizeUmaMetrics) {
ASSERT_TRUE(resizer.get()); ASSERT_TRUE(resizer.get());
EXPECT_EQ(1, histograms().GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms().GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::FREE_RESIZE))); Sample32(AshPipEvents::FREE_RESIZE)));
histograms().ExpectTotalCount(kAshPipEventsHistogramName, 1); histograms().ExpectTotalCount(kAshPipEventsHistogramName, 1);
resizer->Drag(CalculateDragPoint(*resizer, 100, 0), 0); resizer->Drag(CalculateDragPoint(*resizer, 100, 0), 0);
@@ -686,7 +686,7 @@ TEST_P(PipWindowResizerTest, PipPinchResizeTriggersResizeUmaMetrics) {
Shell::Get()->toplevel_window_event_handler()->OnGestureEvent(&event); Shell::Get()->toplevel_window_event_handler()->OnGestureEvent(&event);
EXPECT_EQ(1, histograms().GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms().GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::FREE_RESIZE))); Sample32(AshPipEvents::FREE_RESIZE)));
histograms().ExpectTotalCount(kAshPipEventsHistogramName, 1); histograms().ExpectTotalCount(kAshPipEventsHistogramName, 1);
} }

@@ -87,7 +87,7 @@ class AlwaysMaximizeTestState : public WindowState::State {
using WindowStateTest = AshTestBase; using WindowStateTest = AshTestBase;
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
// Test that a window gets properly snapped to the display's edges in a // Test that a window gets properly snapped to the display's edges in a
// multi monitor environment. // multi monitor environment.
@@ -318,19 +318,19 @@ TEST_F(WindowStateTest, ChromePipWindowUmaMetrics) {
window_state->OnWMEvent(&enter_pip); window_state->OnWMEvent(&enter_pip);
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::PIP_START))); Sample32(AshPipEvents::PIP_START)));
EXPECT_EQ(1, EXPECT_EQ(1,
histograms.GetBucketCount(kAshPipEventsHistogramName, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::CHROME_PIP_START))); Sample32(AshPipEvents::CHROME_PIP_START)));
histograms.ExpectTotalCount(kAshPipEventsHistogramName, 2); histograms.ExpectTotalCount(kAshPipEventsHistogramName, 2);
const WMEvent enter_normal(WM_EVENT_NORMAL); const WMEvent enter_normal(WM_EVENT_NORMAL);
window_state->OnWMEvent(&enter_normal); window_state->OnWMEvent(&enter_normal);
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::PIP_END))); Sample32(AshPipEvents::PIP_END)));
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::CHROME_PIP_END))); Sample32(AshPipEvents::CHROME_PIP_END)));
histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4); histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4);
} }
@@ -345,20 +345,20 @@ TEST_F(WindowStateTest, AndroidPipWindowUmaMetrics) {
window_state->OnWMEvent(&enter_pip); window_state->OnWMEvent(&enter_pip);
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::PIP_START))); Sample32(AshPipEvents::PIP_START)));
EXPECT_EQ(1, EXPECT_EQ(1,
histograms.GetBucketCount(kAshPipEventsHistogramName, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::ANDROID_PIP_START))); Sample32(AshPipEvents::ANDROID_PIP_START)));
histograms.ExpectTotalCount(kAshPipEventsHistogramName, 2); histograms.ExpectTotalCount(kAshPipEventsHistogramName, 2);
const WMEvent enter_normal(WM_EVENT_NORMAL); const WMEvent enter_normal(WM_EVENT_NORMAL);
window_state->OnWMEvent(&enter_normal); window_state->OnWMEvent(&enter_normal);
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::PIP_END))); Sample32(AshPipEvents::PIP_END)));
EXPECT_EQ(1, EXPECT_EQ(1,
histograms.GetBucketCount(kAshPipEventsHistogramName, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::ANDROID_PIP_END))); Sample32(AshPipEvents::ANDROID_PIP_END)));
histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4); histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4);
// Check time count: // Check time count:
@@ -378,9 +378,9 @@ TEST_F(WindowStateTest, ChromePipWindowUmaMetricsCountsExitOnDestroy) {
window.reset(); window.reset();
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::PIP_END))); Sample32(AshPipEvents::PIP_END)));
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::CHROME_PIP_END))); Sample32(AshPipEvents::CHROME_PIP_END)));
histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4); histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4);
} }
@@ -398,10 +398,10 @@ TEST_F(WindowStateTest, AndroidPipWindowUmaMetricsCountsExitOnDestroy) {
window.reset(); window.reset();
EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName, EXPECT_EQ(1, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::PIP_END))); Sample32(AshPipEvents::PIP_END)));
EXPECT_EQ(1, EXPECT_EQ(1,
histograms.GetBucketCount(kAshPipEventsHistogramName, histograms.GetBucketCount(kAshPipEventsHistogramName,
Sample(AshPipEvents::ANDROID_PIP_END))); Sample32(AshPipEvents::ANDROID_PIP_END)));
histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4); histograms.ExpectTotalCount(kAshPipEventsHistogramName, 4);
} }

@@ -79,8 +79,8 @@ HistogramType DummyHistogram::GetHistogramType() const {
} }
bool DummyHistogram::HasConstructionArguments( bool DummyHistogram::HasConstructionArguments(
Sample expected_minimum, Sample32 expected_minimum,
Sample expected_maximum, Sample32 expected_maximum,
size_t expected_bucket_count) const { size_t expected_bucket_count) const {
return true; return true;
} }

@@ -27,15 +27,15 @@ class BASE_EXPORT DummyHistogram : public HistogramBase {
DummyHistogram(const DummyHistogram&) = delete; DummyHistogram(const DummyHistogram&) = delete;
DummyHistogram& operator=(const DummyHistogram&) = delete; DummyHistogram& operator=(const DummyHistogram&) = delete;
// HistogramBase: // HistogramBase
void CheckName(std::string_view name) const override {} void CheckName(std::string_view name) const override {}
uint64_t name_hash() const override; uint64_t name_hash() const override;
HistogramType GetHistogramType() const override; HistogramType GetHistogramType() const override;
bool HasConstructionArguments(Sample expected_minimum, bool HasConstructionArguments(Sample32 expected_minimum,
Sample expected_maximum, Sample32 expected_maximum,
size_t expected_bucket_count) const override; size_t expected_bucket_count) const override;
void Add(Sample value) override {} void Add(Sample32 value) override {}
void AddCount(Sample value, int count) override {} void AddCount(Sample32 value, int count) override {}
bool AddSamples(const HistogramSamples& samples) override; bool AddSamples(const HistogramSamples& samples) override;
bool AddSamplesFromPickle(PickleIterator* iter) override; bool AddSamplesFromPickle(PickleIterator* iter) override;
std::unique_ptr<HistogramSamples> SnapshotSamples() const override; std::unique_ptr<HistogramSamples> SnapshotSamples() const override;

@@ -438,8 +438,8 @@ size_t Histogram::bucket_count() const {
// static // static
bool Histogram::InspectConstructionArguments(std::string_view name, bool Histogram::InspectConstructionArguments(std::string_view name,
Sample* minimum, Sample32* minimum,
Sample* maximum, Sample32* maximum,
size_t* bucket_count) { size_t* bucket_count) {
bool check_okay = true; bool check_okay = true;
@@ -465,7 +465,7 @@ bool Histogram::InspectConstructionArguments(std::string_view name,
} }
if (*bucket_count > kBucketCount_MAX) { if (*bucket_count > kBucketCount_MAX) {
UmaHistogramSparse("Histogram.TooManyBuckets.1000", UmaHistogramSparse("Histogram.TooManyBuckets.1000",
static_cast<Sample>(HashMetricName(name))); static_cast<Sample32>(HashMetricName(name)));
// Blink.UseCounter legitimately has more than 1000 entries in its enum. // Blink.UseCounter legitimately has more than 1000 entries in its enum.
if (!StartsWith(name, "Blink.UseCounter")) { if (!StartsWith(name, "Blink.UseCounter")) {
@@ -500,7 +500,7 @@ bool Histogram::InspectConstructionArguments(std::string_view name,
if (!check_okay) { if (!check_okay) {
UmaHistogramSparse("Histogram.BadConstructionArguments", UmaHistogramSparse("Histogram.BadConstructionArguments",
static_cast<Sample>(HashMetricName(name))); static_cast<Sample32>(HashMetricName(name)));
} }
return check_okay; return check_okay;
@@ -514,8 +514,8 @@ HistogramType Histogram::GetHistogramType() const {
return HISTOGRAM; return HISTOGRAM;
} }
bool Histogram::HasConstructionArguments(Sample expected_minimum, bool Histogram::HasConstructionArguments(Sample32 expected_minimum,
Sample expected_maximum, Sample32 expected_maximum,
size_t expected_bucket_count) const { size_t expected_bucket_count) const {
return (expected_bucket_count == bucket_count() && return (expected_bucket_count == bucket_count() &&
expected_minimum == declared_min() && expected_minimum == declared_min() &&
@@ -687,8 +687,8 @@ HistogramBase* Histogram::DeserializeInfoImpl(PickleIterator* iter) {
// static // static
HistogramBase* Histogram::FactoryGetInternal(std::string_view name, HistogramBase* Histogram::FactoryGetInternal(std::string_view name,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
bool valid_arguments = bool valid_arguments =
@@ -708,10 +708,10 @@ HistogramBase* Histogram::FactoryTimeGetInternal(std::string_view name,
TimeDelta maximum, TimeDelta maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
DCHECK_LT(minimum.InMilliseconds(), std::numeric_limits<Sample>::max()); DCHECK_LT(minimum.InMilliseconds(), std::numeric_limits<Sample32>::max());
DCHECK_LT(maximum.InMilliseconds(), std::numeric_limits<Sample>::max()); DCHECK_LT(maximum.InMilliseconds(), std::numeric_limits<Sample32>::max());
return FactoryGetInternal(name, static_cast<Sample>(minimum.InMilliseconds()), return FactoryGetInternal(name, static_cast<Sample32>(minimum.InMilliseconds()),
static_cast<Sample>(maximum.InMilliseconds()), static_cast<Sample32>(maximum.InMilliseconds()),
bucket_count, flags); bucket_count, flags);
} }
@@ -722,10 +722,10 @@ HistogramBase* Histogram::FactoryMicrosecondsTimeGetInternal(
TimeDelta maximum, TimeDelta maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
DCHECK_LT(minimum.InMicroseconds(), std::numeric_limits<Sample>::max()); DCHECK_LT(minimum.InMicroseconds(), std::numeric_limits<Sample32>::max());
DCHECK_LT(maximum.InMicroseconds(), std::numeric_limits<Sample>::max()); DCHECK_LT(maximum.InMicroseconds(), std::numeric_limits<Sample32>::max());
return FactoryGetInternal(name, static_cast<Sample>(minimum.InMicroseconds()), return FactoryGetInternal(name, static_cast<Sample32>(minimum.InMicroseconds()),
static_cast<Sample>(maximum.InMicroseconds()), static_cast<Sample32>(maximum.InMicroseconds()),
bucket_count, flags); bucket_count, flags);
} }
@@ -813,8 +813,8 @@ class LinearHistogram::Factory : public Histogram::Factory {
LinearHistogram::~LinearHistogram() = default; LinearHistogram::~LinearHistogram() = default;
HistogramBase* LinearHistogram::FactoryGet(std::string_view name, HistogramBase* LinearHistogram::FactoryGet(std::string_view name,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
return FactoryGetInternal(name, minimum, maximum, bucket_count, flags); return FactoryGetInternal(name, minimum, maximum, bucket_count, flags);
@@ -829,8 +829,8 @@ HistogramBase* LinearHistogram::FactoryTimeGet(std::string_view name,
} }
HistogramBase* LinearHistogram::FactoryGet(const std::string& name, HistogramBase* LinearHistogram::FactoryGet(const std::string& name,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
return FactoryGetInternal(name, minimum, maximum, bucket_count, flags); return FactoryGetInternal(name, minimum, maximum, bucket_count, flags);
@@ -845,8 +845,8 @@ HistogramBase* LinearHistogram::FactoryTimeGet(const std::string& name,
} }
HistogramBase* LinearHistogram::FactoryGet(const char* name, HistogramBase* LinearHistogram::FactoryGet(const char* name,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
return FactoryGetInternal(name, minimum, maximum, bucket_count, flags); return FactoryGetInternal(name, minimum, maximum, bucket_count, flags);
@@ -873,8 +873,8 @@ std::unique_ptr<HistogramBase> LinearHistogram::PersistentCreate(
HistogramBase* LinearHistogram::FactoryGetWithRangeDescription( HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
std::string_view name, std::string_view name,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags, int32_t flags,
const DescriptionPair descriptions[]) { const DescriptionPair descriptions[]) {
@@ -928,8 +928,8 @@ std::string LinearHistogram::GetAsciiBucketRange(size_t i) const {
} }
// static // static
void LinearHistogram::InitializeBucketRanges(Sample minimum, void LinearHistogram::InitializeBucketRanges(Sample32 minimum,
Sample maximum, Sample32 maximum,
BucketRanges* ranges) { BucketRanges* ranges) {
double min = minimum; double min = minimum;
double max = maximum; double max = maximum;
@@ -938,7 +938,7 @@ void LinearHistogram::InitializeBucketRanges(Sample minimum,
for (size_t i = 1; i < bucket_count; ++i) { for (size_t i = 1; i < bucket_count; ++i) {
double linear_range = double linear_range =
(min * (bucket_count - 1 - i) + max * (i - 1)) / (bucket_count - 2); (min * (bucket_count - 1 - i) + max * (i - 1)) / (bucket_count - 2);
auto range = static_cast<Sample>(linear_range + 0.5); auto range = static_cast<Sample32>(linear_range + 0.5);
ranges->set_range(i, range); ranges->set_range(i, range);
} }
ranges->set_range(ranges->bucket_count(), HistogramBase::kSampleType_MAX); ranges->set_range(ranges->bucket_count(), HistogramBase::kSampleType_MAX);
@@ -947,8 +947,8 @@ void LinearHistogram::InitializeBucketRanges(Sample minimum,
// static // static
HistogramBase* LinearHistogram::FactoryGetInternal(std::string_view name, HistogramBase* LinearHistogram::FactoryGetInternal(std::string_view name,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
return FactoryGetWithRangeDescription(name, minimum, maximum, bucket_count, return FactoryGetWithRangeDescription(name, minimum, maximum, bucket_count,
@@ -961,10 +961,10 @@ HistogramBase* LinearHistogram::FactoryTimeGetInternal(std::string_view name,
TimeDelta maximum, TimeDelta maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
DCHECK_LT(minimum.InMilliseconds(), std::numeric_limits<Sample>::max()); DCHECK_LT(minimum.InMilliseconds(), std::numeric_limits<Sample32>::max());
DCHECK_LT(maximum.InMilliseconds(), std::numeric_limits<Sample>::max()); DCHECK_LT(maximum.InMilliseconds(), std::numeric_limits<Sample32>::max());
return FactoryGetInternal(name, static_cast<Sample>(minimum.InMilliseconds()), return FactoryGetInternal(name, static_cast<Sample32>(minimum.InMilliseconds()),
static_cast<Sample>(maximum.InMilliseconds()), static_cast<Sample32>(maximum.InMilliseconds()),
bucket_count, flags); bucket_count, flags);
} }
@@ -1207,7 +1207,7 @@ HistogramBase* BooleanHistogram::DeserializeInfoImpl(PickleIterator* iter) {
class CustomHistogram::Factory : public Histogram::Factory { class CustomHistogram::Factory : public Histogram::Factory {
public: public:
Factory(std::string_view name, Factory(std::string_view name,
const std::vector<Sample>* custom_ranges, const std::vector<Sample32>* custom_ranges,
int32_t flags) int32_t flags)
: Histogram::Factory(name, CUSTOM_HISTOGRAM, 0, 0, 0, flags) { : Histogram::Factory(name, CUSTOM_HISTOGRAM, 0, 0, 0, flags) {
custom_ranges_ = custom_ranges; custom_ranges_ = custom_ranges;
@@ -1240,26 +1240,26 @@ class CustomHistogram::Factory : public Histogram::Factory {
} }
private: private:
raw_ptr<const std::vector<Sample>> custom_ranges_; raw_ptr<const std::vector<Sample32>> custom_ranges_;
}; };
HistogramBase* CustomHistogram::FactoryGet( HistogramBase* CustomHistogram::FactoryGet(
std::string_view name, std::string_view name,
const std::vector<Sample>& custom_ranges, const std::vector<Sample32>& custom_ranges,
int32_t flags) { int32_t flags) {
return FactoryGetInternal(name, custom_ranges, flags); return FactoryGetInternal(name, custom_ranges, flags);
} }
HistogramBase* CustomHistogram::FactoryGet( HistogramBase* CustomHistogram::FactoryGet(
const std::string& name, const std::string& name,
const std::vector<Sample>& custom_ranges, const std::vector<Sample32>& custom_ranges,
int32_t flags) { int32_t flags) {
return FactoryGetInternal(name, custom_ranges, flags); return FactoryGetInternal(name, custom_ranges, flags);
} }
HistogramBase* CustomHistogram::FactoryGet( HistogramBase* CustomHistogram::FactoryGet(
const char* name, const char* name,
const std::vector<Sample>& custom_ranges, const std::vector<Sample32>& custom_ranges,
int32_t flags) { int32_t flags) {
return FactoryGetInternal(name, custom_ranges, flags); return FactoryGetInternal(name, custom_ranges, flags);
} }
@@ -1281,9 +1281,9 @@ HistogramType CustomHistogram::GetHistogramType() const {
// static // static
std::vector<Sample32> CustomHistogram::ArrayToCustomEnumRanges( std::vector<Sample32> CustomHistogram::ArrayToCustomEnumRanges(
base::span<const Sample> values) { base::span<const Sample32> values) {
std::vector<Sample> all_values; std::vector<Sample32> all_values;
for (Sample value : values) { for (Sample32 value : values) {
all_values.push_back(value); all_values.push_back(value);
// Ensure that a guard bucket is added. If we end up with duplicate // Ensure that a guard bucket is added. If we end up with duplicate
@@ -1330,9 +1330,9 @@ HistogramBase* CustomHistogram::DeserializeInfoImpl(PickleIterator* iter) {
} }
// First and last ranges are not serialized. // First and last ranges are not serialized.
std::vector<Sample> sample_ranges(bucket_count - 1); std::vector<Sample32> sample_ranges(bucket_count - 1);
for (Sample& sample : sample_ranges) { for (Sample32& sample : sample_ranges) {
if (!iter->ReadInt(&sample)) { if (!iter->ReadInt(&sample)) {
return nullptr; return nullptr;
} }
@@ -1354,7 +1354,7 @@ HistogramBase* CustomHistogram::DeserializeInfoImpl(PickleIterator* iter) {
// static // static
HistogramBase* CustomHistogram::FactoryGetInternal( HistogramBase* CustomHistogram::FactoryGetInternal(
std::string_view name, std::string_view name,
const std::vector<Sample>& custom_ranges, const std::vector<Sample32>& custom_ranges,
int32_t flags) { int32_t flags) {
CHECK(ValidateCustomRanges(custom_ranges)); CHECK(ValidateCustomRanges(custom_ranges));
@@ -1363,9 +1363,9 @@ HistogramBase* CustomHistogram::FactoryGetInternal(
// static // static
bool CustomHistogram::ValidateCustomRanges( bool CustomHistogram::ValidateCustomRanges(
const std::vector<Sample>& custom_ranges) { const std::vector<Sample32>& custom_ranges) {
bool has_valid_range = false; bool has_valid_range = false;
for (Sample sample : custom_ranges) { for (Sample32 sample : custom_ranges) {
if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) { if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) {
return false; return false;
} }

@@ -465,7 +465,7 @@ class BASE_EXPORT LinearHistogram : public Histogram {
// cause overflows of the 31-bit counters, usually with an enum as the value. // cause overflows of the 31-bit counters, usually with an enum as the value.
class BASE_EXPORT ScaledLinearHistogram { class BASE_EXPORT ScaledLinearHistogram {
using AtomicCount = Histogram::AtomicCount; using AtomicCount = Histogram::AtomicCount;
using Sample32 = Histogram::Sample; using Sample32 = Histogram::Sample32;
public: public:
// Currently only works with "exact" linear histograms: minimum=1, maximum=N, // Currently only works with "exact" linear histograms: minimum=1, maximum=N,

@@ -137,7 +137,7 @@ void HistogramBase::AddKiB(Sample32 value, int count) {
} }
void HistogramBase::AddTimeMillisecondsGranularity(const TimeDelta& time) { void HistogramBase::AddTimeMillisecondsGranularity(const TimeDelta& time) {
Add(saturated_cast<Sample>(time.InMilliseconds())); Add(saturated_cast<Sample32>(time.InMilliseconds()));
} }
void HistogramBase::AddTimeMicrosecondsGranularity(const TimeDelta& time) { void HistogramBase::AddTimeMicrosecondsGranularity(const TimeDelta& time) {
@@ -145,7 +145,7 @@ void HistogramBase::AddTimeMicrosecondsGranularity(const TimeDelta& time) {
// clocks. High-resolution metrics cannot make use of low-resolution data and // clocks. High-resolution metrics cannot make use of low-resolution data and
// reporting it merely adds noise to the metric. https://crbug.com/807615#c16 // reporting it merely adds noise to the metric. https://crbug.com/807615#c16
if (TimeTicks::IsHighResolution()) { if (TimeTicks::IsHighResolution()) {
Add(saturated_cast<Sample>(time.InMicroseconds())); Add(saturated_cast<Sample32>(time.InMicroseconds()));
} }
} }

@@ -95,9 +95,6 @@ BASE_EXPORT HistogramBase* DeserializeHistogramInfo(base::PickleIterator* iter);
class BASE_EXPORT HistogramBase { class BASE_EXPORT HistogramBase {
public: public:
typedef int32_t Sample32; // Used for samples. typedef int32_t Sample32; // Used for samples.
// Temporary alias for backward compatibility.
// TODO(crbug.com/40899968): Remove this alias.
typedef Sample32 Sample;
typedef subtle::Atomic32 AtomicCount; // Used to count samples. typedef subtle::Atomic32 AtomicCount; // Used to count samples.
typedef int32_t Count; // Used to manipulate counts in temporaries. typedef int32_t Count; // Used to manipulate counts in temporaries.

@@ -218,7 +218,7 @@ TEST_F(HistogramBaseTest, AddTimeMillisecondsGranularityOverflow) {
1, sample_max, 100, 0); 1, sample_max, 100, 0);
int64_t large_negative = std::numeric_limits<int64_t>::min(); int64_t large_negative = std::numeric_limits<int64_t>::min();
add_count = 0; add_count = 0;
while (large_negative < std::numeric_limits<HistogramBase::Sample>::min()) { while (large_negative < std::numeric_limits<HistogramBase::Sample32>::min()) {
histogram->AddTimeMillisecondsGranularity(Milliseconds(large_negative)); histogram->AddTimeMillisecondsGranularity(Milliseconds(large_negative));
++add_count; ++add_count;
large_negative /= 7; large_negative /= 7;

@@ -297,7 +297,7 @@ class BASE_EXPORT SampleCountIterator {
HistogramBase::Count* count) = 0; HistogramBase::Count* count) = 0;
static_assert(std::numeric_limits<HistogramBase::Sample32>::max() < static_assert(std::numeric_limits<HistogramBase::Sample32>::max() <
std::numeric_limits<int64_t>::max(), std::numeric_limits<int64_t>::max(),
"Get() |max| must be able to hold Histogram::Sample max + 1"); "Get() |max| must be able to hold Histogram::Sample32 max + 1");
// Get the index of current histogram bucket. // Get the index of current histogram bucket.
// For histograms that don't use predefined buckets, it returns false. // For histograms that don't use predefined buckets, it returns false.

@@ -82,7 +82,7 @@ class SnapshotDeltaThread : public SimpleThread {
// but the randomness does not really matter as thread-safety is what is // but the randomness does not really matter as thread-safety is what is
// being tested here and there is already a lot of non-determinism // being tested here and there is already a lot of non-determinism
// surrounding scheduling. // surrounding scheduling.
Histogram::Sample sample = rand() % histogram_max_; Histogram::Sample32 sample = rand() % histogram_max_;
histogram->Add(sample); histogram->Add(sample);
// Take a snapshot of the histogram. Because of the multithreading // Take a snapshot of the histogram. Because of the multithreading
@@ -102,7 +102,7 @@ class SnapshotDeltaThread : public SimpleThread {
private: private:
// Stores an actual |sample| that was emitted for |histogram|. This is done // Stores an actual |sample| that was emitted for |histogram|. This is done
// to compare what was found in histogram snapshots (see StoreSnapshot()). // to compare what was found in histogram snapshots (see StoreSnapshot()).
void StoreActualSample(HistogramBase* histogram, Histogram::Sample sample) { void StoreActualSample(HistogramBase* histogram, Histogram::Sample32 sample) {
subtle::NoBarrier_AtomicIncrement(real_total_samples_count_, 1); subtle::NoBarrier_AtomicIncrement(real_total_samples_count_, 1);
switch (histogram->GetHistogramType()) { switch (histogram->GetHistogramType()) {
case HISTOGRAM: { case HISTOGRAM: {

@@ -410,7 +410,7 @@ std::unique_ptr<HistogramBase> PersistentHistogramAllocator::AllocateHistogram(
bucket_ranges->persistent_reference(); bucket_ranges->persistent_reference();
if (!ranges_ref) { if (!ranges_ref) {
size_t ranges_count = bucket_count + 1; size_t ranges_count = bucket_count + 1;
size_t ranges_bytes = ranges_count * sizeof(HistogramBase::Sample); size_t ranges_bytes = ranges_count * sizeof(HistogramBase::Sample32);
ranges_ref = ranges_ref =
memory_allocator_->Allocate(ranges_bytes, kTypeIdRangesArray); memory_allocator_->Allocate(ranges_bytes, kTypeIdRangesArray);
if (ranges_ref) { if (ranges_ref) {

@@ -76,12 +76,12 @@ class BASE_EXPORT PersistentSampleMap : public HistogramSamples {
// Gets a pointer to a "count" corresponding to a given |value|. Returns NULL // Gets a pointer to a "count" corresponding to a given |value|. Returns NULL
// if sample does not exist. // if sample does not exist.
std::atomic<HistogramBase::Count>* GetSampleCountStorage( std::atomic<HistogramBase::Count>* GetSampleCountStorage(
HistogramBase::Sample value) const; HistogramBase::Sample32 value) const;
// Gets a pointer to a "count" corresponding to a given |value|, creating // Gets a pointer to a "count" corresponding to a given |value|, creating
// the sample (initialized to zero) if it does not already exist. // the sample (initialized to zero) if it does not already exist.
std::atomic<HistogramBase::Count>* GetOrCreateSampleCountStorage( std::atomic<HistogramBase::Count>* GetOrCreateSampleCountStorage(
HistogramBase::Sample value); HistogramBase::Sample32 value);
private: private:
// Gets the object that manages persistent records. This returns the // Gets the object that manages persistent records. This returns the

@@ -51,7 +51,7 @@ class SampleMapIterator : public SampleCountIterator {
SkipEmptyBuckets(); SkipEmptyBuckets();
} }
void Get(HistogramBase::Sample* min, void Get(HistogramBase::Sample32* min,
int64_t* max, int64_t* max,
HistogramBase::Count* count) override { HistogramBase::Count* count) override {
DCHECK(!Done()); DCHECK(!Done());

@@ -71,7 +71,7 @@ DefaultSingleSampleMetric::~DefaultSingleSampleMetric() {
histogram_->Add(sample_); histogram_->Add(sample_);
} }
void DefaultSingleSampleMetric::SetSample(HistogramBase::Sample sample) { void DefaultSingleSampleMetric::SetSample(HistogramBase::Sample32 sample) {
DCHECK_GE(sample, 0); DCHECK_GE(sample, 0);
sample_ = sample; sample_ = sample;
} }

@@ -47,11 +47,11 @@ class BASE_EXPORT SparseHistogram : public HistogramBase {
// HistogramBase: // HistogramBase:
uint64_t name_hash() const override; uint64_t name_hash() const override;
HistogramType GetHistogramType() const override; HistogramType GetHistogramType() const override;
bool HasConstructionArguments(Sample expected_minimum, bool HasConstructionArguments(Sample32 expected_minimum,
Sample expected_maximum, Sample32 expected_maximum,
size_t expected_bucket_count) const override; size_t expected_bucket_count) const override;
void Add(Sample value) override; void Add(Sample32 value) override;
void AddCount(Sample value, int count) override; void AddCount(Sample32 value, int count) override;
bool AddSamples(const HistogramSamples& samples) override; bool AddSamples(const HistogramSamples& samples) override;
bool AddSamplesFromPickle(base::PickleIterator* iter) override; bool AddSamplesFromPickle(base::PickleIterator* iter) override;
std::unique_ptr<HistogramSamples> SnapshotSamples() const override; std::unique_ptr<HistogramSamples> SnapshotSamples() const override;

@@ -430,7 +430,7 @@ TEST_P(SparseHistogramTest, FactoryTime) {
TEST_P(SparseHistogramTest, ExtremeValues) { TEST_P(SparseHistogramTest, ExtremeValues) {
struct Cases { struct Cases {
Histogram::Sample sample; HistogramBase::Sample32 sample;
int64_t expected_max; int64_t expected_max;
}; };
static const auto cases = std::to_array<Cases>({ static const auto cases = std::to_array<Cases>({
@@ -452,7 +452,7 @@ TEST_P(SparseHistogramTest, ExtremeValues) {
std::unique_ptr<SampleCountIterator> it = snapshot->Iterator(); std::unique_ptr<SampleCountIterator> it = snapshot->Iterator();
ASSERT_FALSE(it->Done()); ASSERT_FALSE(it->Done());
base::Histogram::Sample min; base::HistogramBase::Sample32 min;
int64_t max; int64_t max;
base::Histogram::Count count; base::Histogram::Count count;
it->Get(&min, &max, &count); it->Get(&min, &max, &count);

@@ -224,7 +224,7 @@ TEST_F(HistogramTesterTest, MissingHistogramMeansEmptyBuckets) {
TEST_F(HistogramTesterTest, BucketsAre) { TEST_F(HistogramTesterTest, BucketsAre) {
// Auxiliary functions for keeping the lines short. // Auxiliary functions for keeping the lines short.
auto a = [](std::vector<Bucket> b) { return b; }; auto a = [](std::vector<Bucket> b) { return b; };
auto b = [](base::Histogram::Sample min, base::Histogram::Count count) { auto b = [](base::Histogram::Sample32 min, base::Histogram::Count count) {
return Bucket(min, count); return Bucket(min, count);
}; };
using ::testing::Not; using ::testing::Not;
@@ -263,7 +263,7 @@ TEST_F(HistogramTesterTest, BucketsAre) {
TEST_F(HistogramTesterTest, BucketsInclude) { TEST_F(HistogramTesterTest, BucketsInclude) {
// Auxiliary function for the "actual" values to shorten lines. // Auxiliary function for the "actual" values to shorten lines.
auto a = [](std::vector<Bucket> b) { return b; }; auto a = [](std::vector<Bucket> b) { return b; };
auto b = [](base::Histogram::Sample min, base::Histogram::Count count) { auto b = [](base::Histogram::Sample32 min, base::Histogram::Count count) {
return Bucket(min, count); return Bucket(min, count);
}; };
using ::testing::Not; using ::testing::Not;

@@ -62,8 +62,8 @@ ScopedUMAHistogramAreaTimerBase::ScopedUMAHistogramAreaTimerBase() : area_(0) {
ScopedUMAHistogramAreaTimerBase::~ScopedUMAHistogramAreaTimerBase() = default; ScopedUMAHistogramAreaTimerBase::~ScopedUMAHistogramAreaTimerBase() = default;
bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues( bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues(
Sample* time_microseconds, Sample32* time_microseconds,
Sample* pixels_per_ms) const { Sample32* pixels_per_ms) const {
return GetHistogramValues( return GetHistogramValues(
timer_.Elapsed(), area_.ValueOrDefault(std::numeric_limits<int>::max()), timer_.Elapsed(), area_.ValueOrDefault(std::numeric_limits<int>::max()),
time_microseconds, pixels_per_ms); time_microseconds, pixels_per_ms);
@@ -73,16 +73,16 @@ bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues(
bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues( bool ScopedUMAHistogramAreaTimerBase::GetHistogramValues(
base::TimeDelta elapsed, base::TimeDelta elapsed,
int area, int area,
Sample* time_microseconds, Sample32* time_microseconds,
Sample* pixels_per_ms) { Sample32* pixels_per_ms) {
elapsed = std::max(elapsed, base::Microseconds(kMinimumTimeMicroseconds)); elapsed = std::max(elapsed, base::Microseconds(kMinimumTimeMicroseconds));
double area_per_time = area / elapsed.InMillisecondsF(); double area_per_time = area / elapsed.InMillisecondsF();
// It is not clear how NaN can get here, but we've gotten crashes from // It is not clear how NaN can get here, but we've gotten crashes from
// saturated_cast. http://crbug.com/486214 // saturated_cast. http://crbug.com/486214
if (std::isnan(area_per_time)) if (std::isnan(area_per_time))
return false; return false;
*time_microseconds = base::saturated_cast<Sample>(elapsed.InMicroseconds()); *time_microseconds = base::saturated_cast<Sample32>(elapsed.InMicroseconds());
*pixels_per_ms = base::saturated_cast<Sample>(area_per_time); *pixels_per_ms = base::saturated_cast<Sample32>(area_per_time);
return true; return true;
} }

@@ -100,20 +100,20 @@ class CC_BASE_EXPORT ScopedUMAHistogramAreaTimerBase {
void SetArea(const base::CheckedNumeric<int>& area) { area_ = area; } void SetArea(const base::CheckedNumeric<int>& area) { area_ = area; }
protected: protected:
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
ScopedUMAHistogramAreaTimerBase(); ScopedUMAHistogramAreaTimerBase();
~ScopedUMAHistogramAreaTimerBase(); ~ScopedUMAHistogramAreaTimerBase();
// Returns true if histograms should be recorded (i.e. values are valid). // Returns true if histograms should be recorded (i.e. values are valid).
bool GetHistogramValues(Sample* time_microseconds, bool GetHistogramValues(Sample32* time_microseconds,
Sample* pixels_per_ms) const; Sample32* pixels_per_ms) const;
private: private:
static bool GetHistogramValues(base::TimeDelta elapsed, static bool GetHistogramValues(base::TimeDelta elapsed,
int area, int area,
Sample* time_microseconds, Sample32* time_microseconds,
Sample* pixels_per_ms); Sample32* pixels_per_ms);
base::ElapsedTimer timer_; base::ElapsedTimer timer_;
base::CheckedNumeric<int> area_; base::CheckedNumeric<int> area_;

@@ -8,7 +8,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
namespace cc { namespace cc {
@@ -16,10 +16,10 @@ class ScopedUMAHistogramAreaTimerBaseTest : public ::testing::Test {
protected: protected:
void ExpectValidHistogramValues(base::TimeDelta elapsed, void ExpectValidHistogramValues(base::TimeDelta elapsed,
int area, int area,
Sample expected_time_microseconds, Sample32 expected_time_microseconds,
Sample expected_pixels_per_ms) { Sample32 expected_pixels_per_ms) {
Sample time_microseconds; Sample32 time_microseconds;
Sample pixels_per_ms; Sample32 pixels_per_ms;
ScopedUMAHistogramAreaTimerBase::GetHistogramValues( ScopedUMAHistogramAreaTimerBase::GetHistogramValues(
elapsed, area, &time_microseconds, &pixels_per_ms); elapsed, area, &time_microseconds, &pixels_per_ms);
EXPECT_EQ(expected_time_microseconds, time_microseconds); EXPECT_EQ(expected_time_microseconds, time_microseconds);
@@ -49,7 +49,7 @@ TEST_F(ScopedUMAHistogramAreaTimerBaseTest, ZeroTimeAndArea) {
TEST_F(ScopedUMAHistogramAreaTimerBaseTest, VeryLargeTime) { TEST_F(ScopedUMAHistogramAreaTimerBaseTest, VeryLargeTime) {
ExpectValidHistogramValues(base::Hours(24), 1000, ExpectValidHistogramValues(base::Hours(24), 1000,
std::numeric_limits<Sample>::max(), 0); std::numeric_limits<Sample32>::max(), 0);
} }
TEST_F(ScopedUMAHistogramAreaTimerBaseTest, VeryLargeArea) { TEST_F(ScopedUMAHistogramAreaTimerBaseTest, VeryLargeArea) {
@@ -57,7 +57,7 @@ TEST_F(ScopedUMAHistogramAreaTimerBaseTest, VeryLargeArea) {
2000000000); 2000000000);
ExpectValidHistogramValues(base::Microseconds(1000), ExpectValidHistogramValues(base::Microseconds(1000),
std::numeric_limits<int>::max(), 1000, std::numeric_limits<int>::max(), 1000,
std::numeric_limits<Sample>::max()); std::numeric_limits<Sample32>::max());
} }
} // namespace } // namespace

@@ -450,25 +450,25 @@ TEST_F(CompositorFrameReporterTest,
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.TouchPressed.TotalLatency", {"EventLatency.TouchPressed.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.TouchMoved.TotalLatency", {"EventLatency.TouchMoved.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.TouchMoved.TotalLatency", {"EventLatency.TouchMoved.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {
@@ -571,34 +571,34 @@ TEST_F(CompositorFrameReporterTest,
viz_breakdown.presentation_feedback.timestamp; viz_breakdown.presentation_feedback.timestamp;
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.GestureScrollBegin.Wheel.TotalLatency2", {"EventLatency.GestureScrollBegin.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.FirstGestureScrollUpdate.Wheel.TotalLatency2", {"EventLatency.FirstGestureScrollUpdate.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.GestureScrollUpdate.Wheel.TotalLatency2", {"EventLatency.GestureScrollUpdate.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.InertialGestureScrollUpdate.Wheel.TotalLatency2", {"EventLatency.InertialGestureScrollUpdate.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[3]).InMicroseconds())}, (presentation_time - event_times[3]).InMicroseconds())},
{"EventLatency.GestureScrollBegin.Touchscreen.TotalLatency2", {"EventLatency.GestureScrollBegin.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[4]).InMicroseconds())}, (presentation_time - event_times[4]).InMicroseconds())},
{"EventLatency.FirstGestureScrollUpdate.Touchscreen.TotalLatency2", {"EventLatency.FirstGestureScrollUpdate.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[5]).InMicroseconds())}, (presentation_time - event_times[5]).InMicroseconds())},
{"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency", {"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[6]).InMicroseconds())}, (presentation_time - event_times[6]).InMicroseconds())},
{"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency2", {"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[6]).InMicroseconds())}, (presentation_time - event_times[6]).InMicroseconds())},
{"EventLatency.InertialGestureScrollUpdate.Touchscreen.TotalLatency2", {"EventLatency.InertialGestureScrollUpdate.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[7]).InMicroseconds())}, (presentation_time - event_times[7]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {
@@ -674,19 +674,19 @@ TEST_F(CompositorFrameReporterTest,
viz_breakdown.presentation_feedback.timestamp; viz_breakdown.presentation_feedback.timestamp;
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.GesturePinchBegin.Touchpad.TotalLatency", {"EventLatency.GesturePinchBegin.Touchpad.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.GesturePinchUpdate.Touchpad.TotalLatency", {"EventLatency.GesturePinchUpdate.Touchpad.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.GesturePinchBegin.Touchscreen.TotalLatency", {"EventLatency.GesturePinchBegin.Touchscreen.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.GesturePinchUpdate.Touchscreen.TotalLatency", {"EventLatency.GesturePinchUpdate.Touchscreen.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[3]).InMicroseconds())}, (presentation_time - event_times[3]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {

@@ -1260,25 +1260,25 @@ TEST_F(CompositorFrameReportingControllerTest,
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.TouchPressed.TotalLatency", {"EventLatency.TouchPressed.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.TouchMoved.TotalLatency", {"EventLatency.TouchMoved.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.TouchMoved.TotalLatency", {"EventLatency.TouchMoved.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {
@@ -1369,34 +1369,34 @@ TEST_F(CompositorFrameReportingControllerTest,
details.presentation_feedback.timestamp; details.presentation_feedback.timestamp;
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.GestureScrollBegin.Wheel.TotalLatency2", {"EventLatency.GestureScrollBegin.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.FirstGestureScrollUpdate.Wheel.TotalLatency2", {"EventLatency.FirstGestureScrollUpdate.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.GestureScrollUpdate.Wheel.TotalLatency2", {"EventLatency.GestureScrollUpdate.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.InertialGestureScrollUpdate.Wheel.TotalLatency2", {"EventLatency.InertialGestureScrollUpdate.Wheel.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[3]).InMicroseconds())}, (presentation_time - event_times[3]).InMicroseconds())},
{"EventLatency.GestureScrollBegin.Touchscreen.TotalLatency2", {"EventLatency.GestureScrollBegin.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[4]).InMicroseconds())}, (presentation_time - event_times[4]).InMicroseconds())},
{"EventLatency.FirstGestureScrollUpdate.Touchscreen.TotalLatency2", {"EventLatency.FirstGestureScrollUpdate.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[5]).InMicroseconds())}, (presentation_time - event_times[5]).InMicroseconds())},
{"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency", {"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[6]).InMicroseconds())}, (presentation_time - event_times[6]).InMicroseconds())},
{"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency2", {"EventLatency.GestureScrollUpdate.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[6]).InMicroseconds())}, (presentation_time - event_times[6]).InMicroseconds())},
{"EventLatency.InertialGestureScrollUpdate.Touchscreen.TotalLatency2", {"EventLatency.InertialGestureScrollUpdate.Touchscreen.TotalLatency2",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[7]).InMicroseconds())}, (presentation_time - event_times[7]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {
@@ -1530,19 +1530,19 @@ TEST_F(CompositorFrameReportingControllerTest,
details.presentation_feedback.timestamp; details.presentation_feedback.timestamp;
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.GesturePinchBegin.Touchpad.TotalLatency", {"EventLatency.GesturePinchBegin.Touchpad.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.GesturePinchUpdate.Touchpad.TotalLatency", {"EventLatency.GesturePinchUpdate.Touchpad.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.GesturePinchBegin.Touchscreen.TotalLatency", {"EventLatency.GesturePinchBegin.Touchscreen.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.GesturePinchUpdate.Touchscreen.TotalLatency", {"EventLatency.GesturePinchUpdate.Touchscreen.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[3]).InMicroseconds())}, (presentation_time - event_times[3]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {
@@ -1599,25 +1599,25 @@ TEST_F(CompositorFrameReportingControllerTest,
struct { struct {
const char* name; const char* name;
const base::HistogramBase::Sample latency_ms; const base::HistogramBase::Sample32 latency_ms;
} expected_latencies[] = { } expected_latencies[] = {
{"EventLatency.TouchPressed.TotalLatency", {"EventLatency.TouchPressed.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.TouchMoved.TotalLatency", {"EventLatency.TouchMoved.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.TouchMoved.TotalLatency", {"EventLatency.TouchMoved.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[0]).InMicroseconds())}, (presentation_time - event_times[0]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[1]).InMicroseconds())}, (presentation_time - event_times[1]).InMicroseconds())},
{"EventLatency.TotalLatency", {"EventLatency.TotalLatency",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
(presentation_time - event_times[2]).InMicroseconds())}, (presentation_time - event_times[2]).InMicroseconds())},
}; };
for (const auto& expected_latency : expected_latencies) { for (const auto& expected_latency : expected_latencies) {

@@ -28,8 +28,8 @@ namespace about_flags {
namespace { namespace {
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
using SwitchToIdMap = std::map<std::string, Sample>; using SwitchToIdMap = std::map<std::string, Sample32>;
// Get all associated switches corresponding to defined about_flags.cc entries. // Get all associated switches corresponding to defined about_flags.cc entries.
std::set<std::string> GetAllPublicSwitchesAndFeaturesForTesting() { std::set<std::string> GetAllPublicSwitchesAndFeaturesForTesting() {
@@ -240,9 +240,9 @@ class AboutFlagsHistogramTest : public ::testing::Test {
// This is a helper function to check that all IDs in enum LoginCustomFlags in // This is a helper function to check that all IDs in enum LoginCustomFlags in
// histograms.xml are unique. // histograms.xml are unique.
void SetSwitchToHistogramIdMapping(const std::string& switch_name, void SetSwitchToHistogramIdMapping(const std::string& switch_name,
const Sample switch_histogram_id, const Sample32 switch_histogram_id,
std::map<std::string, Sample>* out_map) { std::map<std::string, Sample32>* out_map) {
const std::pair<std::map<std::string, Sample>::iterator, bool> status = const std::pair<std::map<std::string, Sample32>::iterator, bool> status =
out_map->insert(std::make_pair(switch_name, switch_histogram_id)); out_map->insert(std::make_pair(switch_name, switch_histogram_id));
if (!status.second) { if (!status.second) {
EXPECT_TRUE(status.first->second == switch_histogram_id) EXPECT_TRUE(status.first->second == switch_histogram_id)
@@ -255,7 +255,7 @@ class AboutFlagsHistogramTest : public ::testing::Test {
// This method generates a hint for the user for what string should be added // This method generates a hint for the user for what string should be added
// to the enum LoginCustomFlags to make in consistent. // to the enum LoginCustomFlags to make in consistent.
std::string GetHistogramEnumEntryText(const std::string& switch_name, std::string GetHistogramEnumEntryText(const std::string& switch_name,
Sample value) { Sample32 value) {
return base::StringPrintf( return base::StringPrintf(
"<int value=\"%d\" label=\"%s\"/>", value, switch_name.c_str()); "<int value=\"%d\" label=\"%s\"/>", value, switch_name.c_str());
} }
@@ -285,7 +285,7 @@ TEST_F(AboutFlagsHistogramTest, CheckHistograms) {
&metadata_switches_ids); &metadata_switches_ids);
continue; continue;
} }
const Sample uma_id = flags_ui::GetSwitchUMAId(entry.second); const Sample32 uma_id = flags_ui::GetSwitchUMAId(entry.second);
EXPECT_EQ(uma_id, entry.first) EXPECT_EQ(uma_id, entry.first)
<< "tools/metrics/histograms/enums.xml enum LoginCustomFlags " << "tools/metrics/histograms/enums.xml enum LoginCustomFlags "
"entry '" "entry '"
@@ -302,7 +302,7 @@ TEST_F(AboutFlagsHistogramTest, CheckHistograms) {
// Skip empty placeholders. // Skip empty placeholders.
if (flag.empty()) if (flag.empty())
continue; continue;
const Sample uma_id = flags_ui::GetSwitchUMAId(flag); const Sample32 uma_id = flags_ui::GetSwitchUMAId(flag);
EXPECT_NE(flags_ui::testing::kBadSwitchFormatHistogramId, uma_id) EXPECT_NE(flags_ui::testing::kBadSwitchFormatHistogramId, uma_id)
<< "Command-line switch '" << flag << "Command-line switch '" << flag
<< "' from about_flags.cc has UMA ID equal to reserved value " << "' from about_flags.cc has UMA ID equal to reserved value "

@@ -682,7 +682,7 @@ class ChromeBackForwardCacheBrowserWithEmbedTestBase
blink::scheduler::WebSchedulerTrackedFeature feature, blink::scheduler::WebSchedulerTrackedFeature feature,
base::Location location) { base::Location location) {
content::FetchHistogramsFromChildProcesses(); content::FetchHistogramsFromChildProcesses();
base::HistogramBase::Sample32 sample = base::HistogramBase::Sample(feature); base::HistogramBase::Sample32 sample = base::HistogramBase::Sample32(feature);
base::Bucket expected_blocklisted(sample, 1); base::Bucket expected_blocklisted(sample, 1);
EXPECT_THAT(histogram_tester_->GetAllSamples( EXPECT_THAT(histogram_tester_->GetAllSamples(
@@ -763,7 +763,7 @@ class ChromeBackForwardCacheBrowserWithEmbedPdfTest
static constexpr uint8_t kReasonHaveInnerContents = 32; static constexpr uint8_t kReasonHaveInnerContents = 32;
content::FetchHistogramsFromChildProcesses(); content::FetchHistogramsFromChildProcesses();
base::HistogramBase::Sample32 sample = base::HistogramBase::Sample( base::HistogramBase::Sample32 sample = base::HistogramBase::Sample32(
UseOopif() ? kReasonBlocklistedFeatures : kReasonHaveInnerContents); UseOopif() ? kReasonBlocklistedFeatures : kReasonHaveInnerContents);
base::Bucket expected_not_restored(sample, 1); base::Bucket expected_not_restored(sample, 1);

@@ -147,7 +147,7 @@ class MetricIntegrationTest : public InProcessBrowserTest {
// Checks that the UMA bucket count precisely matches the provided value. // Checks that the UMA bucket count precisely matches the provided value.
void ExpectUniqueUMABucketCount(std::string_view metric_name, void ExpectUniqueUMABucketCount(std::string_view metric_name,
base::Histogram::Sample sample, base::Histogram::Sample32 sample,
base::Histogram::Count count); base::Histogram::Count count);
// Checks that we have a single UMA entry. // Checks that we have a single UMA entry.

@@ -782,7 +782,7 @@ class BackForwardCachePrintBrowserTest : public PrintBrowserTest {
void ExpectBlocklistedFeature( void ExpectBlocklistedFeature(
blink::scheduler::WebSchedulerTrackedFeature feature, blink::scheduler::WebSchedulerTrackedFeature feature,
base::Location location) { base::Location location) {
base::HistogramBase::Sample32 sample = base::HistogramBase::Sample(feature); base::HistogramBase::Sample32 sample = base::HistogramBase::Sample32(feature);
AddSampleToBuckets(&expected_blocklisted_features_, sample); AddSampleToBuckets(&expected_blocklisted_features_, sample);
EXPECT_THAT( EXPECT_THAT(

@@ -230,7 +230,7 @@ class LensOverlayLiveTest : public signin::test::LiveTest {
histogram_name, histogram_name,
base::BindLambdaForTesting( base::BindLambdaForTesting(
[&](const char* histogram_name, uint64_t name_hash, [&](const char* histogram_name, uint64_t name_hash,
base::HistogramBase::Sample sample) { run_loop.Quit(); })); base::HistogramBase::Sample32 sample) { run_loop.Quit(); }));
run_loop.Run(); run_loop.Run();
} }

@@ -41,8 +41,8 @@ constexpr int kTitleTagTitleSource =
constexpr int kInferredTitleSource = constexpr int kInferredTitleSource =
static_cast<int>(TileTitleSource::INFERRED); static_cast<int>(TileTitleSource::INFERRED);
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
using Samples = std::vector<Sample>; using Samples = std::vector<Sample32>;
// Helper function that uses sensible defaults for irrelevant fields of // Helper function that uses sensible defaults for irrelevant fields of
// NTPTileImpression. // NTPTileImpression.

@@ -1626,10 +1626,10 @@ int SetupMain() {
PROCESS_MEMORY_COUNTERS pmc; PROCESS_MEMORY_COUNTERS pmc;
if (::GetProcessMemoryInfo(::GetCurrentProcess(), &pmc, sizeof(pmc))) { if (::GetProcessMemoryInfo(::GetCurrentProcess(), &pmc, sizeof(pmc))) {
UMA_HISTOGRAM_MEMORY_KB("Setup.Install.PeakPagefileUsage", UMA_HISTOGRAM_MEMORY_KB("Setup.Install.PeakPagefileUsage",
base::saturated_cast<base::HistogramBase::Sample>( base::saturated_cast<base::HistogramBase::Sample32>(
pmc.PeakPagefileUsage / 1024)); pmc.PeakPagefileUsage / 1024));
UMA_HISTOGRAM_MEMORY_KB("Setup.Install.PeakWorkingSetSize", UMA_HISTOGRAM_MEMORY_KB("Setup.Install.PeakWorkingSetSize",
base::saturated_cast<base::HistogramBase::Sample>( base::saturated_cast<base::HistogramBase::Sample32>(
pmc.PeakWorkingSetSize / 1024)); pmc.PeakWorkingSetSize / 1024));
} }

@@ -93,8 +93,8 @@ class GroupedHistogram : public base::Histogram {
// TODO(crbug.com/40824087): min/max parameters are redundant with "ranges" // TODO(crbug.com/40824087): min/max parameters are redundant with "ranges"
// and can probably be removed. // and can probably be removed.
GroupedHistogram(const char* metric_to_override, GroupedHistogram(const char* metric_to_override,
Sample minimum, Sample32 minimum,
Sample maximum, Sample32 maximum,
const base::BucketRanges* ranges) const base::BucketRanges* ranges)
: Histogram(metric_to_override, ranges), : Histogram(metric_to_override, ranges),
minimum_(minimum), minimum_(minimum),
@@ -108,7 +108,7 @@ class GroupedHistogram : public base::Histogram {
} }
// base::Histogram implementation: // base::Histogram implementation:
void Add(Sample value) override { void Add(Sample32 value) override {
Histogram::Add(value); Histogram::Add(value);
// Note: This is very inefficient. Fetching the app name (which has a lock) // Note: This is very inefficient. Fetching the app name (which has a lock)
@@ -129,8 +129,8 @@ class GroupedHistogram : public base::Histogram {
private: private:
// Saved construction arguments for reconstructing the Histogram later (with // Saved construction arguments for reconstructing the Histogram later (with
// a suffixed app name). // a suffixed app name).
Sample minimum_; Sample32 minimum_;
Sample maximum_; Sample32 maximum_;
uint32_t bucket_count_; uint32_t bucket_count_;
}; };
@@ -139,8 +139,8 @@ class GroupedHistogram : public base::Histogram {
// It acts similarly to Histogram::FactoryGet but checks that // It acts similarly to Histogram::FactoryGet but checks that
// the histogram is being newly created and does not already exist. // the histogram is being newly created and does not already exist.
void PreregisterHistogram(const char* name, void PreregisterHistogram(const char* name,
GroupedHistogram::Sample minimum, GroupedHistogram::Sample32 minimum,
GroupedHistogram::Sample maximum, GroupedHistogram::Sample32 maximum,
size_t bucket_count, size_t bucket_count,
int32_t flags) { int32_t flags) {
std::string_view name_piece(name); std::string_view name_piece(name);

@@ -50,7 +50,7 @@ class CastRuntimeHistogramFlattener final : public base::HistogramFlattener {
for (std::unique_ptr<base::SampleCountIterator> it = samples.Iterator(); for (std::unique_ptr<base::SampleCountIterator> it = samples.Iterator();
!it->Done(); it->Next()) { !it->Done(); it->Next()) {
base::Histogram::Sample min; base::Histogram::Sample32 min;
int64_t max = 0; int64_t max = 0;
base::Histogram::Count count; base::Histogram::Count count;
it->Get(&min, &max, &count); it->Get(&min, &max, &count);

@@ -36,7 +36,7 @@ class HistogramSignalHandler {
// Called when a histogram signal tracked by segmentation platform is // Called when a histogram signal tracked by segmentation platform is
// updated and written to database. // updated and written to database.
virtual void OnHistogramSignalUpdated(const std::string& histogram_name, virtual void OnHistogramSignalUpdated(const std::string& histogram_name,
base::HistogramBase::Sample) = 0; base::HistogramBase::Sample32) = 0;
~Observer() override = default; ~Observer() override = default;
protected: protected:

@@ -41,7 +41,7 @@ class MockObserver : public HistogramSignalHandler::Observer {
~MockObserver() override = default; ~MockObserver() override = default;
MOCK_METHOD(void, MOCK_METHOD(void,
OnHistogramSignalUpdated, OnHistogramSignalUpdated,
(const std::string&, base::HistogramBase::Sample), (const std::string&, base::HistogramBase::Sample32),
(override)); (override));
}; };

@@ -2564,7 +2564,7 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ExpectBucketCount( ExpectBucketCount(
"BackForwardCache.UnexpectedRendererToBrowserMessage.InterfaceName", "BackForwardCache.UnexpectedRendererToBrowserMessage.InterfaceName",
base::HistogramBase::Sample( base::HistogramBase::Sample32(
static_cast<int32_t>(base::HashMetricName(mojom::Echo::Name_))), static_cast<int32_t>(base::HashMetricName(mojom::Echo::Name_))),
1); 1);
} }
@@ -2649,7 +2649,7 @@ IN_PROC_BROWSER_TEST_F(
ExpectBucketCount( ExpectBucketCount(
"BackForwardCache.UnexpectedRendererToBrowserMessage.InterfaceName", "BackForwardCache.UnexpectedRendererToBrowserMessage.InterfaceName",
base::HistogramBase::Sample( base::HistogramBase::Sample32(
static_cast<int32_t>(base::HashMetricName(mojom::Echo::Name_))), static_cast<int32_t>(base::HashMetricName(mojom::Echo::Name_))),
1); 1);

@@ -306,7 +306,7 @@ MetricsPrivateGetHistogramFunction::GetHistogram(const std::string& name) {
for (std::unique_ptr<base::SampleCountIterator> it = samples->Iterator(); for (std::unique_ptr<base::SampleCountIterator> it = samples->Iterator();
!it->Done(); it->Next()) { !it->Done(); it->Next()) {
base::HistogramBase::Sample min = 0; base::HistogramBase::Sample32 min = 0;
int64_t max = 0; int64_t max = 0;
base::HistogramBase::Count count = 0; base::HistogramBase::Count count = 0;
it->Get(&min, &max, &count); it->Get(&min, &max, &count);

@@ -706,9 +706,9 @@ CommandBufferProxyImpl::GetUMAHistogramEnsureWorkVisibleDuration() {
// //
// Histogram values are in microseconds. // Histogram values are in microseconds.
std::vector<base::HistogramBase::Sample> intervals; std::vector<base::HistogramBase::Sample32> intervals;
constexpr base::HistogramBase::Sample k15Milliseconds = 15 * 1000; constexpr base::HistogramBase::Sample32 k15Milliseconds = 15 * 1000;
constexpr base::HistogramBase::Sample k30Seconds = 30 * 1000 * 1000; constexpr base::HistogramBase::Sample32 k30Seconds = 30 * 1000 * 1000;
constexpr int kFirstPartCount = 60; constexpr int kFirstPartCount = 60;
constexpr int kSecondPartCount = 120; constexpr int kSecondPartCount = 120;
intervals.reserve(kFirstPartCount + kSecondPartCount); intervals.reserve(kFirstPartCount + kSecondPartCount);

@@ -78,7 +78,7 @@ bool IsValidWebMIDIData(const std::vector<uint8_t>& data) {
if (data[i] == kEndOfSysExByte) { if (data[i] == kEndOfSysExByte) {
in_sysex = false; in_sysex = false;
UMA_HISTOGRAM_COUNTS_1M("Media.Midi.SysExMessageSizeUpTo1MB", UMA_HISTOGRAM_COUNTS_1M("Media.Midi.SysExMessageSizeUpTo1MB",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
i - sysex_start_offset + 1)); i - sysex_start_offset + 1));
} else if (!IsDataByte(current)) { } else if (!IsDataByte(current)) {
return false; // Error: |current| should have been data byte. return false; // Error: |current| should have been data byte.

@@ -15,7 +15,7 @@ namespace midi {
namespace { namespace {
using Sample = base::HistogramBase::Sample; using Sample32 = base::HistogramBase::Sample32;
using midi::mojom::PortState; using midi::mojom::PortState;
using midi::mojom::Result; using midi::mojom::Result;

@@ -37,7 +37,7 @@ constexpr char kPreflightWarningHistogramName[] =
base::Bucket MakeBucket(mojom::CorsError error, base::Bucket MakeBucket(mojom::CorsError error,
base::HistogramBase::Count count) { base::HistogramBase::Count count) {
return base::Bucket(static_cast<base::HistogramBase::Sample>(error), count); return base::Bucket(static_cast<base::HistogramBase::Sample32>(error), count);
} }
std::vector<std::pair<std::string, std::string>> MakeHeaderPairs( std::vector<std::pair<std::string, std::string>> MakeHeaderPairs(

@@ -477,7 +477,7 @@ class WebBundleURLLoaderFactory::BundleDataSource
DCHECK(!finished_loading_); DCHECK(!finished_loading_);
base::UmaHistogramCustomCounts( base::UmaHistogramCustomCounts(
"SubresourceWebBundles.ReceivedSize", "SubresourceWebBundles.ReceivedSize",
base::saturated_cast<base::Histogram::Sample>(buffer_.size()), 1, base::saturated_cast<base::Histogram::Sample32>(buffer_.size()), 1,
50000000, 50); 50000000, 50);
DCHECK(data_completed_closure_); DCHECK(data_completed_closure_);
// Defer calling |data_completed_closure_| not to run // Defer calling |data_completed_closure_| not to run

@@ -60,11 +60,11 @@ bool BackgroundTracingAgentImpl::DoEmitNamedTrigger(
void BackgroundTracingAgentImpl::OnHistogramChanged( void BackgroundTracingAgentImpl::OnHistogramChanged(
const std::string& rule_id, const std::string& rule_id,
base::Histogram::Sample histogram_lower_value, base::Histogram::Sample32 histogram_lower_value,
base::Histogram::Sample histogram_upper_value, base::Histogram::Sample32 histogram_upper_value,
const char* histogram_name, const char* histogram_name,
uint64_t name_hash, uint64_t name_hash,
base::Histogram::Sample actual_value) { base::Histogram::Sample32 actual_value) {
if (actual_value < histogram_lower_value || if (actual_value < histogram_lower_value ||
actual_value > histogram_upper_value) { actual_value > histogram_upper_value) {
return; return;

@@ -46,11 +46,11 @@ class COMPONENT_EXPORT(BACKGROUND_TRACING_CPP) BackgroundTracingAgentImpl
private: private:
void OnHistogramChanged(const std::string& rule_id, void OnHistogramChanged(const std::string& rule_id,
base::Histogram::Sample reference_lower_value, base::Histogram::Sample32 reference_lower_value,
base::Histogram::Sample reference_upper_value, base::Histogram::Sample32 reference_upper_value,
const char* histogram_name, const char* histogram_name,
uint64_t name_hash, uint64_t name_hash,
base::Histogram::Sample actual_value); base::Histogram::Sample32 actual_value);
mojo::Remote<mojom::BackgroundTracingAgentClient> client_; mojo::Remote<mojom::BackgroundTracingAgentClient> client_;
base::Time histogram_last_changed_; base::Time histogram_last_changed_;

@@ -258,7 +258,7 @@ void CustomEventRecorder::LogHistograms() {
void CustomEventRecorder::OnMetricsSampleCallback( void CustomEventRecorder::OnMetricsSampleCallback(
const char* histogram_name, const char* histogram_name,
uint64_t name_hash, uint64_t name_hash,
base::HistogramBase::Sample sample) { base::HistogramBase::Sample32 sample) {
TRACE_EVENT_INSTANT( TRACE_EVENT_INSTANT(
kHistogramSamplesCategory, "HistogramSample", kHistogramSamplesCategory, "HistogramSample",
[&](perfetto::EventContext ctx) { [&](perfetto::EventContext ctx) {

@@ -51,7 +51,7 @@ class COMPONENT_EXPORT(TRACING_CPP) CustomEventRecorder
// the trace config, all the histograms will be monitored. // the trace config, all the histograms will be monitored.
static void OnMetricsSampleCallback(const char* histogram_name, static void OnMetricsSampleCallback(const char* histogram_name,
uint64_t name_hash, uint64_t name_hash,
base::HistogramBase::Sample sample); base::HistogramBase::Sample32 sample);
bool IsPrivacyFilteringEnabled(); bool IsPrivacyFilteringEnabled();
private: private:

@@ -288,21 +288,21 @@ void V8MetricsRecorder::AddMainThreadEvent(
CustomCountHistogram, collection_rate_histogram, \ CustomCountHistogram, collection_rate_histogram, \
("V8.GC.Cycle" priority ".CollectionRate.Full", 1, 100, 20)); \ ("V8.GC.Cycle" priority ".CollectionRate.Full", 1, 100, 20)); \
collection_rate_histogram.Count( \ collection_rate_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
100 * event.collection_rate_in_percent)); \ 100 * event.collection_rate_in_percent)); \
\ \
DEFINE_THREAD_SAFE_STATIC_LOCAL( \ DEFINE_THREAD_SAFE_STATIC_LOCAL( \
CustomCountHistogram, collection_weight_histogram, \ CustomCountHistogram, collection_weight_histogram, \
("V8.GC.Cycle" priority ".CollectionWeight.Full", 1, 1000, 20)); \ ("V8.GC.Cycle" priority ".CollectionWeight.Full", 1, 1000, 20)); \
collection_weight_histogram.Count( \ collection_weight_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
1000 * event.collection_weight_in_percent)); \ 1000 * event.collection_weight_in_percent)); \
DEFINE_THREAD_SAFE_STATIC_LOCAL( \ DEFINE_THREAD_SAFE_STATIC_LOCAL( \
CustomCountHistogram, main_thread_collection_weight_histogram, \ CustomCountHistogram, main_thread_collection_weight_histogram, \
("V8.GC.Cycle" priority ".CollectionWeight.MainThread.Full", 1, 1000, \ ("V8.GC.Cycle" priority ".CollectionWeight.MainThread.Full", 1, 1000, \
20)); \ 20)); \
main_thread_collection_weight_histogram.Count( \ main_thread_collection_weight_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
1000 * event.main_thread_collection_weight_in_percent)); \ 1000 * event.main_thread_collection_weight_in_percent)); \
} }
@@ -400,14 +400,14 @@ void V8MetricsRecorder::AddMainThreadEvent(
CustomCountHistogram, collection_rate_cpp_histogram, \ CustomCountHistogram, collection_rate_cpp_histogram, \
("V8.GC.Cycle" priority ".CollectionRate.Full.Cpp", 1, 100, 20)); \ ("V8.GC.Cycle" priority ".CollectionRate.Full.Cpp", 1, 100, 20)); \
collection_rate_cpp_histogram.Count( \ collection_rate_cpp_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
100 * event.collection_rate_cpp_in_percent)); \ 100 * event.collection_rate_cpp_in_percent)); \
\ \
DEFINE_THREAD_SAFE_STATIC_LOCAL( \ DEFINE_THREAD_SAFE_STATIC_LOCAL( \
CustomCountHistogram, collection_weight_cpp_histogram, \ CustomCountHistogram, collection_weight_cpp_histogram, \
("V8.GC.Cycle" priority ".CollectionWeight.Full.Cpp", 1, 1000, 20)); \ ("V8.GC.Cycle" priority ".CollectionWeight.Full.Cpp", 1, 1000, 20)); \
collection_weight_cpp_histogram.Count( \ collection_weight_cpp_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
1000 * event.collection_weight_cpp_in_percent)); \ 1000 * event.collection_weight_cpp_in_percent)); \
\ \
DEFINE_THREAD_SAFE_STATIC_LOCAL( \ DEFINE_THREAD_SAFE_STATIC_LOCAL( \
@@ -415,7 +415,7 @@ void V8MetricsRecorder::AddMainThreadEvent(
("V8.GC.Cycle" priority ".CollectionWeight.MainThread.Full.Cpp", 1, \ ("V8.GC.Cycle" priority ".CollectionWeight.MainThread.Full.Cpp", 1, \
1000, 20)); \ 1000, 20)); \
main_thread_collection_weight_cpp_histogram.Count( \ main_thread_collection_weight_cpp_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
1000 * event.main_thread_collection_weight_cpp_in_percent)); \ 1000 * event.main_thread_collection_weight_cpp_in_percent)); \
} }
@@ -528,7 +528,7 @@ void V8MetricsRecorder::AddMainThreadEvent(
CustomCountHistogram, collection_rate_histogram, \ CustomCountHistogram, collection_rate_histogram, \
("V8.GC.Cycle" priority ".CollectionRate.Young", 1, 100, 20)); \ ("V8.GC.Cycle" priority ".CollectionRate.Young", 1, 100, 20)); \
collection_rate_histogram.Count( \ collection_rate_histogram.Count( \
base::saturated_cast<base::Histogram::Sample>( \ base::saturated_cast<base::Histogram::Sample32>( \
100 * event.collection_rate_in_percent)); \ 100 * event.collection_rate_in_percent)); \
} }

@@ -124,7 +124,7 @@ void HighestPmfReporter::OnReportMetrics() {
void HighestPmfReporter::ReportMetrics() { void HighestPmfReporter::ReportMetrics() {
base::UmaHistogramMemoryMB(kHighestPmfMetricNames[report_count_], base::UmaHistogramMemoryMB(kHighestPmfMetricNames[report_count_],
base::saturated_cast<base::Histogram::Sample>( base::saturated_cast<base::Histogram::Sample32>(
current_highest_pmf_ / 1024 / 1024)); current_highest_pmf_ / 1024 / 1024));
} }

@@ -23,8 +23,8 @@
namespace { namespace {
inline base::HistogramBase::Sample ToSample(int64_t value) { inline base::HistogramBase::Sample32 ToSample(int64_t value) {
return base::saturated_cast<base::HistogramBase::Sample>(value); return base::saturated_cast<base::HistogramBase::Sample32>(value);
} }
inline int64_t ApplyBucket(int64_t value) { inline int64_t ApplyBucket(int64_t value) {

@@ -918,8 +918,8 @@ TEST_F(LocalFrameUkmAggregatorSimTest, VisualUpdateDelay) {
Compositor().BeginFrame(); Compositor().BeginFrame();
histogram_tester.ExpectTotalCount("Blink.VisualUpdateDelay.UpdateTime.PreFCP", histogram_tester.ExpectTotalCount("Blink.VisualUpdateDelay.UpdateTime.PreFCP",
1); 1);
base::HistogramBase::Sample delay = base::HistogramBase::Sample32 delay =
base::saturated_cast<base::HistogramBase::Sample>( base::saturated_cast<base::HistogramBase::Sample32>(
(Compositor().LastFrameTime() - (Compositor().LastFrameTime() -
local_root_aggregator().LastFrameRequestTimeForTest()) local_root_aggregator().LastFrameRequestTimeForTest())
.InMicroseconds()); .InMicroseconds());

@@ -302,10 +302,10 @@ TEST_P(MainThreadScrollingReasonsTest, ReportBackgroundAttachmentFixed) {
"Renderer4.MainThreadGestureScrollReason2"), "Renderer4.MainThreadGestureScrollReason2"),
testing::ElementsAre( testing::ElementsAre(
base::Bucket( base::Bucket(
base::HistogramBase::Sample( base::HistogramBase::Sample32(
cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason), cc::MainThreadScrollingReason::kScrollingOnMainForAnyReason),
1), 1),
base::Bucket(base::HistogramBase::Sample( base::Bucket(base::HistogramBase::Sample32(
cc::MainThreadScrollingReason::BucketIndexForTesting( cc::MainThreadScrollingReason::BucketIndexForTesting(
expected_reason)), expected_reason)),
1))); 1)));

@@ -551,7 +551,7 @@ IDBRequest* IDBObjectStore::DoPut(ScriptState* script_state,
// Records 1KB to 1GB. // Records 1KB to 1GB.
UMA_HISTOGRAM_COUNTS_1M( UMA_HISTOGRAM_COUNTS_1M(
"WebCore.IndexedDB.PutValueSize2", "WebCore.IndexedDB.PutValueSize2",
base::saturated_cast<base::HistogramBase::Sample>( base::saturated_cast<base::HistogramBase::Sample32>(
value_wrapper.DataLengthBeforeWrapInBytes() / 1024)); value_wrapper.DataLengthBeforeWrapInBytes() / 1024));
IDBRequest* request = IDBRequest::Create( IDBRequest* request = IDBRequest::Create(

@@ -888,13 +888,13 @@ void ServiceWorkerGlobalScope::CountCacheStorageInstalledScript(
base::UmaHistogramCustomCounts( base::UmaHistogramCustomCounts(
"ServiceWorker.CacheStorageInstalledScript.ScriptSize", "ServiceWorker.CacheStorageInstalledScript.ScriptSize",
base::saturated_cast<base::Histogram::Sample>(script_size), 1000, 5000000, base::saturated_cast<base::Histogram::Sample32>(script_size), 1000, 5000000,
50); 50);
if (script_metadata_size) { if (script_metadata_size) {
base::UmaHistogramCustomCounts( base::UmaHistogramCustomCounts(
"ServiceWorker.CacheStorageInstalledScript.CachedMetadataSize", "ServiceWorker.CacheStorageInstalledScript.CachedMetadataSize",
base::saturated_cast<base::Histogram::Sample>(script_metadata_size), base::saturated_cast<base::Histogram::Sample32>(script_metadata_size),
1000, 50000000, 50); 1000, 50000000, 50);
} }
} }
@@ -1348,18 +1348,18 @@ void ServiceWorkerGlobalScope::SetIsInstalling(bool is_installing) {
// stored in Cache storage during installation. // stored in Cache storage during installation.
base::UmaHistogramCounts1000( base::UmaHistogramCounts1000(
"ServiceWorker.CacheStorageInstalledScript.Count", "ServiceWorker.CacheStorageInstalledScript.Count",
base::saturated_cast<base::Histogram::Sample>( base::saturated_cast<base::Histogram::Sample32>(
cache_storage_installed_script_count_)); cache_storage_installed_script_count_));
base::UmaHistogramCustomCounts( base::UmaHistogramCustomCounts(
"ServiceWorker.CacheStorageInstalledScript.ScriptTotalSize", "ServiceWorker.CacheStorageInstalledScript.ScriptTotalSize",
base::saturated_cast<base::Histogram::Sample>( base::saturated_cast<base::Histogram::Sample32>(
cache_storage_installed_script_total_size_), cache_storage_installed_script_total_size_),
1000, 50000000, 50); 1000, 50000000, 50);
if (cache_storage_installed_script_metadata_total_size_) { if (cache_storage_installed_script_metadata_total_size_) {
base::UmaHistogramCustomCounts( base::UmaHistogramCustomCounts(
"ServiceWorker.CacheStorageInstalledScript.CachedMetadataTotalSize", "ServiceWorker.CacheStorageInstalledScript.CachedMetadataTotalSize",
base::saturated_cast<base::Histogram::Sample>( base::saturated_cast<base::Histogram::Sample32>(
cache_storage_installed_script_metadata_total_size_), cache_storage_installed_script_metadata_total_size_),
1000, 50000000, 50); 1000, 50000000, 50);
} }

@@ -667,7 +667,7 @@ void CachedStorageArea::EnsureLoaded() {
// always above what we see in practice, since histograms can't change. // always above what we see in practice, since histograms can't change.
UMA_HISTOGRAM_CUSTOM_COUNTS( UMA_HISTOGRAM_CUSTOM_COUNTS(
"LocalStorage.MojoSizeInKB", "LocalStorage.MojoSizeInKB",
base::saturated_cast<base::Histogram::Sample>(local_storage_size_kb), 1, base::saturated_cast<base::Histogram::Sample32>(local_storage_size_kb), 1,
6 * 1024, 50); 6 * 1024, 50);
if (local_storage_size_kb < 100) { if (local_storage_size_kb < 100) {
UMA_HISTOGRAM_TIMES("LocalStorage.MojoTimeToPrimeForUnder100KB", UMA_HISTOGRAM_TIMES("LocalStorage.MojoTimeToPrimeForUnder100KB",

@@ -108,7 +108,7 @@ void BitmapImageMetrics::CountDecodedImageDensity(const String& type,
} }
density_histogram->CountMany( density_histogram->CountMany(
base::saturated_cast<base::Histogram::Sample>(density_centi_bpp), base::saturated_cast<base::Histogram::Sample32>(density_centi_bpp),
image_size_kib); image_size_kib);
} }

@@ -155,7 +155,7 @@ class ParkableImageBaseTest : public ::testing::Test {
// //
// Checks the counts for all 3 metrics, but only checks the value for // Checks the counts for all 3 metrics, but only checks the value for
// "Memory.ParkableImage.Write.Size", since the others can't be easily tested. // "Memory.ParkableImage.Write.Size", since the others can't be easily tested.
void ExpectWriteStatistics(base::HistogramBase::Sample sample, void ExpectWriteStatistics(base::HistogramBase::Sample32 sample,
base::HistogramBase::Count expected_count) { base::HistogramBase::Count expected_count) {
histogram_tester_.ExpectTotalCount("Memory.ParkableImage.Write.Latency", histogram_tester_.ExpectTotalCount("Memory.ParkableImage.Write.Latency",
expected_count); expected_count);
@@ -170,7 +170,7 @@ class ParkableImageBaseTest : public ::testing::Test {
// //
// Checks the counts for both metrics, but not their values, since they can't // Checks the counts for both metrics, but not their values, since they can't
// be easily tested. // be easily tested.
void ExpectReadStatistics(base::HistogramBase::Sample sample, void ExpectReadStatistics(base::HistogramBase::Sample32 sample,
base::HistogramBase::Count expected_count) { base::HistogramBase::Count expected_count) {
histogram_tester_.ExpectTotalCount("Memory.ParkableImage.Read.Latency", histogram_tester_.ExpectTotalCount("Memory.ParkableImage.Read.Latency",
expected_count); expected_count);

@@ -876,7 +876,7 @@ void InspectImage(
void TestAvifBppHistogram(const char* image_name, void TestAvifBppHistogram(const char* image_name,
const char* histogram_name = nullptr, const char* histogram_name = nullptr,
base::HistogramBase::Sample sample = 0) { base::HistogramBase::Sample32 sample = 0) {
TestBppHistogram(CreateAVIFDecoder, "Avif", image_name, histogram_name, TestBppHistogram(CreateAVIFDecoder, "Avif", image_name, histogram_name,
sample); sample);
} }

@@ -878,7 +878,7 @@ void InspectImage(
void TestAvifBppHistogram(const char* image_name, void TestAvifBppHistogram(const char* image_name,
const char* histogram_name = nullptr, const char* histogram_name = nullptr,
base::HistogramBase::Sample sample = 0) { base::HistogramBase::Sample32 sample = 0) {
TestBppHistogram(CreateAVIFDecoder, "Avif", image_name, histogram_name, TestBppHistogram(CreateAVIFDecoder, "Avif", image_name, histogram_name,
sample); sample);
} }

@@ -708,7 +708,7 @@ void ImageDecoder::UpdateBppHistogram(gfx::Size size, size_t image_size_bytes) {
density_histogram = &density_14plus_mp_histogram; density_histogram = &density_14plus_mp_histogram;
} }
density_histogram->Count(base::saturated_cast<base::Histogram::Sample>( density_histogram->Count(base::saturated_cast<base::Histogram::Sample32>(
density_centi_bpp.ValueOrDie())); density_centi_bpp.ValueOrDie()));
} }

@@ -536,7 +536,7 @@ void TestBppHistogram(DecoderCreator create_decoder,
const char* image_type, const char* image_type,
const char* image_name, const char* image_name,
const char* histogram_name, const char* histogram_name,
base::HistogramBase::Sample sample) { base::HistogramBase::Sample32 sample) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
std::unique_ptr<ImageDecoder> decoder = create_decoder(); std::unique_ptr<ImageDecoder> decoder = create_decoder();
decoder->SetData(ReadFileToSharedBuffer(image_name), true); decoder->SetData(ReadFileToSharedBuffer(image_name), true);

@@ -127,7 +127,7 @@ void TestBppHistogram(DecoderCreator create_decoder,
const char* image_type, const char* image_type,
const char* image_name, const char* image_name,
const char* histogram_name, const char* histogram_name,
base::HistogramBase::Sample sample); base::HistogramBase::Sample32 sample);
} // namespace blink } // namespace blink

@@ -106,7 +106,7 @@ void ReadYUV(size_t max_decoded_bytes,
void TestJpegBppHistogram(const char* image_name, void TestJpegBppHistogram(const char* image_name,
const char* histogram_name = nullptr, const char* histogram_name = nullptr,
base::HistogramBase::Sample sample = 0) { base::HistogramBase::Sample32 sample = 0) {
TestBppHistogram(CreateJPEGDecoder, "Jpeg", image_name, histogram_name, TestBppHistogram(CreateJPEGDecoder, "Jpeg", image_name, histogram_name,
sample); sample);
} }

@@ -64,7 +64,7 @@ void TestInvalidImage(const char* webp_file, bool parse_error_expected) {
void TestWebPBppHistogram(const char* image_name, void TestWebPBppHistogram(const char* image_name,
const char* histogram_name = nullptr, const char* histogram_name = nullptr,
base::HistogramBase::Sample sample = 0) { base::HistogramBase::Sample32 sample = 0) {
TestBppHistogram(CreateWEBPDecoder, "WebP", image_name, histogram_name, TestBppHistogram(CreateWEBPDecoder, "WebP", image_name, histogram_name,
sample); sample);
} }

@@ -11,8 +11,8 @@
namespace blink { namespace blink {
CustomCountHistogram::CustomCountHistogram(const char* name, CustomCountHistogram::CustomCountHistogram(const char* name,
base::HistogramBase::Sample min, base::HistogramBase::Sample32 min,
base::HistogramBase::Sample max, base::HistogramBase::Sample32 max,
int32_t bucket_count) { int32_t bucket_count) {
histogram_ = base::Histogram::FactoryGet( histogram_ = base::Histogram::FactoryGet(
name, min, max, bucket_count, name, min, max, bucket_count,
@@ -22,17 +22,17 @@ CustomCountHistogram::CustomCountHistogram(const char* name,
CustomCountHistogram::CustomCountHistogram(base::HistogramBase* histogram) CustomCountHistogram::CustomCountHistogram(base::HistogramBase* histogram)
: histogram_(histogram) {} : histogram_(histogram) {}
void CustomCountHistogram::Count(base::HistogramBase::Sample sample) { void CustomCountHistogram::Count(base::HistogramBase::Sample32 sample) {
histogram_->Add(sample); histogram_->Add(sample);
} }
void CustomCountHistogram::CountMany(base::HistogramBase::Sample sample, void CustomCountHistogram::CountMany(base::HistogramBase::Sample32 sample,
int count) { int count) {
histogram_->AddCount(sample, count); histogram_->AddCount(sample, count);
} }
void CustomCountHistogram::CountMicroseconds(base::TimeDelta delta) { void CustomCountHistogram::CountMicroseconds(base::TimeDelta delta) {
Count(base::saturated_cast<base::HistogramBase::Sample>( Count(base::saturated_cast<base::HistogramBase::Sample32>(
delta.InMicroseconds())); delta.InMicroseconds()));
} }

@@ -28,11 +28,11 @@ class PLATFORM_EXPORT CustomCountHistogram {
public: public:
// Min values should be >=1 as emitted 0s still go into the underflow bucket. // Min values should be >=1 as emitted 0s still go into the underflow bucket.
CustomCountHistogram(const char* name, CustomCountHistogram(const char* name,
base::HistogramBase::Sample min, base::HistogramBase::Sample32 min,
base::HistogramBase::Sample max, base::HistogramBase::Sample32 max,
int32_t bucket_count); int32_t bucket_count);
void Count(base::HistogramBase::Sample); void Count(base::HistogramBase::Sample32);
void CountMany(base::HistogramBase::Sample, int count); void CountMany(base::HistogramBase::Sample32, int count);
void CountMicroseconds(base::TimeDelta); void CountMicroseconds(base::TimeDelta);
protected: protected:
@@ -79,9 +79,9 @@ class ScopedHighResUsHistogramTimer
static bool ShouldRecord() { return base::TimeTicks::IsHighResolution(); } static bool ShouldRecord() { return base::TimeTicks::IsHighResolution(); }
}; };
static constexpr base::HistogramBase::Sample kTimeBasedHistogramMinSample = 1; static constexpr base::HistogramBase::Sample32 kTimeBasedHistogramMinSample = 1;
static constexpr base::HistogramBase::Sample kTimeBasedHistogramMaxSample = static constexpr base::HistogramBase::Sample32 kTimeBasedHistogramMaxSample =
static_cast<base::Histogram::Sample>(base::Seconds(10).InMicroseconds()); static_cast<base::Histogram::Sample32>(base::Seconds(10).InMicroseconds());
static constexpr int32_t kTimeBasedHistogramBucketCount = 50; static constexpr int32_t kTimeBasedHistogramBucketCount = 50;
#define SCOPED_BLINK_UMA_HISTOGRAM_TIMER_IMPL(name, allow_cross_thread) \ #define SCOPED_BLINK_UMA_HISTOGRAM_TIMER_IMPL(name, allow_cross_thread) \

@@ -13,8 +13,8 @@ namespace blink {
class TestCustomCountHistogram : public CustomCountHistogram { class TestCustomCountHistogram : public CustomCountHistogram {
public: public:
TestCustomCountHistogram(const char* name, TestCustomCountHistogram(const char* name,
base::HistogramBase::Sample min, base::HistogramBase::Sample32 min,
base::HistogramBase::Sample max, base::HistogramBase::Sample32 max,
int32_t bucket_count) int32_t bucket_count)
: CustomCountHistogram(name, min, max, bucket_count) {} : CustomCountHistogram(name, min, max, bucket_count) {}

@@ -3047,7 +3047,7 @@ class InputHandlerProxyMainThreadScrollingReasonTest
touch_end_.touches_length = 1; touch_end_.touches_length = 1;
} }
base::HistogramBase::Sample GetBucketSample(uint32_t reason) { base::HistogramBase::Sample32 GetBucketSample(uint32_t reason) {
uint32_t bucket = 0; uint32_t bucket = 0;
while (reason >>= 1) while (reason >>= 1)
bucket++; bucket++;

@@ -222,7 +222,7 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
.ToString()); .ToString());
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kSuccess), EdidColorSpaceChecksOutcome::kSuccess),
1); 1);
@@ -247,7 +247,7 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
.ToString()); .ToString());
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kSuccess), EdidColorSpaceChecksOutcome::kSuccess),
2); 2);
@@ -272,7 +272,7 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
.ToString()); .ToString());
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kSuccess), EdidColorSpaceChecksOutcome::kSuccess),
3); 3);
@@ -297,7 +297,7 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
.ToString()); .ToString());
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kSuccess), EdidColorSpaceChecksOutcome::kSuccess),
4); 4);
@@ -309,7 +309,7 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
EXPECT_FALSE(no_gamma_color_space.IsValid()); EXPECT_FALSE(no_gamma_color_space.IsValid());
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kErrorBadGamma), EdidColorSpaceChecksOutcome::kErrorBadGamma),
1); 1);
histogram_tester.ExpectTotalCount( histogram_tester.ExpectTotalCount(
@@ -351,7 +351,7 @@ TEST(DisplayUtilTest, GetInvalidColorSpaceFromEdid) {
GetColorSpaceFromEdid(display::EdidParser(std::move(empty_edid)))); GetColorSpaceFromEdid(display::EdidParser(std::move(empty_edid))));
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kErrorPrimariesAreaTooSmall), EdidColorSpaceChecksOutcome::kErrorPrimariesAreaTooSmall),
1); 1);
@@ -362,7 +362,7 @@ TEST(DisplayUtilTest, GetInvalidColorSpaceFromEdid) {
EXPECT_FALSE(invalid_color_space.IsValid()); EXPECT_FALSE(invalid_color_space.IsValid());
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kErrorPrimariesAreaTooSmall), EdidColorSpaceChecksOutcome::kErrorPrimariesAreaTooSmall),
2); 2);
@@ -372,7 +372,7 @@ TEST(DisplayUtilTest, GetInvalidColorSpaceFromEdid) {
EXPECT_FALSE(sst210_color_space.IsValid()) << sst210_color_space.ToString(); EXPECT_FALSE(sst210_color_space.IsValid()) << sst210_color_space.ToString();
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kErrorBadCoordinates), EdidColorSpaceChecksOutcome::kErrorBadCoordinates),
1); 1);
@@ -384,7 +384,7 @@ TEST(DisplayUtilTest, GetInvalidColorSpaceFromEdid) {
<< sst210_color_space_2.ToString(); << sst210_color_space_2.ToString();
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kErrorPrimariesAreaTooSmall), EdidColorSpaceChecksOutcome::kErrorPrimariesAreaTooSmall),
3); 3);
@@ -397,7 +397,7 @@ TEST(DisplayUtilTest, GetInvalidColorSpaceFromEdid) {
<< broken_blue_color_space.ToString(); << broken_blue_color_space.ToString();
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
"DrmUtil.GetColorSpaceFromEdid.ChecksOutcome", "DrmUtil.GetColorSpaceFromEdid.ChecksOutcome",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample32>(
EdidColorSpaceChecksOutcome::kErrorBluePrimaryIsBroken), EdidColorSpaceChecksOutcome::kErrorBluePrimaryIsBroken),
1); 1);
histogram_tester.ExpectTotalCount( histogram_tester.ExpectTotalCount(