Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: components/metrics/single_value_counts_histogram.cc

Issue 2687583002: Add support for single sample metrics. (Closed)
Patch Set: Redesign! Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698