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 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1107 const WebKit::WebGestureEvent& gesture_event, | 1107 const WebKit::WebGestureEvent& gesture_event, |
| 1108 const ui::LatencyInfo& ui_latency) { | 1108 const ui::LatencyInfo& ui_latency) { |
| 1109 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); | 1109 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); |
| 1110 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 1110 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| 1111 return; | 1111 return; |
| 1112 | 1112 |
| 1113 ui::LatencyInfo latency_info; | 1113 ui::LatencyInfo latency_info; |
| 1114 // In Aura, gesture event will carry its original touch event's | 1114 // In Aura, gesture event will carry its original touch event's |
| 1115 // INPUT_EVENT_LATENCY_RWH_COMPONENT. For non-aura platform, we add the | 1115 // INPUT_EVENT_LATENCY_RWH_COMPONENT. For non-aura platform, we add the |
| 1116 // INPUT_EVENT_LATENCY_RWH_COMPONENT right here. | 1116 // INPUT_EVENT_LATENCY_RWH_COMPONENT right here. |
| 1117 if (!ui_latency.HasLatencyComponent(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, | 1117 if (!ui_latency.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
| 1118 GetLatencyComponentId())) | 1118 GetLatencyComponentId(), |
| 1119 NULL)) | |
| 1119 latency_info = NewInputLatencyInfo(); | 1120 latency_info = NewInputLatencyInfo(); |
| 1120 | 1121 |
| 1121 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_INJECTED_RWH_COMPONENT, | 1122 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_INJECTED_RWH_COMPONENT, |
| 1122 GetLatencyComponentId(), | 1123 GetLatencyComponentId(), |
| 1123 ++last_input_number_); | 1124 ++last_input_number_); |
| 1124 latency_info.MergeWith(ui_latency); | 1125 latency_info.MergeWith(ui_latency); |
| 1125 | 1126 |
| 1126 if (!IsInOverscrollGesture() && | 1127 if (!IsInOverscrollGesture() && |
| 1127 !gesture_event_filter_->ShouldForward( | 1128 !gesture_event_filter_->ShouldForward( |
| 1128 GestureEventWithLatencyInfo(gesture_event, latency_info))) { | 1129 GestureEventWithLatencyInfo(gesture_event, latency_info))) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, | 1290 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
| 1290 GetLatencyComponentId(), | 1291 GetLatencyComponentId(), |
| 1291 ++last_input_number_); | 1292 ++last_input_number_); |
| 1292 return info; | 1293 return info; |
| 1293 } | 1294 } |
| 1294 | 1295 |
| 1295 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, | 1296 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, |
| 1296 int event_size, | 1297 int event_size, |
| 1297 const ui::LatencyInfo& latency_info, | 1298 const ui::LatencyInfo& latency_info, |
| 1298 bool is_keyboard_shortcut) { | 1299 bool is_keyboard_shortcut) { |
| 1299 DCHECK(latency_info.HasLatencyComponent(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, | 1300 DCHECK(latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
| 1300 GetLatencyComponentId())); | 1301 GetLatencyComponentId(), |
| 1302 NULL)); | |
| 1301 input_event_start_time_ = TimeTicks::Now(); | 1303 input_event_start_time_ = TimeTicks::Now(); |
| 1302 Send(new InputMsg_HandleInputEvent( | 1304 Send(new InputMsg_HandleInputEvent( |
| 1303 routing_id_, &input_event, latency_info, is_keyboard_shortcut)); | 1305 routing_id_, &input_event, latency_info, is_keyboard_shortcut)); |
| 1304 increment_in_flight_event_count(); | 1306 increment_in_flight_event_count(); |
| 1305 } | 1307 } |
| 1306 | 1308 |
| 1307 void RenderWidgetHostImpl::ForwardInputEvent( | 1309 void RenderWidgetHostImpl::ForwardInputEvent( |
| 1308 const WebInputEvent& input_event, int event_size, | 1310 const WebInputEvent& input_event, int event_size, |
| 1309 const ui::LatencyInfo& latency_info, bool is_keyboard_shortcut) { | 1311 const ui::LatencyInfo& latency_info, bool is_keyboard_shortcut) { |
| 1310 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardInputEvent"); | 1312 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardInputEvent"); |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2577 if (!should_auto_resize_) | 2579 if (!should_auto_resize_) |
| 2578 return; | 2580 return; |
| 2579 | 2581 |
| 2580 OnRenderAutoResized(new_size); | 2582 OnRenderAutoResized(new_size); |
| 2581 } | 2583 } |
| 2582 | 2584 |
| 2583 void RenderWidgetHostImpl::DetachDelegate() { | 2585 void RenderWidgetHostImpl::DetachDelegate() { |
| 2584 delegate_ = NULL; | 2586 delegate_ = NULL; |
| 2585 } | 2587 } |
| 2586 | 2588 |
| 2589 void RenderWidgetHostImpl::ComputeTouchLatency( | |
| 2590 const ui::LatencyInfo& latency_info) { | |
| 2591 ui::LatencyInfo::LatencyComponent ui_component; | |
| 2592 ui::LatencyInfo::LatencyComponent rwh_component; | |
| 2593 ui::LatencyInfo::LatencyComponent acked_component; | |
| 2594 | |
| 2595 if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, | |
| 2596 0, | |
| 2597 &ui_component) || | |
| 2598 !latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, | |
| 2599 GetLatencyComponentId(), | |
| 2600 &rwh_component)) | |
| 2601 return; | |
| 2602 | |
| 2603 DCHECK(ui_component.event_count == 1); | |
| 2604 DCHECK(rwh_component.event_count == 1); | |
| 2605 | |
| 2606 base::TimeDelta ui_delta = | |
| 2607 rwh_component.event_time - ui_component.event_time; | |
| 2608 rendering_stats_.touch_ui_count++; | |
| 2609 rendering_stats_.total_touch_ui_latency += ui_delta; | |
| 2610 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 2611 "Event.Latency.Browser.TouchUI", | |
| 2612 ui_delta.InMicroseconds(), | |
| 2613 0, | |
| 2614 20000, | |
| 2615 100); | |
| 2616 | |
| 2617 if(!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT, | |
|
sadrul
2013/06/27 22:40:12
ifspace(
Yufeng Shen (Slow to review)
2013/06/27 23:44:07
Done.
| |
| 2618 0, | |
| 2619 &acked_component)) | |
| 2620 return; | |
|
sadrul
2013/06/27 22:40:12
Do you not want to send the IPC below in this case
Yufeng Shen (Slow to review)
2013/06/27 23:44:07
right, done.
| |
| 2621 DCHECK(acked_component.event_count == 1); | |
| 2622 base::TimeDelta acked_delta = | |
| 2623 acked_component.event_time - rwh_component.event_time; | |
| 2624 rendering_stats_.touch_acked_count++; | |
| 2625 rendering_stats_.total_touch_acked_latency += acked_delta; | |
| 2626 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 2627 "Event.Latency.Browser.TouchAcked", | |
| 2628 acked_delta.InMicroseconds(), | |
| 2629 0, | |
| 2630 1000000, | |
| 2631 100); | |
| 2632 | |
| 2633 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2634 switches::kEnableGpuBenchmarking)) | |
| 2635 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | |
|
sadrul
2013/06/27 22:40:12
I don't know what this does. I will leave this par
| |
| 2636 } | |
| 2637 | |
| 2587 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { | 2638 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
| 2588 ui::LatencyInfo::LatencyMap::const_iterator l = | 2639 ui::LatencyInfo::LatencyMap::const_iterator l = |
| 2589 latency_info.latency_components.find(std::make_pair( | 2640 latency_info.latency_components.find(std::make_pair( |
| 2590 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); | 2641 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); |
| 2591 if (l == latency_info.latency_components.end()) | 2642 if (l == latency_info.latency_components.end()) |
| 2592 return; | 2643 return; |
| 2593 | 2644 |
| 2594 rendering_stats_.input_event_count += l->second.event_count; | 2645 rendering_stats_.input_event_count += l->second.event_count; |
| 2595 rendering_stats_.total_input_latency += | 2646 rendering_stats_.total_input_latency += |
| 2596 l->second.event_count * | 2647 l->second.event_count * |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2615 int process_id = (b->first.second >> 32) & 0xffffffff; | 2666 int process_id = (b->first.second >> 32) & 0xffffffff; |
| 2616 RenderWidgetHost* rwh = | 2667 RenderWidgetHost* rwh = |
| 2617 RenderWidgetHost::FromID(process_id, routing_id); | 2668 RenderWidgetHost::FromID(process_id, routing_id); |
| 2618 if (!rwh) | 2669 if (!rwh) |
| 2619 continue; | 2670 continue; |
| 2620 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2671 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
| 2621 } | 2672 } |
| 2622 } | 2673 } |
| 2623 | 2674 |
| 2624 } // namespace content | 2675 } // namespace content |
| OLD | NEW |