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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 681763003: Add input latency histograms for wheel events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ., indent, and XML Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 7e9dc75f05c4a6914b23cd0a17ce9ad73685cd20..b57899f331efdb358cceaee24379b784ee21d448 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -865,7 +865,7 @@ void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo(
ui::LatencyInfo::InputCoordinate logical_coordinate(mouse_event.x,
mouse_event.y);
- ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
+ ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist(
&ui_latency, mouse_event.type, &logical_coordinate, 1);
for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) {
@@ -899,7 +899,7 @@ void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
ui::LatencyInfo::InputCoordinate logical_coordinate(wheel_event.x,
wheel_event.y);
- ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
+ ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist(
&ui_latency, wheel_event.type, &logical_coordinate, 1);
if (IgnoreInputEvents())
@@ -931,7 +931,7 @@ void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo(
ui::LatencyInfo::InputCoordinate logical_coordinate(gesture_event.x,
gesture_event.y);
- ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
+ ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist(
&ui_latency, gesture_event.type, &logical_coordinate, 1);
if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate) {
@@ -974,7 +974,7 @@ void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
touch_event.touches[i].position.x, touch_event.touches[i].position.y);
}
- ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
+ ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist(
NULL, touch_event.type, logical_coordinates, logical_coordinates_size);
TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
input_router_->SendTouchEvent(touch_with_latency);
@@ -998,11 +998,11 @@ void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
touch_event.touches[i].position.x, touch_event.touches[i].position.y);
}
- ui::LatencyInfo latency_info =
- CreateRWHLatencyInfoIfNotExist(&ui_latency,
- touch_event.type,
- logical_coordinates,
- logical_coordinates_size);
+ ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist(
+ &ui_latency,
+ touch_event.type,
+ logical_coordinates,
+ logical_coordinates_size);
TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
if (touch_emulator_ &&
@@ -1083,7 +1083,7 @@ void RenderWidgetHostImpl::ForwardKeyboardEvent(
input_router_->SendKeyboardEvent(
key_event,
- CreateRWHLatencyInfoIfNotExist(NULL, key_event.type, NULL, 0),
+ CreateInputEventLatencyInfoIfNotExist(NULL, key_event.type, NULL, 0),
is_shortcut);
}
@@ -1116,7 +1116,7 @@ void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) {
Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible));
}
-int64 RenderWidgetHostImpl::GetLatencyComponentId() {
+int64 RenderWidgetHostImpl::GetLatencyComponentId() const {
return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32);
}
@@ -1125,7 +1125,7 @@ void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() {
g_check_for_pending_resize_ack = false;
}
-ui::LatencyInfo RenderWidgetHostImpl::CreateRWHLatencyInfoIfNotExist(
+ui::LatencyInfo RenderWidgetHostImpl::CreateInputEventLatencyInfoIfNotExist(
const ui::LatencyInfo* original,
WebInputEvent::Type type,
const ui::LatencyInfo::InputCoordinate* logical_coordinates,
@@ -1897,14 +1897,17 @@ void RenderWidgetHostImpl::OnKeyboardEventAck(
void RenderWidgetHostImpl::OnWheelEventAck(
const MouseWheelEventWithLatencyInfo& wheel_event,
InputEventAckState ack_result) {
+ ui::LatencyInfo latency = wheel_event.latency;
+ latency.AddLatencyNumber(
+ ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0);
if (!wheel_event.latency.FindLatency(
ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) {
// MouseWheelEvent latency ends when it is acked but does not cause any
// rendering scheduled.
- ui::LatencyInfo latency = wheel_event.latency;
latency.AddLatencyNumber(
ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0);
}
+ ComputeInputLatencyHistograms("Wheel", latency);
if (!is_hidden() && view_) {
if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED &&
@@ -1941,14 +1944,14 @@ void RenderWidgetHostImpl::OnTouchEventAck(
InputEventAckState ack_result) {
TouchEventWithLatencyInfo touch_event = event;
touch_event.latency.AddLatencyNumber(
- ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0);
+ ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0);
// TouchEvent latency ends at ack if it didn't cause any rendering.
if (!touch_event.latency.FindLatency(
ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) {
touch_event.latency.AddLatencyNumber(
ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0);
}
- ComputeTouchLatency(touch_event.latency);
+ ComputeInputLatencyHistograms("Touch", touch_event.latency);
if (touch_emulator_ &&
touch_emulator_->HandleTouchEventAck(event.event, ack_result)) {
@@ -2079,44 +2082,47 @@ void RenderWidgetHostImpl::DetachDelegate() {
delegate_ = NULL;
}
-void RenderWidgetHostImpl::ComputeTouchLatency(
- const ui::LatencyInfo& latency_info) {
- ui::LatencyInfo::LatencyComponent ui_component;
+void RenderWidgetHostImpl::ComputeInputLatencyHistograms(
+ const char* type,
+ const ui::LatencyInfo& latency_info) const {
ui::LatencyInfo::LatencyComponent rwh_component;
- ui::LatencyInfo::LatencyComponent acked_component;
-
- if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT,
- 0,
- &ui_component) ||
- !latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
+ if (!latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
GetLatencyComponentId(),
&rwh_component))
return;
-
- DCHECK(ui_component.event_count == 1);
DCHECK(rwh_component.event_count == 1);
- base::TimeDelta ui_delta =
- rwh_component.event_time - ui_component.event_time;
- UMA_HISTOGRAM_CUSTOM_COUNTS(
- "Event.Latency.Browser.TouchUI",
- ui_delta.InMicroseconds(),
- 1,
- 20000,
- 100);
+ ui::LatencyInfo::LatencyComponent ui_component;
+ if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_UI_COMPONENT,
+ 0,
+ &ui_component)) {
+ DCHECK(ui_component.event_count == 1);
+
+ base::TimeDelta ui_delta =
+ rwh_component.event_time - ui_component.event_time;
+ base::HistogramBase* counter_for_type = base::Histogram::FactoryGet(
+ base::StringPrintf("Event.Latency.Browser.%sUI", type),
+ 1,
+ 20000,
+ 100,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ counter_for_type->Add(ui_delta.InMicroseconds());
+ }
- if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT,
+ ui::LatencyInfo::LatencyComponent acked_component;
+ if (latency_info.FindLatency(ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT,
0,
&acked_component)) {
DCHECK(acked_component.event_count == 1);
base::TimeDelta acked_delta =
acked_component.event_time - rwh_component.event_time;
- UMA_HISTOGRAM_CUSTOM_COUNTS(
- "Event.Latency.Browser.TouchAcked",
- acked_delta.InMicroseconds(),
+ base::HistogramBase* counter_for_type = base::Histogram::FactoryGet(
+ base::StringPrintf("Event.Latency.Browser.%sAcked", type),
1,
1000000,
- 100);
+ 100,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ counter_for_type->Add(acked_delta.InMicroseconds());
}
}

Powered by Google App Engine
This is Rietveld 408576698