Index: components/metrics/single_value_counts_histogram.cc |
diff --git a/components/metrics/single_value_counts_histogram.cc b/components/metrics/single_value_counts_histogram.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..466c8c179d19f65f30ae4953031c957de9a6dbb8 |
--- /dev/null |
+++ b/components/metrics/single_value_counts_histogram.cc |
@@ -0,0 +1,37 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/metrics/single_value_counts_histogram.h" |
+ |
+#include "base/metrics/histogram.h" |
+ |
+namespace metrics { |
+ |
+SingleValueCountsHistogram::SingleValueCountsHistogram( |
+ const std::string& name, |
+ base::HistogramBase::Sample min, |
+ base::HistogramBase::Sample max, |
+ uint32_t bucket_count) |
+ : histogram_(base::Histogram::FactoryGet( |
+ name, |
+ min, |
+ max, |
+ bucket_count, |
+ base::HistogramBase::kUmaTargetedHistogramFlag)) { |
+ DCHECK(histogram_); |
+ LOG(ERROR) << __func__; |
+} |
+ |
+SingleValueCountsHistogram::~SingleValueCountsHistogram() { |
+ LOG(ERROR) << __func__; |
+ if (sample_ < 0) |
+ return; |
+ histogram_->Add(sample_); |
+} |
+ |
+void SingleValueCountsHistogram::SetSample(base::HistogramBase::Sample sample) { |
+ sample_ = sample; |
+} |
+ |
+} // namespace metrics |