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

Side by Side Diff: base/metrics/histogram_macros_internal.h

Issue 2661023008: [Cleanup] Clarify a histogram macro comment. (Closed)
Patch Set: Rebase Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_
6 #define BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ 6 #define BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } while (0) 89 } while (0)
90 90
91 // This is a helper macro used by other macros and shouldn't be used directly. 91 // This is a helper macro used by other macros and shouldn't be used directly.
92 #define INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG(name, sample, min, max, \ 92 #define INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG(name, sample, min, max, \
93 bucket_count, flag) \ 93 bucket_count, flag) \
94 STATIC_HISTOGRAM_POINTER_BLOCK( \ 94 STATIC_HISTOGRAM_POINTER_BLOCK( \
95 name, Add(sample), \ 95 name, Add(sample), \
96 base::Histogram::FactoryGet(name, min, max, bucket_count, flag)) 96 base::Histogram::FactoryGet(name, min, max, bucket_count, flag))
97 97
98 // This is a helper macro used by other macros and shouldn't be used directly. 98 // This is a helper macro used by other macros and shouldn't be used directly.
99 // One additional bucket is created in the LinearHistogram for the illegal 99 // For an enumeration with N items, recording values in the range [0, N - 1],
100 // values >= boundary_value so that mistakes in calling the UMA enumeration 100 // this macro creates a linear histogram with N + 1 buckets:
101 // macros can be detected. 101 // [0, 1), [1, 2), ..., [N - 1, N), and an overflow bucket [N, infinity).
102 // Code should never emit to the overflow bucket; only to the other N buckets.
103 // This allows future versions of Chrome to safely append new entries to the
104 // enumeration. Otherwise, the histogram would have [N - 1, infinity) as its
105 // overflow bucket, and so the maximal value (N - 1) would be emitted to this
106 // overflow bucket. But, if an additional enumerated value were later added, the
107 // bucket label for the value (N - 1) would change to [N - 1, N), which would
108 // result in different versions of Chrome using different bucket labels for
109 // identical data.
102 #define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ 110 #define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \
103 do { \ 111 do { \
104 static_assert( \ 112 static_assert( \
105 !std::is_enum<decltype(sample)>::value || \ 113 !std::is_enum<decltype(sample)>::value || \
106 !std::is_enum<decltype(boundary)>::value || \ 114 !std::is_enum<decltype(boundary)>::value || \
107 std::is_same<std::remove_const<decltype(sample)>::type, \ 115 std::is_same<std::remove_const<decltype(sample)>::type, \
108 std::remove_const<decltype(boundary)>::type>::value, \ 116 std::remove_const<decltype(boundary)>::type>::value, \
109 "|sample| and |boundary| shouldn't be of different enums"); \ 117 "|sample| and |boundary| shouldn't be of different enums"); \
110 STATIC_HISTOGRAM_POINTER_BLOCK( \ 118 STATIC_HISTOGRAM_POINTER_BLOCK( \
111 name, Add(sample), base::LinearHistogram::FactoryGet( \ 119 name, Add(sample), base::LinearHistogram::FactoryGet( \
(...skipping 28 matching lines...) Expand all
140 // may be more efficient in memory if the total number of sample values is small 148 // may be more efficient in memory if the total number of sample values is small
141 // compared to the range of their values. 149 // compared to the range of their values.
142 #define INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ 150 #define INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) \
143 do { \ 151 do { \
144 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ 152 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \
145 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ 153 name, base::HistogramBase::kUmaTargetedHistogramFlag); \
146 histogram->Add(sample); \ 154 histogram->Add(sample); \
147 } while (0) 155 } while (0)
148 156
149 #endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ 157 #endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698