OLD | NEW |
---|---|
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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1130 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( | 1130 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
1131 const WebKit::WebGestureEvent& gesture_event, | 1131 const WebKit::WebGestureEvent& gesture_event, |
1132 const ui::LatencyInfo& ui_latency) { | 1132 const ui::LatencyInfo& ui_latency) { |
1133 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); | 1133 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); |
1134 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 1134 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
1135 return; | 1135 return; |
1136 | 1136 |
1137 ui::LatencyInfo latency_info; | 1137 ui::LatencyInfo latency_info; |
1138 // In Aura, gesture event will carry its original touch event's | 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 | 1139 // INPUT_EVENT_LATENCY_RWH_COMPONENT. For non-aura platform, we add the |
1140 // INPUT_EVENT_LATENCY_RWH_COMPONENT right here. | 1140 // INPUT_EVENT_LATENCY_RWH_COMPONENT right here. |
Rick Byers
2013/07/10 15:31:35
We should probably work to unify Android and Aura
| |
1141 if (!ui_latency.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, | 1141 if (!ui_latency.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
1142 GetLatencyComponentId(), | 1142 GetLatencyComponentId(), |
1143 NULL)) | 1143 NULL)) |
1144 latency_info = NewInputLatencyInfo(); | 1144 latency_info = NewInputLatencyInfo(); |
1145 | 1145 |
1146 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_INJECTED_RWH_COMPONENT, | 1146 WebKit::WebInputEvent::Type type = gesture_event.type; |
1147 GetLatencyComponentId(), | 1147 if (type == WebKit::WebInputEvent::GestureScrollBegin || |
1148 ++last_input_number_); | 1148 type == WebKit::WebInputEvent::GestureScrollUpdate || |
1149 latency_info.MergeWith(ui_latency); | 1149 type == WebKit::WebInputEvent::GestureScrollUpdateWithoutPropagation) { |
1150 latency_info.AddLatencyNumber( | |
1151 ui::INPUT_EVENT_LATENCY_GESTURE_SCROLL_RWH_COMPONENT, | |
1152 GetLatencyComponentId(), | |
1153 ++last_input_number_); | |
1154 latency_info.MergeWith(ui_latency); | |
1155 } | |
1150 | 1156 |
1151 if (!IsInOverscrollGesture() && | 1157 if (!IsInOverscrollGesture() && |
1152 !gesture_event_filter_->ShouldForward( | 1158 !gesture_event_filter_->ShouldForward( |
1153 GestureEventWithLatencyInfo(gesture_event, latency_info))) { | 1159 GestureEventWithLatencyInfo(gesture_event, latency_info))) { |
1154 if (overscroll_controller_.get()) | 1160 if (overscroll_controller_.get()) |
1155 overscroll_controller_->DiscardingGestureEvent(gesture_event); | 1161 overscroll_controller_->DiscardingGestureEvent(gesture_event); |
1156 return; | 1162 return; |
1157 } | 1163 } |
1158 | 1164 |
1159 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), | 1165 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2647 1000000, | 2653 1000000, |
2648 100); | 2654 100); |
2649 } | 2655 } |
2650 | 2656 |
2651 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2657 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2652 switches::kEnableGpuBenchmarking)) | 2658 switches::kEnableGpuBenchmarking)) |
2653 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2659 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
2654 } | 2660 } |
2655 | 2661 |
2656 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { | 2662 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
2657 ui::LatencyInfo::LatencyMap::const_iterator l = | 2663 ui::LatencyInfo::LatencyComponent rwh_component; |
2658 latency_info.latency_components.find(std::make_pair( | 2664 if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
2659 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); | 2665 GetLatencyComponentId(), |
2660 if (l == latency_info.latency_components.end()) | 2666 &rwh_component)) |
2661 return; | 2667 return; |
2662 | 2668 |
2663 rendering_stats_.input_event_count += l->second.event_count; | 2669 rendering_stats_.input_event_count += rwh_component.event_count; |
2664 rendering_stats_.total_input_latency += | 2670 rendering_stats_.total_input_latency += |
2665 l->second.event_count * | 2671 rwh_component.event_count * |
2666 (latency_info.swap_timestamp - l->second.event_time); | 2672 (latency_info.swap_timestamp - rwh_component.event_time); |
2673 | |
2674 ui::LatencyInfo::LatencyComponent original_component; | |
2675 if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | |
2676 0, | |
2677 &original_component) && | |
2678 latency_info.FindLatency( | |
2679 ui::INPUT_EVENT_LATENCY_GESTURE_SCROLL_RWH_COMPONENT, | |
2680 GetLatencyComponentId(), | |
2681 NULL)) { | |
2682 // This UMA metric tracks the time from when the original touch event is | |
2683 // created (averaged if there are multiple) to when the scroll gesture | |
2684 // results in final frame swap. | |
2685 base::TimeDelta delta = | |
2686 latency_info.swap_timestamp - original_component.event_time; | |
2687 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
2688 "Event.Latency.Browser.TouchToScroll", | |
2689 delta.InMicroseconds(), | |
2690 0, | |
2691 1000000, | |
2692 100); | |
2693 rendering_stats_.scroll_event_count += original_component.event_count; | |
2694 rendering_stats_.total_scroll_latency += | |
2695 original_component.event_count * | |
2696 (latency_info.swap_timestamp - original_component.event_time); | |
2697 } | |
2667 | 2698 |
2668 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2699 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2669 switches::kEnableGpuBenchmarking)) | 2700 switches::kEnableGpuBenchmarking)) |
2670 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2701 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
2671 } | 2702 } |
2672 | 2703 |
2673 void RenderWidgetHostImpl::DidReceiveRendererFrame() { | 2704 void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
2674 view_->DidReceiveRendererFrame(); | 2705 view_->DidReceiveRendererFrame(); |
2675 } | 2706 } |
2676 | 2707 |
(...skipping 11 matching lines...) Expand all Loading... | |
2688 int process_id = (b->first.second >> 32) & 0xffffffff; | 2719 int process_id = (b->first.second >> 32) & 0xffffffff; |
2689 RenderWidgetHost* rwh = | 2720 RenderWidgetHost* rwh = |
2690 RenderWidgetHost::FromID(process_id, routing_id); | 2721 RenderWidgetHost::FromID(process_id, routing_id); |
2691 if (!rwh) | 2722 if (!rwh) |
2692 continue; | 2723 continue; |
2693 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2724 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
2694 } | 2725 } |
2695 } | 2726 } |
2696 | 2727 |
2697 } // namespace content | 2728 } // namespace content |
OLD | NEW |