Index: base/metrics/histogram_functions.h |
diff --git a/base/metrics/histogram_functions.h b/base/metrics/histogram_functions.h |
index 58fc30173c6ea17480175440202c384b96661261..41c6aa164d591e4aaa3decf970042bf0186c2a76 100644 |
--- a/base/metrics/histogram_functions.h |
+++ b/base/metrics/histogram_functions.h |
@@ -43,7 +43,12 @@ template <typename T> |
void UmaHistogramEnumeration(const std::string& name, T sample, T max) { |
static_assert(std::is_enum<T>::value, |
"Non enum passed to UmaHistogramEnumeration"); |
- return UmaHistogramExactLinear(name, static_cast<int>(sample), max); |
+ DCHECK_GE(static_cast<int64_t>(max), 0); |
+ DCHECK_LE(static_cast<int64_t>(max), INT_MAX); |
+ DCHECK_GE(static_cast<int64_t>(sample), 0); |
+ DCHECK_LE(sample, max); |
benwells
2017/04/06 07:30:01
How is this? Some questions:
- do you have a bette
benwells
2017/04/06 07:40:24
A smart person here suggested this:
DCHECK_EQ(max,
dcheng
2017/04/06 07:47:05
Yeah, static assert won't work here.
benwells
2017/04/06 08:16:48
OK ... yeah, subtle :) Thanks!
|
+ return UmaHistogramExactLinear(name, static_cast<int>(sample), |
+ static_cast<int>(max)); |
} |
// For adding boolean sample to histogram. |