Commit 128d1c67 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

latency: Stop using a component-id for BEGIN_RWH component.

The component-id for BEGIN_RWH component is currently generated from the
process-id and routing-id of the associated RenderWidgetHostImpl, so
that it is possible to find the RenderWidgetHostImpl from the
LatencyInfo after gpu-swap happens. However, the BEGIN_RWH component is
unused at that time (only LatencyInfos that have snapshot requests are
processed after gpu-swap, and the snapshot requests already carry the
identifier for the RenderWidgetHostImpl separately), except for in a
test. So, the changes in this CL:
 . Use zero as the component-id for BEGIN_RWH component.
 . Introduce a SetLatencyInfoProcessorForTesting() method to install a
   callback that receives all the LatencyInfo after a gpu-swap happens,
   and use that in the tests that needed this.

BUG=849729

Change-Id: I19beb790931cfe8e708d0eb4223a3ba23d51e4c1
Reviewed-on: https://chromium-review.googlesource.com/1089583Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565488}
parent b587039b
...@@ -83,11 +83,18 @@ class TracingRenderWidgetHost : public RenderWidgetHostImpl { ...@@ -83,11 +83,18 @@ class TracingRenderWidgetHost : public RenderWidgetHostImpl {
process, process,
routing_id, routing_id,
std::move(widget), std::move(widget),
hidden) {} hidden) {
void OnGpuSwapBuffersCompletedInternal( SetLatencyInfoProcessorForTesting(base::BindRepeating(
const ui::LatencyInfo& latency_info) override { &TracingRenderWidgetHost::HandleLatencyInfoAfterGpuSwap,
RenderWidgetHostImpl::OnGpuSwapBuffersCompletedInternal(latency_info); base::Unretained(this)));
RunClosureIfNecessary(latency_info); }
void HandleLatencyInfoAfterGpuSwap(
const std::vector<ui::LatencyInfo>& latency_infos) {
for (const auto& latency_info : latency_infos) {
if (latency_info.terminated())
RunClosureIfNecessary(latency_info);
}
} }
void OnMouseEventAck(const MouseEventWithLatencyInfo& event, void OnMouseEventAck(const MouseEventWithLatencyInfo& event,
......
...@@ -57,7 +57,6 @@ void RenderWidgetHostLatencyTracker::Initialize(int routing_id, ...@@ -57,7 +57,6 @@ void RenderWidgetHostLatencyTracker::Initialize(int routing_id,
void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms( void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms(
WebInputEvent::Type type, WebInputEvent::Type type,
int64_t latency_component_id,
const LatencyInfo& latency, const LatencyInfo& latency,
InputEventAckState ack_result) { InputEventAckState ack_result) {
// If this event was coalesced into another event, ignore it, as the event it // If this event was coalesced into another event, ignore it, as the event it
...@@ -73,9 +72,8 @@ void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms( ...@@ -73,9 +72,8 @@ void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms(
// The event will have gone through OnInputEvent(). So the BEGIN_RWH component // The event will have gone through OnInputEvent(). So the BEGIN_RWH component
// should always be available here. // should always be available here.
LatencyInfo::LatencyComponent rwh_component; LatencyInfo::LatencyComponent rwh_component;
bool found_component = bool found_component = latency.FindLatency(
latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, &rwh_component);
latency_component_id, &rwh_component);
DCHECK(found_component); DCHECK(found_component);
DCHECK_EQ(rwh_component.event_count, 1u); DCHECK_EQ(rwh_component.event_count, 1u);
...@@ -150,9 +148,8 @@ void RenderWidgetHostLatencyTracker::OnInputEvent( ...@@ -150,9 +148,8 @@ void RenderWidgetHostLatencyTracker::OnInputEvent(
// This is the only place to add the BEGIN_RWH component. So this component // This is the only place to add the BEGIN_RWH component. So this component
// should not already be present in the latency info. // should not already be present in the latency info.
bool found_component = bool found_component = latency->FindLatency(
latency->FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, nullptr);
latency_component_id_, nullptr);
DCHECK(!found_component); DCHECK(!found_component);
if (!event.TimeStamp().is_null() && if (!event.TimeStamp().is_null() &&
...@@ -176,7 +173,7 @@ void RenderWidgetHostLatencyTracker::OnInputEvent( ...@@ -176,7 +173,7 @@ void RenderWidgetHostLatencyTracker::OnInputEvent(
} }
latency->AddLatencyNumberWithTraceName( latency->AddLatencyNumberWithTraceName(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, latency_component_id_, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
WebInputEvent::GetName(event.GetType())); WebInputEvent::GetName(event.GetType()));
if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin) { if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin) {
...@@ -234,8 +231,7 @@ void RenderWidgetHostLatencyTracker::OnInputEventAck( ...@@ -234,8 +231,7 @@ void RenderWidgetHostLatencyTracker::OnInputEventAck(
latency->Terminate(); latency->Terminate();
} }
ComputeInputLatencyHistograms(event.GetType(), latency_component_id_, ComputeInputLatencyHistograms(event.GetType(), *latency, ack_result);
*latency, ack_result);
} }
void RenderWidgetHostLatencyTracker::OnEventStart(ui::LatencyInfo* latency) { void RenderWidgetHostLatencyTracker::OnEventStart(ui::LatencyInfo* latency) {
......
...@@ -32,7 +32,6 @@ class CONTENT_EXPORT RenderWidgetHostLatencyTracker { ...@@ -32,7 +32,6 @@ class CONTENT_EXPORT RenderWidgetHostLatencyTracker {
void Initialize(int routing_id, int process_id); void Initialize(int routing_id, int process_id);
void ComputeInputLatencyHistograms(blink::WebInputEvent::Type type, void ComputeInputLatencyHistograms(blink::WebInputEvent::Type type,
int64_t latency_component_id,
const ui::LatencyInfo& latency, const ui::LatencyInfo& latency,
InputEventAckState ack_result); InputEventAckState ack_result);
......
...@@ -180,8 +180,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestValidEventTiming) { ...@@ -180,8 +180,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestValidEventTiming) {
now + base::TimeDelta::FromMilliseconds(30), 1); now + base::TimeDelta::FromMilliseconds(30), 1);
latency_info.AddLatencyNumberWithTimestamp( latency_info.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
now + base::TimeDelta::FromMilliseconds(20), 1); now + base::TimeDelta::FromMilliseconds(20), 1);
latency_info.AddLatencyNumberWithTimestamp( latency_info.AddLatencyNumberWithTimestamp(
...@@ -234,8 +233,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) { ...@@ -234,8 +233,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) {
AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
tracker()->OnInputEvent(wheel, &wheel_latency); tracker()->OnInputEvent(wheel, &wheel_latency);
EXPECT_TRUE(wheel_latency.FindLatency( EXPECT_TRUE(wheel_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(wheel_latency.FindLatency( EXPECT_TRUE(wheel_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(wheel, &wheel_latency, tracker()->OnInputEventAck(wheel, &wheel_latency,
...@@ -346,8 +344,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) { ...@@ -346,8 +344,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) {
AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
tracker()->OnInputEvent(wheel, &wheel_latency); tracker()->OnInputEvent(wheel, &wheel_latency);
EXPECT_TRUE(wheel_latency.FindLatency( EXPECT_TRUE(wheel_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(wheel_latency.FindLatency( EXPECT_TRUE(wheel_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(wheel, &wheel_latency, tracker()->OnInputEventAck(wheel, &wheel_latency,
...@@ -458,8 +455,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestInertialToScrollHistograms) { ...@@ -458,8 +455,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestInertialToScrollHistograms) {
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency); tracker()->OnInputEvent(scroll, &scroll_latency);
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(scroll, &scroll_latency, tracker()->OnInputEventAck(scroll, &scroll_latency,
...@@ -518,8 +514,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) { ...@@ -518,8 +514,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency); tracker()->OnInputEvent(scroll, &scroll_latency);
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(scroll, &scroll_latency, tracker()->OnInputEventAck(scroll, &scroll_latency,
...@@ -539,8 +534,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) { ...@@ -539,8 +534,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
tracker()->OnInputEvent(touch, &touch_latency); tracker()->OnInputEvent(touch, &touch_latency);
EXPECT_TRUE(touch_latency.FindLatency( EXPECT_TRUE(touch_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(touch_latency.FindLatency( EXPECT_TRUE(touch_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(touch, &touch_latency, tracker()->OnInputEventAck(touch, &touch_latency,
...@@ -632,8 +626,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) { ...@@ -632,8 +626,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) {
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency); tracker()->OnInputEvent(scroll, &scroll_latency);
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(scroll, &scroll_latency, tracker()->OnInputEventAck(scroll, &scroll_latency,
...@@ -653,8 +646,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) { ...@@ -653,8 +646,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) {
AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
tracker()->OnInputEvent(touch, &touch_latency); tracker()->OnInputEvent(touch, &touch_latency);
EXPECT_TRUE(touch_latency.FindLatency( EXPECT_TRUE(touch_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(touch_latency.FindLatency( EXPECT_TRUE(touch_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
tracker()->OnInputEventAck(touch, &touch_latency, tracker()->OnInputEventAck(touch, &touch_latency,
...@@ -836,9 +828,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { ...@@ -836,9 +828,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
0); 0);
tracker()->OnInputEvent(scroll_begin, &scroll_latency); tracker()->OnInputEvent(scroll_begin, &scroll_latency);
EXPECT_TRUE( EXPECT_TRUE(scroll_latency.FindLatency(
scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_EQ(2U, scroll_latency.latency_components().size()); EXPECT_EQ(2U, scroll_latency.latency_components().size());
// The first GestureScrollUpdate should be provided with // The first GestureScrollUpdate should be provided with
...@@ -849,9 +840,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { ...@@ -849,9 +840,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
0); 0);
tracker()->OnInputEvent(first_scroll_update, &scroll_latency); tracker()->OnInputEvent(first_scroll_update, &scroll_latency);
EXPECT_TRUE( EXPECT_TRUE(scroll_latency.FindLatency(
scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_TRUE(scroll_latency.FindLatency( EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), nullptr)); tracker()->latency_component_id(), nullptr));
...@@ -868,9 +858,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { ...@@ -868,9 +858,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, scroll_latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
0); 0);
tracker()->OnInputEvent(scroll_update, &scroll_latency); tracker()->OnInputEvent(scroll_update, &scroll_latency);
EXPECT_TRUE( EXPECT_TRUE(scroll_latency.FindLatency(
scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_FALSE(scroll_latency.FindLatency( EXPECT_FALSE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), nullptr)); tracker()->latency_component_id(), nullptr));
...@@ -901,8 +890,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -901,8 +890,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
fake_latency.set_trace_id(kTraceEventId); fake_latency.set_trace_id(kTraceEventId);
fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
fake_latency.AddLatencyNumberWithTimestamp( fake_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
1); 1);
...@@ -921,9 +909,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -921,9 +909,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
// Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
// overwriting components. // overwriting components.
tracker()->ComputeInputLatencyHistograms( tracker()->ComputeInputLatencyHistograms(event.GetType(), fake_latency,
event.GetType(), tracker()->latency_component_id(), fake_latency, blocking);
blocking);
tracker()->OnInputEventAck(event, &latency, tracker()->OnInputEventAck(event, &latency,
blocking); blocking);
...@@ -938,9 +925,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -938,9 +925,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
EXPECT_TRUE(latency.FindLatency( EXPECT_TRUE(latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
EXPECT_TRUE( EXPECT_TRUE(latency.FindLatency(
latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_EQ(2U, latency.latency_components().size()); EXPECT_EQ(2U, latency.latency_components().size());
...@@ -948,8 +934,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -948,8 +934,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
fake_latency.set_trace_id(kTraceEventId); fake_latency.set_trace_id(kTraceEventId);
fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
fake_latency.AddLatencyNumberWithTimestamp( fake_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]), base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]),
1); 1);
...@@ -968,9 +953,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -968,9 +953,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
// Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
// overwriting components. // overwriting components.
tracker()->ComputeInputLatencyHistograms( tracker()->ComputeInputLatencyHistograms(event.GetType(), fake_latency,
event.GetType(), tracker()->latency_component_id(), fake_latency, blocking);
blocking);
} }
{ {
...@@ -982,9 +966,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -982,9 +966,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
EXPECT_TRUE(latency.FindLatency( EXPECT_TRUE(latency.FindLatency(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
EXPECT_TRUE( EXPECT_TRUE(latency.FindLatency(
latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
tracker()->latency_component_id(), nullptr));
EXPECT_EQ(2U, latency.latency_components().size()); EXPECT_EQ(2U, latency.latency_components().size());
...@@ -992,8 +975,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -992,8 +975,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
fake_latency.set_trace_id(kTraceEventId); fake_latency.set_trace_id(kTraceEventId);
fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
fake_latency.AddLatencyNumberWithTimestamp( fake_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]), base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]),
1); 1);
...@@ -1012,9 +994,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { ...@@ -1012,9 +994,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
// Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
// overwriting components. // overwriting components.
tracker()->ComputeInputLatencyHistograms( tracker()->ComputeInputLatencyHistograms(event.GetType(), fake_latency,
event.GetType(), tracker()->latency_component_id(), fake_latency, blocking);
blocking);
} }
} }
...@@ -1095,8 +1076,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, KeyBlockingAndQueueingTime) { ...@@ -1095,8 +1076,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, KeyBlockingAndQueueingTime) {
fake_latency.set_trace_id(kTraceEventId); fake_latency.set_trace_id(kTraceEventId);
fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS); fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
fake_latency.AddLatencyNumberWithTimestamp( fake_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]), base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]),
1); 1);
...@@ -1115,9 +1095,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, KeyBlockingAndQueueingTime) { ...@@ -1115,9 +1095,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, KeyBlockingAndQueueingTime) {
// Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
// overwriting components. // overwriting components.
tracker()->ComputeInputLatencyHistograms( tracker()->ComputeInputLatencyHistograms(event.GetType(), fake_latency,
event.GetType(), tracker()->latency_component_id(), fake_latency, blocking);
blocking);
tracker()->OnInputEventAck(event, &latency_info, blocking); tracker()->OnInputEventAck(event, &latency_info, blocking);
} }
...@@ -1155,8 +1134,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) { ...@@ -1155,8 +1134,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) {
1); 1);
latency_info.AddLatencyNumberWithTimestamp( latency_info.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1); 1);
...@@ -1208,8 +1186,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ...@@ -1208,8 +1186,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest,
ui::LatencyInfo fake_latency; ui::LatencyInfo fake_latency;
fake_latency.set_trace_id(kTraceEventId); fake_latency.set_trace_id(kTraceEventId);
fake_latency.AddLatencyNumberWithTimestamp( fake_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeTicks() +
base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
1); 1);
...@@ -1229,7 +1206,6 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ...@@ -1229,7 +1206,6 @@ TEST_F(RenderWidgetHostLatencyTrackerTest,
// Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
// overwriting components. // overwriting components.
tracker()->ComputeInputLatencyHistograms(event.GetType(), tracker()->ComputeInputLatencyHistograms(event.GetType(),
tracker()->latency_component_id(),
fake_latency, ack_state); fake_latency, ack_state);
tracker()->OnInputEventAck(event, &latency, ack_state); tracker()->OnInputEventAck(event, &latency, ack_state);
...@@ -1279,8 +1255,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, WheelDuringMultiFingerTouch) { ...@@ -1279,8 +1255,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, WheelDuringMultiFingerTouch) {
fake_latency.set_trace_id(kTraceEventId); fake_latency.set_trace_id(kTraceEventId);
fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
fake_latency.AddLatencyNumberWithTimestamp( fake_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0,
tracker()->latency_component_id(),
base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]), base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]),
1); 1);
...@@ -1297,7 +1272,6 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, WheelDuringMultiFingerTouch) { ...@@ -1297,7 +1272,6 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, WheelDuringMultiFingerTouch) {
// Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
// overwriting components. // overwriting components.
tracker()->ComputeInputLatencyHistograms(wheel_event.GetType(), tracker()->ComputeInputLatencyHistograms(wheel_event.GetType(),
tracker()->latency_component_id(),
fake_latency, ack_state); fake_latency, ack_state);
tracker()->OnInputEventAck(wheel_event, &latency, ack_state); tracker()->OnInputEventAck(wheel_event, &latency, ack_state);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -184,6 +185,12 @@ class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { ...@@ -184,6 +185,12 @@ class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator {
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostIteratorImpl); DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostIteratorImpl);
}; };
RenderWidgetHostImpl::LatencyInfoProcessor& GetLatencyInfoProcessor() {
static base::NoDestructor<RenderWidgetHostImpl::LatencyInfoProcessor>
processor;
return *processor;
}
inline blink::WebGestureEvent CreateScrollBeginForWrapping( inline blink::WebGestureEvent CreateScrollBeginForWrapping(
const blink::WebGestureEvent& gesture_event) { const blink::WebGestureEvent& gesture_event) {
DCHECK(gesture_event.GetType() == blink::WebInputEvent::kGestureScrollUpdate); DCHECK(gesture_event.GetType() == blink::WebInputEvent::kGestureScrollUpdate);
...@@ -1974,6 +1981,11 @@ bool RenderWidgetHostImpl::IsMouseLocked() const { ...@@ -1974,6 +1981,11 @@ bool RenderWidgetHostImpl::IsMouseLocked() const {
return view_ ? view_->IsMouseLocked() : false; return view_ ? view_->IsMouseLocked() : false;
} }
void RenderWidgetHostImpl::SetLatencyInfoProcessorForTesting(
const LatencyInfoProcessor& processor) {
GetLatencyInfoProcessor() = processor;
}
void RenderWidgetHostImpl::SetAutoResize(bool enable, void RenderWidgetHostImpl::SetAutoResize(bool enable,
const gfx::Size& min_size, const gfx::Size& min_size,
const gfx::Size& max_size) { const gfx::Size& max_size) {
...@@ -2056,7 +2068,7 @@ void RenderWidgetHostImpl::ClearDisplayedGraphics() { ...@@ -2056,7 +2068,7 @@ void RenderWidgetHostImpl::ClearDisplayedGraphics() {
view_->ClearCompositorFrame(); view_->ClearCompositorFrame();
} }
void RenderWidgetHostImpl::OnGpuSwapBuffersCompletedInternal( void RenderWidgetHostImpl::ProcessSnapshotResponses(
const ui::LatencyInfo& latency_info) { const ui::LatencyInfo& latency_info) {
// Note that a compromised renderer can send LatencyInfo to a // Note that a compromised renderer can send LatencyInfo to a
// RenderWidgetHostImpl other than its own. Be mindful of security // RenderWidgetHostImpl other than its own. Be mindful of security
...@@ -2745,20 +2757,17 @@ void RenderWidgetHostImpl::NotifyCorrespondingRenderWidgetHost( ...@@ -2745,20 +2757,17 @@ void RenderWidgetHostImpl::NotifyCorrespondingRenderWidgetHost(
return; return;
RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
if (notified_hosts.insert(rwhi).second) if (notified_hosts.insert(rwhi).second)
rwhi->OnGpuSwapBuffersCompletedInternal(latency_info); rwhi->ProcessSnapshotResponses(latency_info);
} }
// static // static
void RenderWidgetHostImpl::OnGpuSwapBuffersCompleted( void RenderWidgetHostImpl::OnGpuSwapBuffersCompleted(
const std::vector<ui::LatencyInfo>& latency_info) { const std::vector<ui::LatencyInfo>& latency_info) {
auto& callback = GetLatencyInfoProcessor();
if (!callback.is_null())
callback.Run(latency_info);
for (size_t i = 0; i < latency_info.size(); i++) { for (size_t i = 0; i < latency_info.size(); i++) {
std::set<RenderWidgetHostImpl*> rwhi_set; std::set<RenderWidgetHostImpl*> rwhi_set;
for (const auto& lc : latency_info[i].latency_components()) {
if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) {
NotifyCorrespondingRenderWidgetHost(lc.first.second, rwhi_set,
latency_info[i]);
}
}
for (const auto& snapshot : latency_info[i].Snapshots()) for (const auto& snapshot : latency_info[i].Snapshots())
NotifyCorrespondingRenderWidgetHost(snapshot.first, rwhi_set, NotifyCorrespondingRenderWidgetHost(snapshot.first, rwhi_set,
latency_info[i]); latency_info[i]);
......
...@@ -722,6 +722,11 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -722,6 +722,11 @@ class CONTENT_EXPORT RenderWidgetHostImpl
void GetContentRenderingTimeoutFrom(RenderWidgetHostImpl* other); void GetContentRenderingTimeoutFrom(RenderWidgetHostImpl* other);
using LatencyInfoProcessor =
base::RepeatingCallback<void(const std::vector<ui::LatencyInfo>&)>;
static void SetLatencyInfoProcessorForTesting(
const LatencyInfoProcessor& processor);
protected: protected:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// The following method is overridden by RenderViewHost to send upwards to // The following method is overridden by RenderViewHost to send upwards to
...@@ -731,9 +736,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl ...@@ -731,9 +736,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl
// from a newly loaded page. Used for testing. // from a newly loaded page. Used for testing.
virtual void NotifyNewContentRenderingTimeoutForTesting() {} virtual void NotifyNewContentRenderingTimeoutForTesting() {}
// Can be overriden for subclass based testing. void ProcessSnapshotResponses(const ui::LatencyInfo& latency_info);
virtual void OnGpuSwapBuffersCompletedInternal(
const ui::LatencyInfo& latency_info);
// InputAckHandler // InputAckHandler
void OnKeyboardEventAck(const NativeWebKeyboardEventWithLatencyInfo& event, void OnKeyboardEventAck(const NativeWebKeyboardEventWithLatencyInfo& event,
......
...@@ -2054,7 +2054,7 @@ void CheckLatencyInfoComponentInMessage( ...@@ -2054,7 +2054,7 @@ void CheckLatencyInfoComponentInMessage(
expected_type); expected_type);
EXPECT_TRUE( EXPECT_TRUE(
dispatched_events[0]->ToEvent()->Event()->latency_info.FindLatency( dispatched_events[0]->ToEvent()->Event()->latency_info.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, nullptr)); ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
dispatched_events[0]->ToEvent()->CallCallback(INPUT_EVENT_ACK_STATE_CONSUMED); dispatched_events[0]->ToEvent()->CallCallback(INPUT_EVENT_ACK_STATE_CONSUMED);
} }
...@@ -2071,7 +2071,7 @@ void CheckLatencyInfoComponentInGestureScrollUpdate( ...@@ -2071,7 +2071,7 @@ void CheckLatencyInfoComponentInGestureScrollUpdate(
dispatched_events[1]->ToEvent()->Event()->web_event->GetType()); dispatched_events[1]->ToEvent()->Event()->web_event->GetType());
EXPECT_TRUE( EXPECT_TRUE(
dispatched_events[1]->ToEvent()->Event()->latency_info.FindLatency( dispatched_events[1]->ToEvent()->Event()->latency_info.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, nullptr)); ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
dispatched_events[1]->ToEvent()->CallCallback(INPUT_EVENT_ACK_STATE_CONSUMED); dispatched_events[1]->ToEvent()->CallCallback(INPUT_EVENT_ACK_STATE_CONSUMED);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment