Chromium Code Reviews| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 // Samples should be one of the std::vector<int> list provided via | 272 // Samples should be one of the std::vector<int> list provided via |
| 273 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the | 273 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the |
| 274 // requirement of |custom_ranges|. You can use the helper function | 274 // requirement of |custom_ranges|. You can use the helper function |
| 275 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid | 275 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid |
| 276 // sample values to a std::vector<int>. | 276 // sample values to a std::vector<int>. |
| 277 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 277 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
| 278 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 278 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 279 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 279 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
| 280 base::HistogramBase::kUmaTargetedHistogramFlag)) | 280 base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 281 | 281 |
| 282 // Support a collection of histograms, perhaps one for each entry in an | |
| 283 // enumeration. This macro manages a block of pointers, adding to a specific | |
| 284 // one by its index. | |
|
Ilya Sherman
2017/01/09 22:51:45
nit: You've currently added this under the "Deprec
tdresser
2017/01/11 18:14:49
Whoops. Fixed.
| |
| 285 // | |
| 286 // A typical instantiation looks something like this: | |
| 287 // STATIC_HISTOGRAM_POINTER_GROUP( | |
| 288 // GetHistogramNameForIndex(histogram_index), | |
| 289 // histogram_index, MAXIMUM_HISTOGRAM_INDEX, Add(some_delta), | |
| 290 // base::Histogram::FactoryGet( | |
| 291 // GetHistogramNameForType(histogram_index), | |
|
Ilya Sherman
2017/01/09 22:51:45
nit: s/Type/Index
tdresser
2017/01/11 18:14:49
Done.
| |
| 292 // MINIMUM_SAMPLE, MAXIMUM_SAMPLE, BUCKET_COUNT, | |
| 293 // base::HistogramBase::kUmaTargetedHistogramFlag)); | |
| 294 // | |
| 295 // Though it seems inefficient to generate the name twice, the first | |
| 296 // instance will be used only for DCHECK builds and the second will | |
| 297 // execute only during the first access to the given index, after which | |
| 298 // the pointer is cached and the name never needed again. | |
| 299 #define STATIC_HISTOGRAM_POINTER_GROUP(constant_histogram_name, index, \ | |
| 300 constant_maximum, \ | |
| 301 histogram_add_method_invocation, \ | |
| 302 histogram_factory_get_invocation) \ | |
| 303 do { \ | |
| 304 static base::subtle::AtomicWord atomic_histograms[constant_maximum]; \ | |
| 305 DCHECK_LE(0, index); \ | |
| 306 DCHECK_LT(index, constant_maximum); \ | |
| 307 HISTOGRAM_POINTER_USE(&atomic_histograms[index], constant_histogram_name, \ | |
| 308 histogram_add_method_invocation, \ | |
| 309 histogram_factory_get_invocation); \ | |
| 310 } while (0) | |
| 311 | |
| 282 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 312 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
| OLD | NEW |