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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2756893002: Add Keyboard Latency UMA Metrics. (Closed)
Patch Set: mfomitchev responses, rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 return; 1035 return;
1036 } 1036 }
1037 1037
1038 ForwardMouseEventWithLatencyInfo(mouse_event, 1038 ForwardMouseEventWithLatencyInfo(mouse_event,
1039 ui::LatencyInfo(ui::SourceEventType::OTHER)); 1039 ui::LatencyInfo(ui::SourceEventType::OTHER));
1040 if (owner_delegate_) 1040 if (owner_delegate_)
1041 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); 1041 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event);
1042 } 1042 }
1043 1043
1044 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( 1044 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo(
1045 const blink::WebMouseEvent& mouse_event, 1045 const blink::WebMouseEvent& mouse_event,
1046 const ui::LatencyInfo& ui_latency) { 1046 const ui::LatencyInfo& latency) {
1047 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", "x", 1047 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", "x",
1048 mouse_event.PositionInWidget().x, "y", 1048 mouse_event.PositionInWidget().x, "y",
1049 mouse_event.PositionInWidget().y); 1049 mouse_event.PositionInWidget().y);
1050 1050
1051 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { 1051 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) {
1052 if (mouse_event_callbacks_[i].Run(mouse_event)) 1052 if (mouse_event_callbacks_[i].Run(mouse_event))
1053 return; 1053 return;
1054 } 1054 }
1055 1055
1056 if (ShouldDropInputEvents()) 1056 if (ShouldDropInputEvents())
1057 return; 1057 return;
1058 1058
1059 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) 1059 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event))
1060 return; 1060 return;
1061 1061
1062 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); 1062 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, latency);
1063 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency); 1063 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency);
1064 input_router_->SendMouseEvent(mouse_with_latency); 1064 input_router_->SendMouseEvent(mouse_with_latency);
1065 } 1065 }
1066 1066
1067 void RenderWidgetHostImpl::ForwardWheelEvent( 1067 void RenderWidgetHostImpl::ForwardWheelEvent(
1068 const WebMouseWheelEvent& wheel_event) { 1068 const WebMouseWheelEvent& wheel_event) {
1069 ForwardWheelEventWithLatencyInfo(wheel_event, 1069 ForwardWheelEventWithLatencyInfo(wheel_event,
1070 ui::LatencyInfo(ui::SourceEventType::WHEEL)); 1070 ui::LatencyInfo(ui::SourceEventType::WHEEL));
1071 } 1071 }
1072 1072
1073 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( 1073 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
1074 const blink::WebMouseWheelEvent& wheel_event, 1074 const blink::WebMouseWheelEvent& wheel_event,
1075 const ui::LatencyInfo& ui_latency) { 1075 const ui::LatencyInfo& latency) {
1076 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", "dx", 1076 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", "dx",
1077 wheel_event.delta_x, "dy", wheel_event.delta_y); 1077 wheel_event.delta_x, "dy", wheel_event.delta_y);
1078 1078
1079 if (ShouldDropInputEvents()) 1079 if (ShouldDropInputEvents())
1080 return; 1080 return;
1081 1081
1082 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) 1082 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event))
1083 return; 1083 return;
1084 1084
1085 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); 1085 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, latency);
1086 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency); 1086 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency);
1087 input_router_->SendWheelEvent(wheel_with_latency); 1087 input_router_->SendWheelEvent(wheel_with_latency);
1088 } 1088 }
1089 1089
1090 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( 1090 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent(
1091 const blink::WebGestureEvent& gesture_event) { 1091 const blink::WebGestureEvent& gesture_event) {
1092 ForwardGestureEvent(gesture_event); 1092 ForwardGestureEvent(gesture_event);
1093 } 1093 }
1094 1094
1095 void RenderWidgetHostImpl::ForwardGestureEvent( 1095 void RenderWidgetHostImpl::ForwardGestureEvent(
1096 const blink::WebGestureEvent& gesture_event) { 1096 const blink::WebGestureEvent& gesture_event) {
1097 ForwardGestureEventWithLatencyInfo( 1097 ForwardGestureEventWithLatencyInfo(
1098 gesture_event, 1098 gesture_event,
1099 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( 1099 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(
1100 gesture_event)); 1100 gesture_event));
1101 } 1101 }
1102 1102
1103 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( 1103 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo(
1104 const blink::WebGestureEvent& gesture_event, 1104 const blink::WebGestureEvent& gesture_event,
1105 const ui::LatencyInfo& ui_latency) { 1105 const ui::LatencyInfo& latency) {
1106 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); 1106 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent");
1107 // Early out if necessary, prior to performing latency logic. 1107 // Early out if necessary, prior to performing latency logic.
1108 if (ShouldDropInputEvents()) 1108 if (ShouldDropInputEvents())
1109 return; 1109 return;
1110 1110
1111 // TODO(wjmaclean) Remove the code for supporting resending gesture events 1111 // TODO(wjmaclean) Remove the code for supporting resending gesture events
1112 // when WebView transitions to OOPIF and BrowserPlugin is removed. 1112 // when WebView transitions to OOPIF and BrowserPlugin is removed.
1113 // http://crbug.com/533069 1113 // http://crbug.com/533069
1114 bool* is_in_gesture_scroll = 1114 bool* is_in_gesture_scroll =
1115 gesture_event.source_device == 1115 gesture_event.source_device ==
(...skipping 30 matching lines...) Expand all
1146 ForwardGestureEventWithLatencyInfo( 1146 ForwardGestureEventWithLatencyInfo(
1147 CreateScrollBeginForWrapping(gesture_event), 1147 CreateScrollBeginForWrapping(gesture_event),
1148 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( 1148 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(
1149 gesture_event)); 1149 gesture_event));
1150 } 1150 }
1151 1151
1152 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. 1152 // Delegate must be non-null, due to |ShouldDropInputEvents()| test.
1153 if (delegate_->PreHandleGestureEvent(gesture_event)) 1153 if (delegate_->PreHandleGestureEvent(gesture_event))
1154 return; 1154 return;
1155 1155
1156 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); 1156 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency);
1157 DispatchInputEventWithLatencyInfo(gesture_event, 1157 DispatchInputEventWithLatencyInfo(gesture_event,
1158 &gesture_with_latency.latency); 1158 &gesture_with_latency.latency);
1159 input_router_->SendGestureEvent(gesture_with_latency); 1159 input_router_->SendGestureEvent(gesture_with_latency);
1160 1160
1161 if (scroll_update_needs_wrapping) { 1161 if (scroll_update_needs_wrapping) {
1162 ForwardGestureEventWithLatencyInfo( 1162 ForwardGestureEventWithLatencyInfo(
1163 CreateScrollEndForWrapping(gesture_event), 1163 CreateScrollEndForWrapping(gesture_event),
1164 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( 1164 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(
1165 gesture_event)); 1165 gesture_event));
1166 } 1166 }
1167 } 1167 }
1168 1168
1169 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( 1169 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
1170 const blink::WebTouchEvent& touch_event) { 1170 const blink::WebTouchEvent& touch_event) {
1171 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); 1171 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent");
1172 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH); 1172 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH);
1173 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); 1173 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
1174 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); 1174 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency);
1175 input_router_->SendTouchEvent(touch_with_latency); 1175 input_router_->SendTouchEvent(touch_with_latency);
1176 } 1176 }
1177 1177
1178 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( 1178 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
1179 const blink::WebTouchEvent& touch_event, 1179 const blink::WebTouchEvent& touch_event,
1180 const ui::LatencyInfo& ui_latency) { 1180 const ui::LatencyInfo& latency) {
1181 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); 1181 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent");
1182 1182
1183 // Always forward TouchEvents for touch stream consistency. They will be 1183 // Always forward TouchEvents for touch stream consistency. They will be
1184 // ignored if appropriate in FilterInputEvent(). 1184 // ignored if appropriate in FilterInputEvent().
1185 1185
1186 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency); 1186 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency);
1187 if (touch_emulator_ && 1187 if (touch_emulator_ &&
1188 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { 1188 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) {
1189 if (view_) { 1189 if (view_) {
1190 view_->ProcessAckedTouchEvent( 1190 view_->ProcessAckedTouchEvent(
1191 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); 1191 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED);
1192 } 1192 }
1193 return; 1193 return;
1194 } 1194 }
1195 1195
1196 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); 1196 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency);
1197 input_router_->SendTouchEvent(touch_with_latency); 1197 input_router_->SendTouchEvent(touch_with_latency);
1198 } 1198 }
1199 1199
1200 void RenderWidgetHostImpl::ForwardKeyboardEvent( 1200 void RenderWidgetHostImpl::ForwardKeyboardEventWithLatencyInfo(
1201 const NativeWebKeyboardEvent& key_event) { 1201 const NativeWebKeyboardEvent& key_event,
1202 ForwardKeyboardEventWithCommands(key_event, nullptr, nullptr); 1202 const ui::LatencyInfo& latency) {
1203 ForwardKeyboardEventWithCommands(key_event, latency, nullptr, nullptr);
1203 } 1204 }
1204 1205
1205 void RenderWidgetHostImpl::ForwardKeyboardEventWithCommands( 1206 void RenderWidgetHostImpl::ForwardKeyboardEventWithCommands(
1206 const NativeWebKeyboardEvent& key_event, 1207 const NativeWebKeyboardEvent& key_event,
1208 const ui::LatencyInfo& latency,
1207 const std::vector<EditCommand>* commands, 1209 const std::vector<EditCommand>* commands,
1208 bool* update_event) { 1210 bool* update_event) {
1209 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); 1211 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent");
1210 if (owner_delegate_ && 1212 if (owner_delegate_ &&
1211 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { 1213 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) {
1212 return; 1214 return;
1213 } 1215 }
1214 1216
1215 if (ShouldDropInputEvents()) 1217 if (ShouldDropInputEvents())
1216 return; 1218 return;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 is_shortcut = true; 1275 is_shortcut = true;
1274 break; 1276 break;
1275 } 1277 }
1276 1278
1277 if (key_event.GetType() == WebKeyboardEvent::kRawKeyDown) 1279 if (key_event.GetType() == WebKeyboardEvent::kRawKeyDown)
1278 suppress_events_until_keydown_ = false; 1280 suppress_events_until_keydown_ = false;
1279 } 1281 }
1280 1282
1281 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) 1283 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event))
1282 return; 1284 return;
1283 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER);
1284 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, 1285 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event,
1285 latency_info); 1286 latency);
1286 key_event_with_latency.event.is_browser_shortcut = is_shortcut; 1287 key_event_with_latency.event.is_browser_shortcut = is_shortcut;
1287 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); 1288 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency);
1288 // TODO(foolip): |InputRouter::SendKeyboardEvent()| may filter events, in 1289 // TODO(foolip): |InputRouter::SendKeyboardEvent()| may filter events, in
1289 // which the commands will be treated as belonging to the next key event. 1290 // which the commands will be treated as belonging to the next key event.
1290 // InputMsg_SetEditCommandsForNextKeyEvent should only be sent if 1291 // InputMsg_SetEditCommandsForNextKeyEvent should only be sent if
1291 // InputMsg_HandleInputEvent is, but has to be sent first. 1292 // InputMsg_HandleInputEvent is, but has to be sent first.
1292 // https://crbug.com/684298 1293 // https://crbug.com/684298
1293 if (commands && !commands->empty()) { 1294 if (commands && !commands->empty()) {
1294 Send( 1295 Send(
1295 new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), *commands)); 1296 new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), *commands));
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 RenderProcessHost* rph = GetProcess(); 2636 RenderProcessHost* rph = GetProcess();
2636 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); 2637 for (std::vector<IPC::Message>::const_iterator i = messages.begin();
2637 i != messages.end(); ++i) { 2638 i != messages.end(); ++i) {
2638 rph->OnMessageReceived(*i); 2639 rph->OnMessageReceived(*i);
2639 if (i->dispatch_error()) 2640 if (i->dispatch_error())
2640 rph->OnBadMessageReceived(*i); 2641 rph->OnBadMessageReceived(*i);
2641 } 2642 }
2642 } 2643 }
2643 2644
2644 } // namespace content 2645 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698