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

Unified Diff: base/metrics/histogram_functions.h

Issue 2801613002: Allow UmaHistogramEnumeration to be used with enum classes. (Closed)
Patch Set: dcheng magic Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_functions.h
diff --git a/base/metrics/histogram_functions.h b/base/metrics/histogram_functions.h
index 58fc30173c6ea17480175440202c384b96661261..5960aca657497357e7146aff8b0e5997b9d356f6 100644
--- a/base/metrics/histogram_functions.h
+++ b/base/metrics/histogram_functions.h
@@ -43,7 +43,10 @@ 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_LE(static_cast<uintmax_t>(max), static_cast<uintmax_t>(INT_MAX));
+ DCHECK_LE(static_cast<uintmax_t>(sample), static_cast<uintmax_t>(max));
+ return UmaHistogramExactLinear(name, static_cast<int>(sample),
+ static_cast<int>(max));
}
// For adding boolean sample to histogram.
« 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