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

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

Issue 1984173002: Log First User Interaction in Page Load Metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Get navigation_start in OnCommit callback in FromGWSPLMO Created 4 years, 6 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 <utility> 10 #include <utility>
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 969
970 if (ShouldDropInputEvents()) 970 if (ShouldDropInputEvents())
971 return; 971 return;
972 972
973 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) 973 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event))
974 return; 974 return;
975 975
976 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); 976 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency);
977 latency_tracker_.OnInputEvent(mouse_event, &mouse_with_latency.latency); 977 latency_tracker_.OnInputEvent(mouse_event, &mouse_with_latency.latency);
978 input_router_->SendMouseEvent(mouse_with_latency); 978 input_router_->SendMouseEvent(mouse_with_latency);
979 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
980 OnInputEvent(mouse_event));
979 } 981 }
980 982
981 void RenderWidgetHostImpl::ForwardWheelEvent( 983 void RenderWidgetHostImpl::ForwardWheelEvent(
982 const WebMouseWheelEvent& wheel_event) { 984 const WebMouseWheelEvent& wheel_event) {
983 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); 985 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo());
984 } 986 }
985 987
986 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( 988 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
987 const blink::WebMouseWheelEvent& wheel_event, 989 const blink::WebMouseWheelEvent& wheel_event,
988 const ui::LatencyInfo& ui_latency) { 990 const ui::LatencyInfo& ui_latency) {
989 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", 991 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent",
990 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); 992 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY);
991 993
992 if (ShouldDropInputEvents()) 994 if (ShouldDropInputEvents())
993 return; 995 return;
994 996
995 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) 997 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event))
996 return; 998 return;
997 999
998 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); 1000 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency);
999 latency_tracker_.OnInputEvent(wheel_event, &wheel_with_latency.latency); 1001 latency_tracker_.OnInputEvent(wheel_event, &wheel_with_latency.latency);
Bryan McQuade 2016/05/27 20:06:36 can we add a helper method: void RenderWidgetHost
mushan1 2016/05/28 03:58:32 Done.
1000 input_router_->SendWheelEvent(wheel_with_latency); 1002 input_router_->SendWheelEvent(wheel_with_latency);
1003 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1004 OnInputEvent(wheel_event));
1001 } 1005 }
1002 1006
1003 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( 1007 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent(
1004 const blink::WebGestureEvent& gesture_event) { 1008 const blink::WebGestureEvent& gesture_event) {
1005 ForwardGestureEvent(gesture_event); 1009 ForwardGestureEvent(gesture_event);
1006 } 1010 }
1007 1011
1008 void RenderWidgetHostImpl::ForwardGestureEvent( 1012 void RenderWidgetHostImpl::ForwardGestureEvent(
1009 const blink::WebGestureEvent& gesture_event) { 1013 const blink::WebGestureEvent& gesture_event) {
1010 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); 1014 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); 1051 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo());
1048 } 1052 }
1049 1053
1050 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. 1054 // Delegate must be non-null, due to |ShouldDropInputEvents()| test.
1051 if (delegate_->PreHandleGestureEvent(gesture_event)) 1055 if (delegate_->PreHandleGestureEvent(gesture_event))
1052 return; 1056 return;
1053 1057
1054 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); 1058 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency);
1055 latency_tracker_.OnInputEvent(gesture_event, &gesture_with_latency.latency); 1059 latency_tracker_.OnInputEvent(gesture_event, &gesture_with_latency.latency);
1056 input_router_->SendGestureEvent(gesture_with_latency); 1060 input_router_->SendGestureEvent(gesture_with_latency);
1061 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1062 OnInputEvent(gesture_event));
1057 1063
1058 if (scroll_update_needs_wrapping) { 1064 if (scroll_update_needs_wrapping) {
1059 ForwardGestureEventWithLatencyInfo( 1065 ForwardGestureEventWithLatencyInfo(
1060 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); 1066 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo());
1061 } 1067 }
1062 } 1068 }
1063 1069
1064 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( 1070 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
1065 const blink::WebTouchEvent& touch_event) { 1071 const blink::WebTouchEvent& touch_event) {
1066 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); 1072 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent");
1067 1073
1068 TouchEventWithLatencyInfo touch_with_latency(touch_event); 1074 TouchEventWithLatencyInfo touch_with_latency(touch_event);
1069 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); 1075 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency);
1070 input_router_->SendTouchEvent(touch_with_latency); 1076 input_router_->SendTouchEvent(touch_with_latency);
1077 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1078 OnInputEvent(touch_event));
1071 } 1079 }
1072 1080
1073 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( 1081 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
1074 const blink::WebTouchEvent& touch_event, 1082 const blink::WebTouchEvent& touch_event,
1075 const ui::LatencyInfo& ui_latency) { 1083 const ui::LatencyInfo& ui_latency) {
1076 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); 1084 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent");
1077 1085
1078 // Always forward TouchEvents for touch stream consistency. They will be 1086 // Always forward TouchEvents for touch stream consistency. They will be
1079 // ignored if appropriate in FilterInputEvent(). 1087 // ignored if appropriate in FilterInputEvent().
1080 1088
1081 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency); 1089 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency);
1082 if (touch_emulator_ && 1090 if (touch_emulator_ &&
1083 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { 1091 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) {
1084 if (view_) { 1092 if (view_) {
1085 view_->ProcessAckedTouchEvent( 1093 view_->ProcessAckedTouchEvent(
1086 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); 1094 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED);
1087 } 1095 }
1088 return; 1096 return;
1089 } 1097 }
1090 1098
1091 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); 1099 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency);
1092 input_router_->SendTouchEvent(touch_with_latency); 1100 input_router_->SendTouchEvent(touch_with_latency);
1101 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1102 OnInputEvent(touch_event));
1093 } 1103 }
1094 1104
1095 void RenderWidgetHostImpl::ForwardKeyboardEvent( 1105 void RenderWidgetHostImpl::ForwardKeyboardEvent(
1096 const NativeWebKeyboardEvent& key_event) { 1106 const NativeWebKeyboardEvent& key_event) {
1097 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); 1107 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent");
1098 if (owner_delegate_ && 1108 if (owner_delegate_ &&
1099 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { 1109 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) {
1100 return; 1110 return;
1101 } 1111 }
1102 1112
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 suppress_next_char_events_ = false; 1162 suppress_next_char_events_ = false;
1153 } 1163 }
1154 1164
1155 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) 1165 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event))
1156 return; 1166 return;
1157 1167
1158 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event); 1168 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event);
1159 key_event_with_latency.event.isBrowserShortcut = is_shortcut; 1169 key_event_with_latency.event.isBrowserShortcut = is_shortcut;
1160 latency_tracker_.OnInputEvent(key_event, &key_event_with_latency.latency); 1170 latency_tracker_.OnInputEvent(key_event, &key_event_with_latency.latency);
1161 input_router_->SendKeyboardEvent(key_event_with_latency); 1171 input_router_->SendKeyboardEvent(key_event_with_latency);
1172 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1173 OnInputEvent(key_event));
1162 } 1174 }
1163 1175
1164 void RenderWidgetHostImpl::QueueSyntheticGesture( 1176 void RenderWidgetHostImpl::QueueSyntheticGesture(
1165 std::unique_ptr<SyntheticGesture> synthetic_gesture, 1177 std::unique_ptr<SyntheticGesture> synthetic_gesture,
1166 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { 1178 const base::Callback<void(SyntheticGesture::Result)>& on_complete) {
1167 if (!synthetic_gesture_controller_ && view_) { 1179 if (!synthetic_gesture_controller_ && view_) {
1168 synthetic_gesture_controller_.reset( 1180 synthetic_gesture_controller_.reset(
1169 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); 1181 new SyntheticGestureController(view_->CreateSyntheticGestureTarget()));
1170 } 1182 }
1171 if (synthetic_gesture_controller_) { 1183 if (synthetic_gesture_controller_) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 void RenderWidgetHostImpl::RemoveMouseEventCallback( 1234 void RenderWidgetHostImpl::RemoveMouseEventCallback(
1223 const MouseEventCallback& callback) { 1235 const MouseEventCallback& callback) {
1224 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { 1236 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) {
1225 if (mouse_event_callbacks_[i].Equals(callback)) { 1237 if (mouse_event_callbacks_[i].Equals(callback)) {
1226 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i); 1238 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i);
1227 return; 1239 return;
1228 } 1240 }
1229 } 1241 }
1230 } 1242 }
1231 1243
1244 void RenderWidgetHostImpl::AddInputEventObserver(
1245 RenderWidgetHost::InputEventObserver* observer) {
1246 input_event_observers_.AddObserver(observer);
1247 }
1248
1249 void RenderWidgetHostImpl::RemoveInputEventObserver(
1250 RenderWidgetHost::InputEventObserver* observer) {
1251 input_event_observers_.RemoveObserver(observer);
1252 }
1253
1232 void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) { 1254 void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) {
1233 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); 1255 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo");
1234 if (view_) 1256 if (view_)
1235 view_->GetScreenInfo(result); 1257 view_->GetScreenInfo(result);
1236 else 1258 else
1237 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); 1259 RenderWidgetHostViewBase::GetDefaultScreenInfo(result);
1238 // TODO(sievers): find a way to make this done another way so the method 1260 // TODO(sievers): find a way to make this done another way so the method
1239 // can be const. 1261 // can be const.
1240 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); 1262 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor);
1241 if (IsUseZoomForDSFEnabled()) 1263 if (IsUseZoomForDSFEnabled())
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2186 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2165 } 2187 }
2166 2188
2167 BrowserAccessibilityManager* 2189 BrowserAccessibilityManager*
2168 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2190 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2169 return delegate_ ? 2191 return delegate_ ?
2170 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2192 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2171 } 2193 }
2172 2194
2173 } // namespace content 2195 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698