OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ |
6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ | 6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ |
7 | 7 |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/histogram_macros_internal.h" | 9 #include "base/metrics/histogram_macros_internal.h" |
10 #include "base/metrics/histogram_macros_local.h" | 10 #include "base/metrics/histogram_macros_local.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 // You should be defining an associated Enum, and the input sample should be | 34 // You should be defining an associated Enum, and the input sample should be |
35 // an element of the Enum. | 35 // an element of the Enum. |
36 // All of these macros must be called with |name| as a runtime constant. | 36 // All of these macros must be called with |name| as a runtime constant. |
37 | 37 |
38 // Sample usage: | 38 // Sample usage: |
39 // UMA_HISTOGRAM_ENUMERATION("My.Enumeration", VALUE, EVENT_MAX_VALUE); | 39 // UMA_HISTOGRAM_ENUMERATION("My.Enumeration", VALUE, EVENT_MAX_VALUE); |
40 // New Enum values can be added, but existing enums must never be renumbered or | 40 // New Enum values can be added, but existing enums must never be renumbered or |
41 // delete and reused. The value in |sample| must be strictly less than | 41 // delete and reused. The value in |sample| must be strictly less than |
42 // |enum_max|. | 42 // |enum_max|. |
43 | 43 |
44 #define UMA_HISTOGRAM_ENUMERATION(name, sample, enum_max) \ | 44 #define UMA_HISTOGRAM_ENUMERATION(name, sample, enum_max) \ |
45 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ | 45 static_assert( \ |
Alexei Svitkine (slow)
2016/11/02 15:48:47
Thanks for working on this!
Just a nit, can you m
wychen
2016/11/02 21:45:04
Done.
| |
46 name, sample, enum_max, \ | 46 !std::is_enum<decltype(sample)>::value || \ |
47 base::HistogramBase::kUmaTargetedHistogramFlag) | 47 !std::is_enum<decltype(enum_max)>::value || \ |
48 std::is_same<std::remove_const<decltype(sample)>::type, \ | |
49 std::remove_const<decltype(enum_max)>::type>::value, \ | |
50 "UMA_HISTOGRAM_ENUMERATION type incompatible"); \ | |
51 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ | |
52 name, sample, enum_max, base::HistogramBase::kUmaTargetedHistogramFlag) | |
48 | 53 |
49 // Histogram for boolean values. | 54 // Histogram for boolean values. |
50 | 55 |
51 // Sample usage: | 56 // Sample usage: |
52 // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool); | 57 // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool); |
53 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ | 58 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ |
54 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 59 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
55 base::BooleanHistogram::FactoryGet(name, \ | 60 base::BooleanHistogram::FactoryGet(name, \ |
56 base::HistogramBase::kUmaTargetedHistogramFlag)) | 61 base::HistogramBase::kUmaTargetedHistogramFlag)) |
57 | 62 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the | 277 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the |
273 // requirement of |custom_ranges|. You can use the helper function | 278 // requirement of |custom_ranges|. You can use the helper function |
274 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid | 279 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid |
275 // sample values to a std::vector<int>. | 280 // sample values to a std::vector<int>. |
276 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 281 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
277 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 282 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
278 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 283 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
279 base::HistogramBase::kUmaTargetedHistogramFlag)) | 284 base::HistogramBase::kUmaTargetedHistogramFlag)) |
280 | 285 |
281 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 286 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |