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

Unified Diff: ui/events/event.cc

Issue 2756893002: Add Keyboard Latency UMA Metrics. (Closed)
Patch Set: Restrict to RawKeyDown and Char events on Android & Mac Created 3 years, 7 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 | « tools/metrics/histograms/histograms.xml ('k') | ui/latency/latency_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index ce99ff82d68ee08dd10cdfe51f89c3bedfcfc56a..249781fa2422152d9aa14aaf8414ab1c91efe78d 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -149,13 +149,18 @@ SourceEventType EventTypeToLatencySourceEventType(EventType type) {
case ET_SCROLL_FLING_CANCEL:
return SourceEventType::UNKNOWN;
+ case ui::ET_KEY_PRESSED:
+ return ui::SourceEventType::KEY_PRESS;
+
case ET_MOUSE_PRESSED:
case ET_MOUSE_DRAGGED:
case ET_MOUSE_RELEASED:
case ET_MOUSE_MOVED:
case ET_MOUSE_ENTERED:
case ET_MOUSE_EXITED:
- case ET_KEY_PRESSED:
+ // We measure latency for key presses, not key releases. Most behavior is
+ // keyed off of presses, and release latency is higher than press latency as
+ // it's impacted by event handling of the press event.
case ET_KEY_RELEASED:
case ET_MOUSE_CAPTURE_CHANGED:
case ET_DROP_TARGET_EVENT:
@@ -1141,6 +1146,11 @@ KeyEvent::KeyEvent(const base::NativeEvent& native_event, int event_flags)
key_code_(KeyboardCodeFromNative(native_event)),
code_(CodeFromNative(native_event)),
is_char_(IsCharFromNative(native_event)) {
+ latency()->AddLatencyNumberWithTimestamp(
+ INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
+ base::TimeTicks::FromInternalValue(time_stamp().ToInternalValue()), 1);
+ latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
+
if (IsRepeated(*this))
set_flags(flags() | ui::EF_IS_REPEAT);
« no previous file with comments | « tools/metrics/histograms/histograms.xml ('k') | ui/latency/latency_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698