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 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2179 if (delegate_ && !processed && !is_hidden() && !event.skip_in_browser) { | 2179 if (delegate_ && !processed && !is_hidden() && !event.skip_in_browser) { |
| 2180 delegate_->HandleKeyboardEvent(event); | 2180 delegate_->HandleKeyboardEvent(event); |
| 2181 | 2181 |
| 2182 // WARNING: This RenderWidgetHostImpl can be deallocated at this point | 2182 // WARNING: This RenderWidgetHostImpl can be deallocated at this point |
| 2183 // (i.e. in the case of Ctrl+W, where the call to | 2183 // (i.e. in the case of Ctrl+W, where the call to |
| 2184 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). | 2184 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). |
| 2185 } | 2185 } |
| 2186 } | 2186 } |
| 2187 | 2187 |
| 2188 void RenderWidgetHostImpl::OnWheelEventAck( | 2188 void RenderWidgetHostImpl::OnWheelEventAck( |
| 2189 const WebKit::WebMouseWheelEvent& wheel_event, | 2189 const MouseWheelEventWithLatencyInfo& event, |
|
jdduke (slow)
2013/10/01 23:45:31
See my comment below about making Report() const.
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
As to Nat's suggestion, removed the Report() funct
| |
| 2190 InputEventAckState ack_result) { | 2190 InputEventAckState ack_result) { |
| 2191 ui::LatencyInfo latency = event.latency; | |
| 2192 latency.Report(ui::INPUT_EVENT_LATENCY_ACKED_MOUSE_COMPONENT); | |
| 2191 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 2193 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); |
| 2192 if (overscroll_controller_) | 2194 if (overscroll_controller_) |
| 2193 overscroll_controller_->ReceivedEventACK(wheel_event, processed); | 2195 overscroll_controller_->ReceivedEventACK(event.event, processed); |
| 2194 | |
| 2195 if (!processed && !is_hidden() && view_) | 2196 if (!processed && !is_hidden() && view_) |
| 2196 view_->UnhandledWheelEvent(wheel_event); | 2197 view_->UnhandledWheelEvent(event.event); |
| 2197 } | 2198 } |
| 2198 | 2199 |
| 2199 void RenderWidgetHostImpl::OnGestureEventAck( | 2200 void RenderWidgetHostImpl::OnGestureEventAck( |
| 2200 const WebKit::WebGestureEvent& event, | 2201 const GestureEventWithLatencyInfo& event, |
| 2201 InputEventAckState ack_result) { | 2202 InputEventAckState ack_result) { |
| 2203 ui::LatencyInfo latency = event.latency; | |
| 2204 latency.Report(ui::INPUT_EVENT_LATENCY_ACKED_GESTURE_COMPONENT); | |
| 2202 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 2205 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); |
| 2203 if (overscroll_controller_) | 2206 if (overscroll_controller_) |
| 2204 overscroll_controller_->ReceivedEventACK(event, processed); | 2207 overscroll_controller_->ReceivedEventACK(event.event, processed); |
| 2205 | |
| 2206 if (view_) | 2208 if (view_) |
| 2207 view_->GestureEventAck(event.type, ack_result); | 2209 view_->GestureEventAck(event.event.type, ack_result); |
| 2208 } | 2210 } |
| 2209 | 2211 |
| 2210 void RenderWidgetHostImpl::OnTouchEventAck( | 2212 void RenderWidgetHostImpl::OnTouchEventAck( |
| 2211 const TouchEventWithLatencyInfo& event, | 2213 const TouchEventWithLatencyInfo& event, |
| 2212 InputEventAckState ack_result) { | 2214 InputEventAckState ack_result) { |
| 2215 ui::LatencyInfo* latency = const_cast<ui::LatencyInfo*>(&(event.latency)); | |
|
jdduke (slow)
2013/10/01 23:45:31
Again, if Report() was const we could do away with
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
ditto
jdduke (slow)
2013/10/04 02:22:19
Sorry, I didn't mean to say we should start passin
Yufeng Shen (Slow to review)
2013/10/04 18:03:02
So in the new patch I switch to passing both const
| |
| 2216 latency->Report(ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT); | |
| 2213 ComputeTouchLatency(event.latency); | 2217 ComputeTouchLatency(event.latency); |
| 2214 if (view_) | 2218 if (view_) |
| 2215 view_->ProcessAckedTouchEvent(event, ack_result); | 2219 view_->ProcessAckedTouchEvent(event, ack_result); |
| 2216 } | 2220 } |
| 2217 | 2221 |
| 2218 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { | 2222 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { |
| 2219 if (type == BAD_ACK_MESSAGE) { | 2223 if (type == BAD_ACK_MESSAGE) { |
| 2220 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); | 2224 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); |
| 2221 process_->ReceivedBadMessage(); | 2225 process_->ReceivedBadMessage(); |
| 2222 } else if (type == UNEXPECTED_EVENT_TYPE) { | 2226 } else if (type == UNEXPECTED_EVENT_TYPE) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2506 rwh_component.event_time - ui_component.event_time; | 2510 rwh_component.event_time - ui_component.event_time; |
| 2507 rendering_stats_.touch_ui_count++; | 2511 rendering_stats_.touch_ui_count++; |
| 2508 rendering_stats_.total_touch_ui_latency += ui_delta; | 2512 rendering_stats_.total_touch_ui_latency += ui_delta; |
| 2509 UMA_HISTOGRAM_CUSTOM_COUNTS( | 2513 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 2510 "Event.Latency.Browser.TouchUI", | 2514 "Event.Latency.Browser.TouchUI", |
| 2511 ui_delta.InMicroseconds(), | 2515 ui_delta.InMicroseconds(), |
| 2512 0, | 2516 0, |
| 2513 20000, | 2517 20000, |
| 2514 100); | 2518 100); |
| 2515 | 2519 |
| 2516 if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT, | 2520 if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, |
| 2517 0, | 2521 0, |
| 2518 &acked_component)) { | 2522 &acked_component)) { |
| 2519 DCHECK(acked_component.event_count == 1); | 2523 DCHECK(acked_component.event_count == 1); |
| 2520 base::TimeDelta acked_delta = | 2524 base::TimeDelta acked_delta = |
| 2521 acked_component.event_time - rwh_component.event_time; | 2525 acked_component.event_time - rwh_component.event_time; |
| 2522 rendering_stats_.touch_acked_count++; | 2526 rendering_stats_.touch_acked_count++; |
| 2523 rendering_stats_.total_touch_acked_latency += acked_delta; | 2527 rendering_stats_.total_touch_acked_latency += acked_delta; |
| 2524 UMA_HISTOGRAM_CUSTOM_COUNTS( | 2528 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 2525 "Event.Latency.Browser.TouchAcked", | 2529 "Event.Latency.Browser.TouchAcked", |
| 2526 acked_delta.InMicroseconds(), | 2530 acked_delta.InMicroseconds(), |
| 2527 0, | 2531 0, |
| 2528 1000000, | 2532 1000000, |
| 2529 100); | 2533 100); |
| 2530 } | 2534 } |
| 2531 | 2535 |
| 2532 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2536 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2533 switches::kEnableGpuBenchmarking)) | 2537 switches::kEnableGpuBenchmarking)) |
| 2534 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2538 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
| 2535 } | 2539 } |
| 2536 | 2540 |
| 2537 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { | 2541 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
| 2538 ui::LatencyInfo::LatencyComponent rwh_component; | 2542 ui::LatencyInfo::LatencyComponent rwh_component; |
|
jdduke (slow)
2013/10/01 23:45:31
Hmm, I thought we had moved these calculations/upd
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
Yeah, I wasn't able to land that. But eventually w
| |
| 2543 ui::LatencyInfo::LatencyComponent swap_component; | |
| 2539 if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, | 2544 if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, |
| 2540 GetLatencyComponentId(), | 2545 GetLatencyComponentId(), |
| 2541 &rwh_component)) | 2546 &rwh_component) || |
| 2547 !latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT, | |
| 2548 0, &swap_component)) { | |
| 2542 return; | 2549 return; |
| 2550 } | |
| 2543 | 2551 |
| 2544 rendering_stats_.input_event_count += rwh_component.event_count; | 2552 rendering_stats_.input_event_count += rwh_component.event_count; |
| 2545 rendering_stats_.total_input_latency += | 2553 rendering_stats_.total_input_latency += |
| 2546 rwh_component.event_count * | 2554 rwh_component.event_count * |
| 2547 (latency_info.swap_timestamp - rwh_component.event_time); | 2555 (swap_component.event_time - rwh_component.event_time); |
| 2548 | 2556 |
| 2549 ui::LatencyInfo::LatencyComponent original_component; | 2557 ui::LatencyInfo::LatencyComponent original_component; |
| 2550 if (latency_info.FindLatency( | 2558 if (latency_info.FindLatency( |
| 2551 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 2559 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 2552 GetLatencyComponentId(), | 2560 GetLatencyComponentId(), |
| 2553 &original_component)) { | 2561 &original_component)) { |
| 2554 // This UMA metric tracks the time from when the original touch event is | 2562 // This UMA metric tracks the time from when the original touch event is |
| 2555 // created (averaged if there are multiple) to when the scroll gesture | 2563 // created (averaged if there are multiple) to when the scroll gesture |
| 2556 // results in final frame swap. | 2564 // results in final frame swap. |
| 2557 base::TimeDelta delta = | 2565 base::TimeDelta delta = |
| 2558 latency_info.swap_timestamp - original_component.event_time; | 2566 swap_component.event_time - original_component.event_time; |
| 2559 for (size_t i = 0; i < original_component.event_count; i++) { | 2567 for (size_t i = 0; i < original_component.event_count; i++) { |
| 2560 UMA_HISTOGRAM_CUSTOM_COUNTS( | 2568 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 2561 "Event.Latency.TouchToScrollUpdateSwap", | 2569 "Event.Latency.TouchToScrollUpdateSwap", |
| 2562 delta.InMicroseconds(), | 2570 delta.InMicroseconds(), |
| 2563 0, | 2571 0, |
| 2564 1000000, | 2572 1000000, |
| 2565 100); | 2573 100); |
| 2566 } | 2574 } |
| 2567 rendering_stats_.scroll_update_count += original_component.event_count; | 2575 rendering_stats_.scroll_update_count += original_component.event_count; |
| 2568 rendering_stats_.total_scroll_update_latency += | 2576 rendering_stats_.total_scroll_update_latency += |
| 2569 original_component.event_count * | 2577 original_component.event_count * |
| 2570 (latency_info.swap_timestamp - original_component.event_time); | 2578 (swap_component.event_time - original_component.event_time); |
| 2571 } | 2579 } |
| 2572 | 2580 |
| 2573 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2581 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2574 switches::kEnableGpuBenchmarking)) | 2582 switches::kEnableGpuBenchmarking)) |
| 2575 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); | 2583 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_)); |
| 2576 } | 2584 } |
| 2577 | 2585 |
| 2578 void RenderWidgetHostImpl::DidReceiveRendererFrame() { | 2586 void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
| 2579 view_->DidReceiveRendererFrame(); | 2587 view_->DidReceiveRendererFrame(); |
| 2580 } | 2588 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2593 int process_id = (b->first.second >> 32) & 0xffffffff; | 2601 int process_id = (b->first.second >> 32) & 0xffffffff; |
| 2594 RenderWidgetHost* rwh = | 2602 RenderWidgetHost* rwh = |
| 2595 RenderWidgetHost::FromID(process_id, routing_id); | 2603 RenderWidgetHost::FromID(process_id, routing_id); |
| 2596 if (!rwh) | 2604 if (!rwh) |
| 2597 continue; | 2605 continue; |
| 2598 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2606 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
| 2599 } | 2607 } |
| 2600 } | 2608 } |
| 2601 | 2609 |
| 2602 } // namespace content | 2610 } // namespace content |
| OLD | NEW |