OLD | NEW |
---|---|
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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 // | 133 // |
134 // Note the range checks verify two separate issues: | 134 // Note the range checks verify two separate issues: |
135 // - that the declared enum max isn't out of range of HistogramBase::Sample | 135 // - that the declared enum max isn't out of range of HistogramBase::Sample |
136 // - that the declared enum max is > 0 | 136 // - that the declared enum max is > 0 |
137 // | 137 // |
138 // TODO(dcheng): This should assert that the passed in types are actually enum | 138 // TODO(dcheng): This should assert that the passed in types are actually enum |
139 // types. | 139 // types. |
140 #define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ | 140 #define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ |
141 do { \ | 141 do { \ |
142 static_assert( \ | 142 static_assert( \ |
143 !std::is_enum<std::remove_const<std::remove_reference<decltype( \ | |
dcheng
2017/07/17 09:13:59
I think std::decay can replace the use of std::rem
| |
144 boundary)>::type>::type>::value || \ | |
145 std::is_enum<std::remove_const< \ | |
146 std::remove_reference<decltype(sample)>::type>::type>::value, \ | |
147 "Unexpected: |boundary| is enum, but |sample| is not."); \ | |
148 static_assert( \ | |
143 !std::is_enum<decltype(sample)>::value || \ | 149 !std::is_enum<decltype(sample)>::value || \ |
144 !std::is_enum<decltype(boundary)>::value || \ | 150 !std::is_enum<decltype(boundary)>::value || \ |
145 std::is_same<std::remove_const<decltype(sample)>::type, \ | 151 std::is_same<std::remove_const<decltype(sample)>::type, \ |
146 std::remove_const<decltype(boundary)>::type>::value, \ | 152 std::remove_const<decltype(boundary)>::type>::value, \ |
147 "|sample| and |boundary| shouldn't be of different enums"); \ | 153 "|sample| and |boundary| shouldn't be of different enums"); \ |
148 static_assert( \ | 154 static_assert( \ |
149 static_cast<uintmax_t>(boundary) < \ | 155 static_cast<uintmax_t>(boundary) < \ |
150 static_cast<uintmax_t>( \ | 156 static_cast<uintmax_t>( \ |
151 std::numeric_limits<base::HistogramBase::Sample>::max()), \ | 157 std::numeric_limits<base::HistogramBase::Sample>::max()), \ |
152 "|boundary| is out of range of HistogramBase::Sample"); \ | 158 "|boundary| is out of range of HistogramBase::Sample"); \ |
(...skipping 30 matching lines...) Expand all Loading... | |
183 // may be more efficient in memory if the total number of sample values is small | 189 // may be more efficient in memory if the total number of sample values is small |
184 // compared to the range of their values. | 190 // compared to the range of their values. |
185 #define INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ | 191 #define INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
186 do { \ | 192 do { \ |
187 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ | 193 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ |
188 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ | 194 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ |
189 histogram->Add(sample); \ | 195 histogram->Add(sample); \ |
190 } while (0) | 196 } while (0) |
191 | 197 |
192 #endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ | 198 #endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ |
OLD | NEW |