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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

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: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 2b0a11d2a17b90d248e7fd40e21649042cd28697..087724baec0023e5bd6ce92e7b1a9dee92f7081f 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -2098,6 +2098,8 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
DCHECK(widgetHost);
NativeWebKeyboardEvent event(theEvent);
+ ui::LatencyInfo latency_info(ui::SourceEventType::KEY);
+ latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
// Force fullscreen windows to close on Escape so they won't keep the keyboard
// grabbed or be stuck onscreen if the renderer is hanging.
@@ -2137,7 +2139,7 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
// We only handle key down events and just simply forward other events.
if ([theEvent type] != NSKeyDown) {
- widgetHost->ForwardKeyboardEvent(event);
+ widgetHost->ForwardKeyboardEventWithLatencyInfo(event, latency_info);
// Possibly autohide the cursor.
if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
@@ -2192,7 +2194,7 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
NativeWebKeyboardEvent fakeEvent = event;
fakeEvent.windowsKeyCode = 0xE5; // VKEY_PROCESSKEY
fakeEvent.skip_in_browser = true;
- widgetHost->ForwardKeyboardEvent(fakeEvent);
+ widgetHost->ForwardKeyboardEventWithLatencyInfo(fakeEvent, latency_info);
// If this key event was handled by the input method, but
// -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above)
// enqueued edit commands, then in order to let webkit handle them
@@ -2203,12 +2205,14 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
if (hasEditCommands_ && !hasMarkedText_)
delayEventUntilAfterImeCompostion = YES;
} else {
- widgetHost->ForwardKeyboardEventWithCommands(event, &editCommands_);
+ widgetHost->ForwardKeyboardEventWithCommands(event, latency_info,
+ &editCommands_);
}
- // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
- // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
- // be set to NULL. So we check it here and return immediately if it's NULL.
+ // Calling ForwardKeyboardEventWithCommands() could have destroyed the
+ // widget. When the widget was destroyed,
+ // |renderWidgetHostView_->render_widget_host_| will be set to NULL. So we
+ // check it here and return immediately if it's NULL.
if (!renderWidgetHostView_->render_widget_host_)
return;
@@ -2267,16 +2271,18 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
NativeWebKeyboardEvent fakeEvent = event;
fakeEvent.setType(blink::WebInputEvent::KeyUp);
fakeEvent.skip_in_browser = true;
- widgetHost->ForwardKeyboardEvent(fakeEvent);
+ widgetHost->ForwardKeyboardEventWithLatencyInfo(fakeEvent, latency_info);
// Not checking |renderWidgetHostView_->render_widget_host_| here because
// a key event with |skip_in_browser| == true won't be handled by browser,
// thus it won't destroy the widget.
- widgetHost->ForwardKeyboardEventWithCommands(event, &editCommands_);
+ widgetHost->ForwardKeyboardEventWithCommands(event, latency_info,
+ &editCommands_);
- // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
- // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
- // be set to NULL. So we check it here and return immediately if it's NULL.
+ // Calling ForwardKeyboardEventWithCommands() could have destroyed the
+ // widget. When the widget was destroyed,
+ // |renderWidgetHostView_->render_widget_host_| will be set to NULL. So we
+ // check it here and return immediately if it's NULL.
if (!renderWidgetHostView_->render_widget_host_)
return;
}
@@ -2291,7 +2297,7 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
event.text[0] = textToBeInserted_[0];
event.text[1] = 0;
event.skip_in_browser = true;
- widgetHost->ForwardKeyboardEvent(event);
+ widgetHost->ForwardKeyboardEventWithLatencyInfo(event, latency_info);
} else if ((!textInserted || delayEventUntilAfterImeCompostion) &&
event.text[0] != '\0' &&
(([theEvent modifierFlags] & kCtrlCmdKeyMask) ||
@@ -2301,7 +2307,7 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
// cases, unless the key event generated any other command.
event.setType(blink::WebInputEvent::Char);
event.skip_in_browser = true;
- widgetHost->ForwardKeyboardEvent(event);
+ widgetHost->ForwardKeyboardEventWithLatencyInfo(event, latency_info);
}
}

Powered by Google App Engine
This is Rietveld 408576698