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

Unified Diff: ui/events/event.cc

Issue 2756893002: Add Keyboard Latency UMA Metrics. (Closed)
Patch Set: Fix test issue Created 3 years, 9 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
Index: ui/events/event.cc
diff --git a/ui/events/event.cc b/ui/events/event.cc
index 64f06d0cae3d0fbef8a52b7a4c723663beca8582..7483c6c10091c7cbbb5c9c0d855aa5742884d048 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;
+
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
mfomitchev 2017/04/04 14:59:06 Nit: Perhaps this comment should be in the SourceE
tdresser 2017/05/01 15:49:21 Added a comment in SourceEventType enum.
+ // 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:
@@ -1140,6 +1145,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);

Powered by Google App Engine
This is Rietveld 408576698