Add linearly spaced counting histograms

This change adds HistogramFactoryGetCountsLinear and
RTC_HISTOGRAM_COUNTS_LINEAR. Note that the default implementation of
HistogramFactoryGetCounts in metrics_default.cc also provides a
linearly spaced histogram, while the Chrome UMA implementation
provides exponentially spaced buckets.

BUG=none

Review-Url: https://codereview.webrtc.org/2548463002
Cr-Commit-Position: refs/heads/master@{#15367}
diff --git a/webrtc/system_wrappers/include/metrics.h b/webrtc/system_wrappers/include/metrics.h
index 9b14736..25a5180 100644
--- a/webrtc/system_wrappers/include/metrics.h
+++ b/webrtc/system_wrappers/include/metrics.h
@@ -85,6 +85,11 @@
   RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
       webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count))
 
+#define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count)      \
+  RTC_HISTOGRAM_COMMON_BLOCK(name, sample,                                     \
+                             webrtc::metrics::HistogramFactoryGetCountsLinear( \
+                                 name, min, max, bucket_count))
+
 // Deprecated.
 // TODO(asapersson): Remove.
 #define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \
@@ -213,6 +218,12 @@
 Histogram* HistogramFactoryGetCounts(
     const std::string& name, int min, int max, int bucket_count);
 
+// Get histogram for counters with linear bucket spacing.
+Histogram* HistogramFactoryGetCountsLinear(const std::string& name,
+                                           int min,
+                                           int max,
+                                           int bucket_count);
+
 // Get histogram for enumerators.
 // |boundary| should be above the max enumerator sample.
 Histogram* HistogramFactoryGetEnumeration(
diff --git a/webrtc/system_wrappers/source/metrics_default.cc b/webrtc/system_wrappers/source/metrics_default.cc
index d7d24fa..6ca90da 100644
--- a/webrtc/system_wrappers/source/metrics_default.cc
+++ b/webrtc/system_wrappers/source/metrics_default.cc
@@ -213,6 +213,19 @@
                                      int min,
                                      int max,
                                      int bucket_count) {
+  // TODO(asapersson): Alternative implementation will be needed if this
+  // histogram type should be truly exponential.
+  return HistogramFactoryGetCountsLinear(name, min, max, bucket_count);
+}
+
+// Histogram with linearly spaced buckets.
+// Creates (or finds) histogram.
+// The returned histogram pointer is cached (and used for adding samples in
+// subsequent calls).
+Histogram* HistogramFactoryGetCountsLinear(const std::string& name,
+                                           int min,
+                                           int max,
+                                           int bucket_count) {
   RtcHistogramMap* map = GetMap();
   if (!map)
     return nullptr;