1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_QUIC_PLATFORM_IMPL_QUIC_CLIENT_STATS_IMPL_H_
6 #define NET_QUIC_PLATFORM_IMPL_QUIC_CLIENT_STATS_IMPL_H_
7 
8 #include "base/metrics/histogram_functions.h"
9 #include "base/metrics/histogram_macros.h"
10 
11 namespace quic {
12 
13 // By convention, all QUIC histograms are prefixed by "Net.".
14 #define QUIC_HISTOGRAM_NAME(raw_name) "Net." raw_name
15 
16 #define QUIC_CLIENT_HISTOGRAM_ENUM_IMPL(name, sample, enum_size, docstring) \
17   UMA_HISTOGRAM_ENUMERATION(QUIC_HISTOGRAM_NAME(name), sample, enum_size)
18 
19 #define QUIC_CLIENT_HISTOGRAM_BOOL_IMPL(name, sample, docstring) \
20   UMA_HISTOGRAM_BOOLEAN(QUIC_HISTOGRAM_NAME(name), sample)
21 
22 #define QUIC_CLIENT_HISTOGRAM_TIMES_IMPL(name, sample, min, max, bucket_count, \
23                                          docstring)                            \
24   UMA_HISTOGRAM_CUSTOM_TIMES(                                                  \
25       QUIC_HISTOGRAM_NAME(name),                                               \
26       base::TimeDelta::FromMicroseconds(sample.ToMicroseconds()),              \
27       base::TimeDelta::FromMicroseconds(min.ToMicroseconds()),                 \
28       base::TimeDelta::FromMicroseconds(max.ToMicroseconds()), bucket_count)
29 
30 #define QUIC_CLIENT_HISTOGRAM_COUNTS_IMPL(name, sample, min, max,          \
31                                           bucket_count, docstring)         \
32   UMA_HISTOGRAM_CUSTOM_COUNTS(QUIC_HISTOGRAM_NAME(name), sample, min, max, \
33                               bucket_count)
34 
QuicClientSparseHistogramImpl(const std::string & name,int sample)35 inline void QuicClientSparseHistogramImpl(const std::string& name, int sample) {
36   base::UmaHistogramSparse(name, sample);
37 }
38 
39 }  // namespace quic
40 
41 #endif  // NET_QUIC_PLATFORM_IMPL_QUIC_CLIENT_STATS_IMPL_H_
42