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

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

Issue 2086453002: Log First User Interaction in Page Load Metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: 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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 return; 958 return;
959 } 959 }
960 960
961 if (ShouldDropInputEvents()) 961 if (ShouldDropInputEvents())
962 return; 962 return;
963 963
964 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) 964 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event))
965 return; 965 return;
966 966
967 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); 967 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency);
968 latency_tracker_.OnInputEvent(mouse_event, &mouse_with_latency.latency); 968 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency);
969 input_router_->SendMouseEvent(mouse_with_latency); 969 input_router_->SendMouseEvent(mouse_with_latency);
970 } 970 }
971 971
972 void RenderWidgetHostImpl::ForwardWheelEvent( 972 void RenderWidgetHostImpl::ForwardWheelEvent(
973 const WebMouseWheelEvent& wheel_event) { 973 const WebMouseWheelEvent& wheel_event) {
974 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); 974 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo());
975 } 975 }
976 976
977 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( 977 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
978 const blink::WebMouseWheelEvent& wheel_event, 978 const blink::WebMouseWheelEvent& wheel_event,
979 const ui::LatencyInfo& ui_latency) { 979 const ui::LatencyInfo& ui_latency) {
980 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", 980 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent",
981 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); 981 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY);
982 982
983 if (ShouldDropInputEvents()) 983 if (ShouldDropInputEvents())
984 return; 984 return;
985 985
986 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) 986 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event))
987 return; 987 return;
988 988
989 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); 989 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency);
990 latency_tracker_.OnInputEvent(wheel_event, &wheel_with_latency.latency); 990 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency);
991 input_router_->SendWheelEvent(wheel_with_latency); 991 input_router_->SendWheelEvent(wheel_with_latency);
992 } 992 }
993 993
994 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( 994 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent(
995 const blink::WebGestureEvent& gesture_event) { 995 const blink::WebGestureEvent& gesture_event) {
996 ForwardGestureEvent(gesture_event); 996 ForwardGestureEvent(gesture_event);
997 } 997 }
998 998
999 void RenderWidgetHostImpl::ForwardGestureEvent( 999 void RenderWidgetHostImpl::ForwardGestureEvent(
1000 const blink::WebGestureEvent& gesture_event) { 1000 const blink::WebGestureEvent& gesture_event) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 if (scroll_update_needs_wrapping) { 1036 if (scroll_update_needs_wrapping) {
1037 ForwardGestureEventWithLatencyInfo( 1037 ForwardGestureEventWithLatencyInfo(
1038 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); 1038 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo());
1039 } 1039 }
1040 1040
1041 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. 1041 // Delegate must be non-null, due to |ShouldDropInputEvents()| test.
1042 if (delegate_->PreHandleGestureEvent(gesture_event)) 1042 if (delegate_->PreHandleGestureEvent(gesture_event))
1043 return; 1043 return;
1044 1044
1045 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); 1045 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency);
1046 latency_tracker_.OnInputEvent(gesture_event, &gesture_with_latency.latency); 1046 DispatchInputEventWithLatencyInfo(gesture_event,
1047 &gesture_with_latency.latency);
1047 input_router_->SendGestureEvent(gesture_with_latency); 1048 input_router_->SendGestureEvent(gesture_with_latency);
1048 1049
1049 if (scroll_update_needs_wrapping) { 1050 if (scroll_update_needs_wrapping) {
1050 ForwardGestureEventWithLatencyInfo( 1051 ForwardGestureEventWithLatencyInfo(
1051 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); 1052 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo());
1052 } 1053 }
1053 } 1054 }
1054 1055
1055 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( 1056 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
1056 const blink::WebTouchEvent& touch_event) { 1057 const blink::WebTouchEvent& touch_event) {
1057 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); 1058 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent");
1058 1059
1059 TouchEventWithLatencyInfo touch_with_latency(touch_event); 1060 TouchEventWithLatencyInfo touch_with_latency(touch_event);
1060 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); 1061 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency);
1061 input_router_->SendTouchEvent(touch_with_latency); 1062 input_router_->SendTouchEvent(touch_with_latency);
1062 } 1063 }
1063 1064
1064 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( 1065 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
1065 const blink::WebTouchEvent& touch_event, 1066 const blink::WebTouchEvent& touch_event,
1066 const ui::LatencyInfo& ui_latency) { 1067 const ui::LatencyInfo& ui_latency) {
1067 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); 1068 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent");
1068 1069
1069 // Always forward TouchEvents for touch stream consistency. They will be 1070 // Always forward TouchEvents for touch stream consistency. They will be
1070 // ignored if appropriate in FilterInputEvent(). 1071 // ignored if appropriate in FilterInputEvent().
1071 1072
1072 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency); 1073 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency);
1073 if (touch_emulator_ && 1074 if (touch_emulator_ &&
1074 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { 1075 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) {
1075 if (view_) { 1076 if (view_) {
1076 view_->ProcessAckedTouchEvent( 1077 view_->ProcessAckedTouchEvent(
1077 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); 1078 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED);
1078 } 1079 }
1079 return; 1080 return;
1080 } 1081 }
1081 1082
1082 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); 1083 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency);
1083 input_router_->SendTouchEvent(touch_with_latency); 1084 input_router_->SendTouchEvent(touch_with_latency);
1084 } 1085 }
1085 1086
1086 void RenderWidgetHostImpl::ForwardKeyboardEvent( 1087 void RenderWidgetHostImpl::ForwardKeyboardEvent(
1087 const NativeWebKeyboardEvent& key_event) { 1088 const NativeWebKeyboardEvent& key_event) {
1088 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); 1089 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent");
1089 if (owner_delegate_ && 1090 if (owner_delegate_ &&
1090 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { 1091 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) {
1091 return; 1092 return;
1092 } 1093 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1142
1142 if (key_event.type == WebKeyboardEvent::RawKeyDown) 1143 if (key_event.type == WebKeyboardEvent::RawKeyDown)
1143 suppress_next_char_events_ = false; 1144 suppress_next_char_events_ = false;
1144 } 1145 }
1145 1146
1146 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) 1147 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event))
1147 return; 1148 return;
1148 1149
1149 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event); 1150 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event);
1150 key_event_with_latency.event.isBrowserShortcut = is_shortcut; 1151 key_event_with_latency.event.isBrowserShortcut = is_shortcut;
1151 latency_tracker_.OnInputEvent(key_event, &key_event_with_latency.latency); 1152 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency);
1152 input_router_->SendKeyboardEvent(key_event_with_latency); 1153 input_router_->SendKeyboardEvent(key_event_with_latency);
1153 } 1154 }
1154 1155
1155 void RenderWidgetHostImpl::QueueSyntheticGesture( 1156 void RenderWidgetHostImpl::QueueSyntheticGesture(
1156 std::unique_ptr<SyntheticGesture> synthetic_gesture, 1157 std::unique_ptr<SyntheticGesture> synthetic_gesture,
1157 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { 1158 const base::Callback<void(SyntheticGesture::Result)>& on_complete) {
1158 if (!synthetic_gesture_controller_ && view_) { 1159 if (!synthetic_gesture_controller_ && view_) {
1159 synthetic_gesture_controller_.reset( 1160 synthetic_gesture_controller_.reset(
1160 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); 1161 new SyntheticGestureController(view_->CreateSyntheticGestureTarget()));
1161 } 1162 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 void RenderWidgetHostImpl::RemoveMouseEventCallback( 1214 void RenderWidgetHostImpl::RemoveMouseEventCallback(
1214 const MouseEventCallback& callback) { 1215 const MouseEventCallback& callback) {
1215 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { 1216 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) {
1216 if (mouse_event_callbacks_[i].Equals(callback)) { 1217 if (mouse_event_callbacks_[i].Equals(callback)) {
1217 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i); 1218 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i);
1218 return; 1219 return;
1219 } 1220 }
1220 } 1221 }
1221 } 1222 }
1222 1223
1224 void RenderWidgetHostImpl::AddInputEventObserver(
1225 RenderWidgetHost::InputEventObserver* observer) {
1226 if (!input_event_observers_.HasObserver(observer))
1227 input_event_observers_.AddObserver(observer);
1228 }
1229
1230 void RenderWidgetHostImpl::RemoveInputEventObserver(
1231 RenderWidgetHost::InputEventObserver* observer) {
1232 input_event_observers_.RemoveObserver(observer);
1233 }
1234
1223 void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) { 1235 void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) {
1224 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); 1236 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo");
1225 if (view_) 1237 if (view_)
1226 view_->GetScreenInfo(result); 1238 view_->GetScreenInfo(result);
1227 else 1239 else
1228 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); 1240 RenderWidgetHostViewBase::GetDefaultScreenInfo(result);
1229 // TODO(sievers): find a way to make this done another way so the method 1241 // TODO(sievers): find a way to make this done another way so the method
1230 // can be const. 1242 // can be const.
1231 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); 1243 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor);
1232 if (IsUseZoomForDSFEnabled()) 1244 if (IsUseZoomForDSFEnabled())
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) { 1883 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) {
1872 if (view_) 1884 if (view_)
1873 view_->DidOverscroll(params); 1885 view_->DidOverscroll(params);
1874 } 1886 }
1875 1887
1876 void RenderWidgetHostImpl::DidStopFlinging() { 1888 void RenderWidgetHostImpl::DidStopFlinging() {
1877 if (view_) 1889 if (view_)
1878 view_->DidStopFlinging(); 1890 view_->DidStopFlinging();
1879 } 1891 }
1880 1892
1893 void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo(
1894 const blink::WebInputEvent& event,
1895 ui::LatencyInfo* latency) {
1896 latency_tracker_.OnInputEvent(event, latency);
1897 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_,
1898 OnInputEvent(event));
1899 }
1900
1881 void RenderWidgetHostImpl::OnKeyboardEventAck( 1901 void RenderWidgetHostImpl::OnKeyboardEventAck(
1882 const NativeWebKeyboardEventWithLatencyInfo& event, 1902 const NativeWebKeyboardEventWithLatencyInfo& event,
1883 InputEventAckState ack_result) { 1903 InputEventAckState ack_result) {
1884 latency_tracker_.OnInputEventAck(event.event, &event.latency); 1904 latency_tracker_.OnInputEventAck(event.event, &event.latency);
1885 1905
1886 // We only send unprocessed key event upwards if we are not hidden, 1906 // We only send unprocessed key event upwards if we are not hidden,
1887 // because the user has moved away from us and no longer expect any effect 1907 // because the user has moved away from us and no longer expect any effect
1888 // of this key event. 1908 // of this key event.
1889 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 1909 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
1890 if (delegate_ && !processed && !is_hidden() && !event.event.skip_in_browser) { 1910 if (delegate_ && !processed && !is_hidden() && !event.event.skip_in_browser) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2171 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2152 } 2172 }
2153 2173
2154 BrowserAccessibilityManager* 2174 BrowserAccessibilityManager*
2155 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2175 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2156 return delegate_ ? 2176 return delegate_ ?
2157 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2177 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2158 } 2178 }
2159 2179
2160 } // namespace content 2180 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/public/browser/render_widget_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698