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

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

Issue 16213002: Add telemetry to track the time an event spent waiting for the main thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 4 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 | Annotate | Revision Log
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 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 InputEventAckState ack_result) { 2093 InputEventAckState ack_result) {
2094 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 2094 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
2095 if (overscroll_controller_) 2095 if (overscroll_controller_)
2096 overscroll_controller_->ReceivedEventACK(wheel_event, processed); 2096 overscroll_controller_->ReceivedEventACK(wheel_event, processed);
2097 2097
2098 if (!processed && !is_hidden() && view_) 2098 if (!processed && !is_hidden() && view_)
2099 view_->UnhandledWheelEvent(wheel_event); 2099 view_->UnhandledWheelEvent(wheel_event);
2100 } 2100 }
2101 2101
2102 void RenderWidgetHostImpl::OnGestureEventAck( 2102 void RenderWidgetHostImpl::OnGestureEventAck(
2103 const WebKit::WebGestureEvent& event, 2103 const GestureEventWithLatencyInfo& event,
2104 InputEventAckState ack_result) { 2104 InputEventAckState ack_result) {
2105 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 2105 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
2106 if (overscroll_controller_) 2106 if (overscroll_controller_)
2107 overscroll_controller_->ReceivedEventACK(event, processed); 2107 overscroll_controller_->ReceivedEventACK(event.event, processed);
2108 2108
2109 if (view_) 2109 if (view_)
2110 view_->GestureEventAck(event.type, ack_result); 2110 view_->GestureEventAck(event.event.type, ack_result);
2111
2112 UpdateRenderingStatsForImplThreadLatency(event.event.type, event.latency);
2111 } 2113 }
2112 2114
2113 void RenderWidgetHostImpl::OnTouchEventAck( 2115 void RenderWidgetHostImpl::OnTouchEventAck(
2114 const TouchEventWithLatencyInfo& event, 2116 const TouchEventWithLatencyInfo& event,
2115 InputEventAckState ack_result) { 2117 InputEventAckState ack_result) {
2116 ComputeTouchLatency(event.latency); 2118 ComputeTouchLatency(event.latency);
2117 if (view_) 2119 if (view_)
2118 view_->ProcessAckedTouchEvent(event, ack_result); 2120 view_->ProcessAckedTouchEvent(event, ack_result);
2119 } 2121 }
2120 2122
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 // Clear the new_auto_size_ since the empty value is used as a flag to 2359 // Clear the new_auto_size_ since the empty value is used as a flag to
2358 // indicate that no callback is in progress (i.e. without this line 2360 // indicate that no callback is in progress (i.e. without this line
2359 // DelayedAutoResized will not get called again). 2361 // DelayedAutoResized will not get called again).
2360 new_auto_size_.SetSize(0, 0); 2362 new_auto_size_.SetSize(0, 0);
2361 if (!should_auto_resize_) 2363 if (!should_auto_resize_)
2362 return; 2364 return;
2363 2365
2364 OnRenderAutoResized(new_size); 2366 OnRenderAutoResized(new_size);
2365 } 2367 }
2366 2368
2369 void RenderWidgetHostImpl::UpdateRenderingStatsForImplThreadLatency(
nduca 2013/08/15 01:41:04 I'd like to see you modify enough of the input rou
2370 WebKit::WebInputEvent::Type type,
2371 const ui::LatencyInfo& latency_info) {
2372 ui::LatencyInfo::LatencyComponent dispatch_component;
2373 ui::LatencyInfo::LatencyComponent receive_component;
2374 if (!latency_info.FindLatency(
2375 ui::INPUT_EVENT_LATENCY_EVENT_SENT_FROM_IMPL_THREAD_COMPONENT,
2376 routing_id_, &dispatch_component) ||
2377 !latency_info.FindLatency(
2378 ui::INPUT_EVENT_LATENCY_EVENT_RECEIVED_ON_MAIN_THREAD_COMPONENT,
2379 routing_id_, &receive_component))
2380 return;
2381
2382 bool stats_changed = false;
2383 if (WebKit::WebInputEvent::isTouchEventType(type)) {
2384 rendering_stats_.total_impl_to_main_touch_event_latency +=
2385 (receive_component.event_time - dispatch_component.event_time);
2386 rendering_stats_.impl_to_main_touch_event_count++;
2387 stats_changed = true;
2388 } else if (type == WebKit::WebInputEvent::GestureScrollBegin ||
2389 type == WebKit::WebInputEvent::GestureScrollUpdate ||
2390 type == WebKit::WebInputEvent::GestureScrollUpdateWithoutPropagation) {
2391 rendering_stats_.total_impl_to_main_gesture_scroll_event_latency +=
2392 (receive_component.event_time - dispatch_component.event_time);
2393 rendering_stats_.impl_to_main_gesture_scroll_event_count++;
2394 stats_changed = true;
2395 }
2396
2397 if (stats_changed && CommandLine::ForCurrentProcess()->HasSwitch(
2398 switches::kEnableGpuBenchmarking))
2399 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_));
2400 }
2401
2367 void RenderWidgetHostImpl::DetachDelegate() { 2402 void RenderWidgetHostImpl::DetachDelegate() {
2368 delegate_ = NULL; 2403 delegate_ = NULL;
2369 } 2404 }
2370 2405
2371 void RenderWidgetHostImpl::ComputeTouchLatency( 2406 void RenderWidgetHostImpl::ComputeTouchLatency(
2372 const ui::LatencyInfo& latency_info) { 2407 const ui::LatencyInfo& latency_info) {
2373 ui::LatencyInfo::LatencyComponent ui_component; 2408 ui::LatencyInfo::LatencyComponent ui_component;
2374 ui::LatencyInfo::LatencyComponent rwh_component; 2409 ui::LatencyInfo::LatencyComponent rwh_component;
2375 ui::LatencyInfo::LatencyComponent acked_component; 2410 ui::LatencyInfo::LatencyComponent acked_component;
2376 2411
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 int process_id = (b->first.second >> 32) & 0xffffffff; 2511 int process_id = (b->first.second >> 32) & 0xffffffff;
2477 RenderWidgetHost* rwh = 2512 RenderWidgetHost* rwh =
2478 RenderWidgetHost::FromID(process_id, routing_id); 2513 RenderWidgetHost::FromID(process_id, routing_id);
2479 if (!rwh) 2514 if (!rwh)
2480 continue; 2515 continue;
2481 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2516 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2482 } 2517 }
2483 } 2518 }
2484 2519
2485 } // namespace content 2520 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698