blob: 592f957b450fb470bfbdec328f8c363b9ca5d7dc [file] [log] [blame]
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
#include "base/numerics/safe_conversions.h"
namespace blink {
CustomCountHistogram::CustomCountHistogram(const char* name,
base::HistogramBase::Sample32 min,
base::HistogramBase::Sample32 max,
int32_t bucket_count) {
histogram_ = base::Histogram::FactoryGet(
name, min, max, bucket_count,
base::HistogramBase::kUmaTargetedHistogramFlag);
}
CustomCountHistogram::CustomCountHistogram(base::HistogramBase* histogram)
: histogram_(histogram) {}
void CustomCountHistogram::Count(base::HistogramBase::Sample32 sample) {
histogram_->Add(sample);
}
void CustomCountHistogram::CountMany(base::HistogramBase::Sample32 sample,
int count) {
histogram_->AddCount(sample, count);
}
void CustomCountHistogram::CountMicroseconds(base::TimeDelta delta) {
Count(base::saturated_cast<base::HistogramBase::Sample32>(
delta.InMicroseconds()));
}
} // namespace blink