Chromium Code Reviews| 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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. |
| 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_INJECTED_RWH_COMPONENT, | |
| 1152 GetLatencyComponentId(), | |
| 1153 ++last_input_number_); | |
| 1154 latency_info.MergeWith(ui_latency); | |
|
Rick Byers
2013/07/10 01:36:30
Why do we need two different LatencyInfo objects h
Yufeng Shen (Slow to review)
2013/07/10 15:12:04
right. it is just that it happens to be coded this
Rick Byers
2013/07/10 15:31:35
Ok, I see. But now that you're only conditionally
| |
| 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(ui::INPUT_EVENT_LATENCY_INJECTED_RWH_COMPONENT, | |
| 2679 GetLatencyComponentId(), | |
| 2680 NULL)) { | |
| 2681 // This UMA metric tracks the time from when the original touch event is | |
| 2682 // created (averaged if there are multiple) to when the scroll gesture | |
| 2683 // results in final frame swap. | |
| 2684 base::TimeDelta delta = | |
| 2685 latency_info.swap_timestamp - original_component.event_time; | |
| 2686 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 2687 "Event.Latency.Browser.TouchToScroll", | |
| 2688 delta.InMicroseconds(), | |
| 2689 0, | |
| 2690 1000000, | |
| 2691 100); | |
| 2692 rendering_stats_.scroll_event_count += original_component.event_count; | |
| 2693 rendering_stats_.total_scroll_latency += | |
| 2694 original_component.event_count * | |
| 2695 (latency_info.swap_timestamp - original_component.event_time); | |
| 2696 } | |
| 2667 | 2697 |
| 2668 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2698 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2669 switches::kEnableGpuBenchmarking)) | 2699 switches::kEnableGpuBenchmarking)) |
| 2670 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2700 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
| 2671 } | 2701 } |
| 2672 | 2702 |
| 2673 void RenderWidgetHostImpl::DidReceiveRendererFrame() { | 2703 void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
| 2674 view_->DidReceiveRendererFrame(); | 2704 view_->DidReceiveRendererFrame(); |
| 2675 } | 2705 } |
| 2676 | 2706 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2688 int process_id = (b->first.second >> 32) & 0xffffffff; | 2718 int process_id = (b->first.second >> 32) & 0xffffffff; |
| 2689 RenderWidgetHost* rwh = | 2719 RenderWidgetHost* rwh = |
| 2690 RenderWidgetHost::FromID(process_id, routing_id); | 2720 RenderWidgetHost::FromID(process_id, routing_id); |
| 2691 if (!rwh) | 2721 if (!rwh) |
| 2692 continue; | 2722 continue; |
| 2693 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2723 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
| 2694 } | 2724 } |
| 2695 } | 2725 } |
| 2696 | 2726 |
| 2697 } // namespace content | 2727 } // namespace content |
| OLD | NEW |