Index: ui/events/event.cc |
diff --git a/ui/events/event.cc b/ui/events/event.cc |
index ca6704b6f8fa5b6e49888074b799c620b7bc90e2..b29c68daa83397fa9ffd6a4349c192f9d1f44c46 100644 |
--- a/ui/events/event.cc |
+++ b/ui/events/event.cc |
@@ -312,16 +312,17 @@ Event::Event(const base::NativeEvent& native_event, |
static_cast<base::HistogramBase::Sample>(delta.InMicroseconds()); |
UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser", delta_sample, 1, 1000000, |
100); |
- std::string name_for_event = |
- base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()); |
- base::HistogramBase* counter_for_type = |
+ |
+ // Though it seems inefficient to generate the string twice, the first |
+ // instance will be used only for DCHECK builds and the second won't be |
+ // executed at all if the histogram was previously accessed here. |
+ STATIC_HISTOGRAM_POINTER_GROUP( |
+ base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()), |
+ type_, ET_LAST, Add(delta_sample), |
base::Histogram::FactoryGet( |
- name_for_event, |
- 1, |
- 1000000, |
- 100, |
- base::HistogramBase::kUmaTargetedHistogramFlag); |
- counter_for_type->Add(delta_sample); |
+ base::StringPrintf("Event.Latency.Browser.%s", name_.c_str()), |
+ 1, 1000000, 100, |
+ base::HistogramBase::kUmaTargetedHistogramFlag)); |
#if defined(USE_X11) |
if (native_event->type == GenericEvent) { |