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

Unified Diff: webrtc/base/histogram.h

Issue 2654473002: Remove static locals from histograms. (Closed)
Patch Set: use another HistogramBase constructor for enumerations Created 3 years, 11 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
« no previous file with comments | « webrtc/base/BUILD.gn ('k') | webrtc/base/histogram.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/histogram.h
diff --git a/webrtc/base/histogram.h b/webrtc/base/histogram.h
new file mode 100644
index 0000000000000000000000000000000000000000..6eda37704e3f5c507825065cc8a8b00f9c882c7b
--- /dev/null
+++ b/webrtc/base/histogram.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_BASE_HISTOGRAM_H_
+#define WEBRTC_BASE_HISTOGRAM_H_
+
+namespace webrtc {
+namespace metrics {
+class Histogram;
+} // namespace metrics
+} // namespace webrtc
+
+namespace rtc {
+
+class HistogramBase {
+ protected:
+ enum class Type { kCounts, kCountsLinear, kEnumeration };
+
+ HistogramBase(const char* name,
+ Type type,
+ int min,
+ int max,
+ int bucket_count);
+
+ HistogramBase(const char* name, Type type, int boundary);
+
+ void AddSample(int sample) const;
+
+ private:
+ webrtc::metrics::Histogram* histogram_;
+};
+
+class Histogram : private HistogramBase {
+ public:
+ Histogram(const char* name, int max);
+ Histogram(const char* name, int min, int max);
+ Histogram(const char* name, int min, int max, int bucket_count);
+
+ using HistogramBase::AddSample;
+};
+
+class HistogramLinear : private HistogramBase {
+ public:
+ HistogramLinear(const char* name, int max);
+ HistogramLinear(const char* name, int min, int max);
+ HistogramLinear(const char* name, int min, int max, int bucket_count);
+
+ using HistogramBase::AddSample;
+};
+
+class HistogramEnumeration : private HistogramBase {
+ public:
+ HistogramEnumeration(const char* name, int boundary);
+ void AddSample(int sample);
+
+ private:
+ int boundary_;
+};
+
+class HistogramBoolean : private HistogramEnumeration {
+ public:
+ explicit HistogramBoolean(const char* name);
+
+ void AddSample(bool sample);
+};
+
+class HistogramPercentage : private HistogramEnumeration {
+ public:
+ explicit HistogramPercentage(const char* name);
+
+ using HistogramEnumeration::AddSample;
+};
+
+} // namespace rtc
+
+#endif // WEBRTC_BASE_HISTOGRAM_H_
« no previous file with comments | « webrtc/base/BUILD.gn ('k') | webrtc/base/histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698