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

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

Issue 18937002: Add UMA/Telemetry stats for end-to-end scroll latency (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rename NewInputLatencyInfo() to CreateRWHLatencyInfoIfNotExist() Created 7 years, 5 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 x, y, 0)); 1019 x, y, 0));
1020 } 1020 }
1021 break; 1021 break;
1022 case WebMouseEvent::ButtonNone: 1022 case WebMouseEvent::ButtonNone:
1023 break; 1023 break;
1024 } 1024 }
1025 } 1025 }
1026 1026
1027 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { 1027 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
1028 ForwardMouseEventWithLatencyInfo( 1028 ForwardMouseEventWithLatencyInfo(
1029 MouseEventWithLatencyInfo(mouse_event, NewInputLatencyInfo())); 1029 MouseEventWithLatencyInfo(mouse_event,
1030 CreateRWHLatencyInfoIfNotExist(NULL)));
1030 } 1031 }
1031 1032
1032 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( 1033 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo(
1033 const MouseEventWithLatencyInfo& mouse_event) { 1034 const MouseEventWithLatencyInfo& mouse_event) {
1034 TRACE_EVENT2("input", 1035 TRACE_EVENT2("input",
1035 "RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo", 1036 "RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo",
1036 "x", mouse_event.event.x, "y", mouse_event.event.y); 1037 "x", mouse_event.event.x, "y", mouse_event.event.y);
1037 if (ignore_input_events_ || process_->IgnoreInputEvents()) 1038 if (ignore_input_events_ || process_->IgnoreInputEvents())
1038 return; 1039 return;
1039 1040
(...skipping 13 matching lines...) Expand all
1053 return; 1054 return;
1054 1055
1055 ForwardMouseEventImmediately(mouse_event); 1056 ForwardMouseEventImmediately(mouse_event);
1056 } 1057 }
1057 1058
1058 void RenderWidgetHostImpl::OnPointerEventActivate() { 1059 void RenderWidgetHostImpl::OnPointerEventActivate() {
1059 } 1060 }
1060 1061
1061 void RenderWidgetHostImpl::ForwardWheelEvent( 1062 void RenderWidgetHostImpl::ForwardWheelEvent(
1062 const WebMouseWheelEvent& wheel_event) { 1063 const WebMouseWheelEvent& wheel_event) {
1063 ForwardWheelEventWithLatencyInfo(wheel_event, NewInputLatencyInfo()); 1064 ForwardWheelEventWithLatencyInfo(wheel_event,
1065 CreateRWHLatencyInfoIfNotExist(NULL));
1064 } 1066 }
1065 1067
1066 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( 1068 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
1067 const WebMouseWheelEvent& wheel_event, 1069 const WebMouseWheelEvent& wheel_event,
1068 const ui::LatencyInfo& latency_info) { 1070 const ui::LatencyInfo& latency_info) {
1069 TRACE_EVENT0("input", 1071 TRACE_EVENT0("input",
1070 "RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo"); 1072 "RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo");
1071 if (ignore_input_events_ || process_->IgnoreInputEvents()) 1073 if (ignore_input_events_ || process_->IgnoreInputEvents())
1072 return; 1074 return;
1073 1075
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); 1129 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo());
1128 } 1130 }
1129 1131
1130 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( 1132 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo(
1131 const WebKit::WebGestureEvent& gesture_event, 1133 const WebKit::WebGestureEvent& gesture_event,
1132 const ui::LatencyInfo& ui_latency) { 1134 const ui::LatencyInfo& ui_latency) {
1133 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); 1135 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent");
1134 if (ignore_input_events_ || process_->IgnoreInputEvents()) 1136 if (ignore_input_events_ || process_->IgnoreInputEvents())
1135 return; 1137 return;
1136 1138
1137 ui::LatencyInfo latency_info; 1139 ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(&ui_latency);
1138 // In Aura, gesture event will carry its original touch event's
1139 // INPUT_EVENT_LATENCY_RWH_COMPONENT. For non-aura platform, we add the
1140 // INPUT_EVENT_LATENCY_RWH_COMPONENT right here.
1141 if (!ui_latency.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
1142 GetLatencyComponentId(),
1143 NULL))
1144 latency_info = NewInputLatencyInfo();
1145 1140
1146 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_INJECTED_RWH_COMPONENT, 1141 WebKit::WebInputEvent::Type type = gesture_event.type;
1147 GetLatencyComponentId(), 1142 if (type == WebKit::WebInputEvent::GestureScrollUpdate ||
1148 ++last_input_number_); 1143 type == WebKit::WebInputEvent::GestureScrollUpdateWithoutPropagation) {
1149 latency_info.MergeWith(ui_latency); 1144 latency_info.AddLatencyNumber(
1145 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT,
1146 GetLatencyComponentId(),
1147 ++last_input_number_);
1148 }
1150 1149
1151 if (!IsInOverscrollGesture() && 1150 if (!IsInOverscrollGesture() &&
1152 !gesture_event_filter_->ShouldForward( 1151 !gesture_event_filter_->ShouldForward(
1153 GestureEventWithLatencyInfo(gesture_event, latency_info))) { 1152 GestureEventWithLatencyInfo(gesture_event, latency_info))) {
1154 if (overscroll_controller_.get()) 1153 if (overscroll_controller_.get())
1155 overscroll_controller_->DiscardingGestureEvent(gesture_event); 1154 overscroll_controller_->DiscardingGestureEvent(gesture_event);
1156 return; 1155 return;
1157 } 1156 }
1158 1157
1159 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), 1158 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent),
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 // Put all WebKeyboardEvent objects in a queue since we can't trust the 1283 // Put all WebKeyboardEvent objects in a queue since we can't trust the
1285 // renderer and we need to give something to the HandleKeyboardEvent 1284 // renderer and we need to give something to the HandleKeyboardEvent
1286 // handler. 1285 // handler.
1287 key_queue_.push_back(key_event); 1286 key_queue_.push_back(key_event);
1288 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); 1287 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
1289 1288
1290 gesture_event_filter_->FlingHasBeenHalted(); 1289 gesture_event_filter_->FlingHasBeenHalted();
1291 1290
1292 // Only forward the non-native portions of our event. 1291 // Only forward the non-native portions of our event.
1293 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent), 1292 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent),
1294 NewInputLatencyInfo(), 1293 CreateRWHLatencyInfoIfNotExist(NULL),
1295 is_keyboard_shortcut); 1294 is_keyboard_shortcut);
1296 } 1295 }
1297 } 1296 }
1298 1297
1299 void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) { 1298 void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) {
1300 Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible)); 1299 Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible));
1301 } 1300 }
1302 1301
1303 int64 RenderWidgetHostImpl::GetLatencyComponentId() { 1302 int64 RenderWidgetHostImpl::GetLatencyComponentId() {
1304 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); 1303 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32);
1305 } 1304 }
1306 1305
1307 // static 1306 // static
1308 void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() { 1307 void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() {
1309 g_check_for_pending_resize_ack = false; 1308 g_check_for_pending_resize_ack = false;
1310 } 1309 }
1311 1310
1312 ui::LatencyInfo RenderWidgetHostImpl::NewInputLatencyInfo() { 1311 ui::LatencyInfo RenderWidgetHostImpl::CreateRWHLatencyInfoIfNotExist(
1312 const ui::LatencyInfo* original) {
1313 ui::LatencyInfo info; 1313 ui::LatencyInfo info;
1314 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, 1314 if (original)
1315 info = *original;
1316 // In Aura, gesture event will already carry its original touch event's
1317 // INPUT_EVENT_LATENCY_RWH_COMPONENT.
1318 if (!info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
1315 GetLatencyComponentId(), 1319 GetLatencyComponentId(),
1316 ++last_input_number_); 1320 NULL)) {
1321 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
1322 GetLatencyComponentId(),
1323 ++last_input_number_);
1324 }
1317 return info; 1325 return info;
1318 } 1326 }
1319 1327
1320 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, 1328 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event,
1321 int event_size, 1329 int event_size,
1322 const ui::LatencyInfo& latency_info, 1330 const ui::LatencyInfo& latency_info,
1323 bool is_keyboard_shortcut) { 1331 bool is_keyboard_shortcut) {
1324 DCHECK(latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, 1332 DCHECK(latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
1325 GetLatencyComponentId(), 1333 GetLatencyComponentId(),
1326 NULL)); 1334 NULL));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 // after this line. 1419 // after this line.
1412 next_mouse_move_.reset(); 1420 next_mouse_move_.reset();
1413 1421
1414 StartHangMonitorTimeout( 1422 StartHangMonitorTimeout(
1415 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); 1423 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
1416 } 1424 }
1417 1425
1418 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( 1426 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
1419 const WebKit::WebTouchEvent& touch_event, 1427 const WebKit::WebTouchEvent& touch_event,
1420 const ui::LatencyInfo& ui_latency) { 1428 const ui::LatencyInfo& ui_latency) {
1421 ui::LatencyInfo latency_info = NewInputLatencyInfo(); 1429 ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(&ui_latency);
1422 latency_info.MergeWith(ui_latency);
1423 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); 1430 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
1424 touch_event_queue_->QueueEvent(touch_with_latency); 1431 touch_event_queue_->QueueEvent(touch_with_latency);
1425 } 1432 }
1426 1433
1427 void RenderWidgetHostImpl::AddKeyboardListener(KeyboardListener* listener) { 1434 void RenderWidgetHostImpl::AddKeyboardListener(KeyboardListener* listener) {
1428 keyboard_listeners_.AddObserver(listener); 1435 keyboard_listeners_.AddObserver(listener);
1429 } 1436 }
1430 1437
1431 void RenderWidgetHostImpl::RemoveKeyboardListener( 1438 void RenderWidgetHostImpl::RemoveKeyboardListener(
1432 KeyboardListener* listener) { 1439 KeyboardListener* listener) {
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 1000000, 2654 1000000,
2648 100); 2655 100);
2649 } 2656 }
2650 2657
2651 if (CommandLine::ForCurrentProcess()->HasSwitch( 2658 if (CommandLine::ForCurrentProcess()->HasSwitch(
2652 switches::kEnableGpuBenchmarking)) 2659 switches::kEnableGpuBenchmarking))
2653 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); 2660 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_));
2654 } 2661 }
2655 2662
2656 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { 2663 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
2657 ui::LatencyInfo::LatencyMap::const_iterator l = 2664 ui::LatencyInfo::LatencyComponent rwh_component;
2658 latency_info.latency_components.find(std::make_pair( 2665 if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
2659 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); 2666 GetLatencyComponentId(),
2660 if (l == latency_info.latency_components.end()) 2667 &rwh_component))
2661 return; 2668 return;
2662 2669
2663 rendering_stats_.input_event_count += l->second.event_count; 2670 rendering_stats_.input_event_count += rwh_component.event_count;
2664 rendering_stats_.total_input_latency += 2671 rendering_stats_.total_input_latency +=
2665 l->second.event_count * 2672 rwh_component.event_count *
2666 (latency_info.swap_timestamp - l->second.event_time); 2673 (latency_info.swap_timestamp - rwh_component.event_time);
2674
2675 ui::LatencyInfo::LatencyComponent original_component;
2676 if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
2677 0,
2678 &original_component) &&
2679 latency_info.FindLatency(
2680 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT,
2681 GetLatencyComponentId(),
2682 NULL)) {
2683 // This UMA metric tracks the time from when the original touch event is
2684 // created (averaged if there are multiple) to when the scroll gesture
2685 // results in final frame swap.
2686 base::TimeDelta delta =
2687 latency_info.swap_timestamp - original_component.event_time;
2688 UMA_HISTOGRAM_CUSTOM_COUNTS(
2689 "Event.Latency.Browser.TouchToScroll",
Rick Byers 2013/07/10 20:19:03 nit: probably want to call this TouchToScrollUpdat
Yufeng Shen (Slow to review) 2013/07/10 21:05:53 done. and also rename the telemetry stats to avera
2690 delta.InMicroseconds(),
2691 0,
2692 1000000,
2693 100);
2694 rendering_stats_.scroll_event_count += original_component.event_count;
2695 rendering_stats_.total_scroll_latency +=
2696 original_component.event_count *
2697 (latency_info.swap_timestamp - original_component.event_time);
2698 }
2667 2699
2668 if (CommandLine::ForCurrentProcess()->HasSwitch( 2700 if (CommandLine::ForCurrentProcess()->HasSwitch(
2669 switches::kEnableGpuBenchmarking)) 2701 switches::kEnableGpuBenchmarking))
2670 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); 2702 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_));
2671 } 2703 }
2672 2704
2673 void RenderWidgetHostImpl::DidReceiveRendererFrame() { 2705 void RenderWidgetHostImpl::DidReceiveRendererFrame() {
2674 view_->DidReceiveRendererFrame(); 2706 view_->DidReceiveRendererFrame();
2675 } 2707 }
2676 2708
(...skipping 11 matching lines...) Expand all
2688 int process_id = (b->first.second >> 32) & 0xffffffff; 2720 int process_id = (b->first.second >> 32) & 0xffffffff;
2689 RenderWidgetHost* rwh = 2721 RenderWidgetHost* rwh =
2690 RenderWidgetHost::FromID(process_id, routing_id); 2722 RenderWidgetHost::FromID(process_id, routing_id);
2691 if (!rwh) 2723 if (!rwh)
2692 continue; 2724 continue;
2693 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2725 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2694 } 2726 }
2695 } 2727 }
2696 2728
2697 } // namespace content 2729 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/common/browser_rendering_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698