Commit 73387efb authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

latency: Remove the last non-zero component id.

Only SCROLL_UPDATE and FIRST_SCROLL_UPDATE components currently have
non-zero component ids. However, these component-ids are never used for
any purpose. So use zero as the component-id for these components. This
allows for the following cleanups:
 . RenderWidgetHostLatencyTracker no longer needs latency_component_id_.
 . Rename RenderWidgetHostImpl::GetLatencyComponentId() to a clearer
   name: GetFrameSinkIdForSnapshot().

BUG=849729

Change-Id: I7fea87d5cf1b06c580b6738816ffeb893063b1fb
Reviewed-on: https://chromium-review.googlesource.com/1089715
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565559}
parent 3f77a22e
......@@ -39,7 +39,6 @@ RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker(
RenderWidgetHostDelegate* delegate)
: ukm_source_id_(GenerateUkmSourceId()),
last_event_id_(0),
latency_component_id_(0),
has_seen_first_gesture_scroll_update_(false),
active_multi_finger_gesture_(false),
touch_start_default_prevented_(false),
......@@ -47,14 +46,6 @@ RenderWidgetHostLatencyTracker::RenderWidgetHostLatencyTracker(
RenderWidgetHostLatencyTracker::~RenderWidgetHostLatencyTracker() {}
void RenderWidgetHostLatencyTracker::Initialize(int routing_id,
int process_id) {
DCHECK_EQ(0, last_event_id_);
DCHECK_EQ(0, latency_component_id_);
last_event_id_ = static_cast<int64_t>(process_id) << 32;
latency_component_id_ = routing_id | last_event_id_;
}
void RenderWidgetHostLatencyTracker::ComputeInputLatencyHistograms(
WebInputEvent::Type type,
const LatencyInfo& latency,
......@@ -149,7 +140,7 @@ void RenderWidgetHostLatencyTracker::OnInputEvent(
// This is the only place to add the BEGIN_RWH component. So this component
// should not already be present in the latency info.
bool found_component = latency->FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, nullptr);
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr);
DCHECK(!found_component);
if (!event.TimeStamp().is_null() &&
......@@ -189,8 +180,7 @@ void RenderWidgetHostLatencyTracker::OnInputEvent(
has_seen_first_gesture_scroll_update_
? ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT
: ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
latency_component_id_, original_component.event_time,
original_component.event_count);
0, original_component.event_time, original_component.event_count);
}
has_seen_first_gesture_scroll_update_ = true;
......
......@@ -51,16 +51,11 @@ class CONTENT_EXPORT RenderWidgetHostLatencyTracker {
void reset_delegate() { render_widget_host_delegate_ = nullptr; }
// Returns the ID that uniquely describes this component to the latency
// subsystem.
int64_t latency_component_id() const { return latency_component_id_; }
private:
void OnEventStart(ui::LatencyInfo* latency);
ukm::SourceId ukm_source_id_;
int64_t last_event_id_;
int64_t latency_component_id_;
bool has_seen_first_gesture_scroll_update_;
bool set_url_for_ukm_ = false;
// Whether the current stream of touch events includes more than one active
......
......@@ -49,8 +49,8 @@ void AddFakeComponentsWithTimeStamp(
void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker,
ui::LatencyInfo* latency) {
latency->AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker.latency_component_id(), base::TimeTicks::Now(), 1);
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0,
base::TimeTicks::Now(), 1);
AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now());
}
......@@ -135,7 +135,6 @@ class RenderWidgetHostLatencyTrackerTest
RenderViewHostImplTestHarness::SetUp();
old_browser_client_ = SetBrowserClientForTesting(&test_browser_client_);
tracker_ = std::make_unique<RenderWidgetHostLatencyTracker>(contents());
tracker_->Initialize(kTestRoutingId, kTestProcessId);
viz_tracker_.DisableMetricSamplingForTesting();
}
......@@ -146,14 +145,12 @@ class RenderWidgetHostLatencyTrackerTest
}
protected:
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest);
const int kTestRoutingId = 3;
const int kTestProcessId = 1;
std::unique_ptr<base::HistogramTester> histogram_tester_;
std::unique_ptr<RenderWidgetHostLatencyTracker> tracker_;
ui::LatencyTracker viz_tracker_;
RenderWidgetHostLatencyTrackerTestBrowserClient test_browser_client_;
ContentBrowserClient* old_browser_client_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest);
};
TEST_F(RenderWidgetHostLatencyTrackerTest, TestValidEventTiming) {
......@@ -227,8 +224,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) {
wheel.SetTimeStamp(now);
ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
wheel_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0,
now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
tracker()->OnInputEvent(wheel, &wheel_latency);
......@@ -338,8 +335,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) {
wheel.SetTimeStamp(now);
ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
wheel_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0, now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
tracker()->OnInputEvent(wheel, &wheel_latency);
......@@ -449,8 +445,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestInertialToScrollHistograms) {
scroll.SetTimeStamp(now);
ui::LatencyInfo scroll_latency(ui::SourceEventType::INERTIAL);
scroll_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0, now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency);
......@@ -508,8 +503,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
scroll.SetTimeStamp(now);
ui::LatencyInfo scroll_latency;
scroll_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0,
now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency);
......@@ -528,8 +523,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
base::TimeTicks now = base::TimeTicks::Now();
touch_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0,
now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
tracker()->OnInputEvent(touch, &touch_latency);
......@@ -620,8 +615,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) {
scroll.SetTimeStamp(now);
ui::LatencyInfo scroll_latency;
scroll_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0, now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency);
......@@ -640,8 +634,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) {
ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
base::TimeTicks now = base::TimeTicks::Now();
touch_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0, now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
tracker()->OnInputEvent(touch, &touch_latency);
......@@ -809,8 +802,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, LatencyTerminatedOnAckIfGSUIgnored) {
? ui::SourceEventType::TOUCH
: ui::SourceEventType::WHEEL);
scroll_latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), now, 1);
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 0,
now, 1);
AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency);
......@@ -843,11 +836,9 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), nullptr));
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, nullptr));
EXPECT_FALSE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), nullptr));
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, nullptr));
EXPECT_EQ(3U, scroll_latency.latency_components().size());
// Subsequent GestureScrollUpdates should be provided with
......@@ -861,11 +852,9 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) {
EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, nullptr));
EXPECT_FALSE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), nullptr));
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, nullptr));
EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
tracker()->latency_component_id(), nullptr));
ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, nullptr));
EXPECT_EQ(3U, scroll_latency.latency_components().size());
}
......
......@@ -406,8 +406,6 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
process_->AddRoute(routing_id_, this);
process_->AddWidget(this);
latency_tracker_.Initialize(routing_id_, GetProcess()->GetID());
SetupInputRouter();
touch_emulator_.reset();
SetWidget(std::move(widget));
......@@ -1546,8 +1544,9 @@ void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) {
GetWidgetInputHandler()->CursorVisibilityChanged(is_visible);
}
int64_t RenderWidgetHostImpl::GetLatencyComponentId() const {
return latency_tracker_.latency_component_id();
int64_t RenderWidgetHostImpl::GetFrameSinkIdForSnapshot() const {
int process_id = GetProcess()->GetID();
return static_cast<int64_t>(process_id) << 32 | routing_id_;
}
// static
......@@ -1745,7 +1744,7 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser(
if (from_surface) {
pending_surface_browser_snapshots_.insert(std::make_pair(id, callback));
ui::LatencyInfo latency_info;
latency_info.AddSnapshot(GetLatencyComponentId(), id);
latency_info.AddSnapshot(GetFrameSinkIdForSnapshot(), id);
Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info));
return;
}
......@@ -1760,7 +1759,7 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser(
// TODO(nzolghadr): Remove the duplication here and the if block just above.
pending_browser_snapshots_.insert(std::make_pair(id, callback));
ui::LatencyInfo latency_info;
latency_info.AddSnapshot(GetLatencyComponentId(), id);
latency_info.AddSnapshot(GetFrameSinkIdForSnapshot(), id);
Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info));
}
......@@ -2073,9 +2072,9 @@ void RenderWidgetHostImpl::ProcessSnapshotResponses(
// Note that a compromised renderer can send LatencyInfo to a
// RenderWidgetHostImpl other than its own. Be mindful of security
// implications of the code you add here.
if (latency_info.Snapshots().find(GetLatencyComponentId()) !=
if (latency_info.Snapshots().find(GetFrameSinkIdForSnapshot()) !=
latency_info.Snapshots().end()) {
int snapshot_id = latency_info.Snapshots().at(GetLatencyComponentId());
int snapshot_id = latency_info.Snapshots().at(GetFrameSinkIdForSnapshot());
#if defined(OS_MACOSX) || defined(OS_WIN)
// On Mac, when using CoreAnimation, or Win32 when using GDI, there is a
// delay between when content is drawn to the screen, and when the
......@@ -2749,7 +2748,7 @@ void RenderWidgetHostImpl::NotifyCorrespondingRenderWidgetHost(
int64_t frame_id,
std::set<RenderWidgetHostImpl*>& notified_hosts,
const ui::LatencyInfo& latency_info) {
// Matches with GetLatencyComponentId.
// Matches with GetFrameSinkIdForSnapshot.
int routing_id = frame_id & 0xffffffff;
int process_id = (frame_id >> 32) & 0xffffffff;
RenderWidgetHost* rwh = RenderWidgetHost::FromID(process_id, routing_id);
......
......@@ -530,9 +530,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl
void DidReceiveRendererFrame();
// Returns the ID that uniquely describes this component to the latency
// subsystem.
int64_t GetLatencyComponentId() const;
// Returns an identifier for this RenderWidgetHostImpl instance. This is used
// for snapshot requests made to the compositor.
int64_t GetFrameSinkIdForSnapshot() const;
static void OnGpuSwapBuffersCompleted(
const std::vector<ui::LatencyInfo>& latency_info);
......
......@@ -764,8 +764,6 @@ class RenderWidgetHostTest : public testing::Test {
virtual void ConfigureView(TestView* view) {
}
int64_t GetLatencyComponentId() { return host_->GetLatencyComponentId(); }
base::TimeTicks GetNextSimulatedEventTime() {
last_simulated_event_time_ += simulated_event_time_delta_;
return last_simulated_event_time_;
......@@ -2045,7 +2043,6 @@ TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) {
void CheckLatencyInfoComponentInMessage(
MockWidgetInputHandler::MessageVector& dispatched_events,
int64_t component_id,
WebInputEvent::Type expected_type) {
ASSERT_EQ(1u, dispatched_events.size());
ASSERT_TRUE(dispatched_events[0]->ToEvent());
......@@ -2059,8 +2056,7 @@ void CheckLatencyInfoComponentInMessage(
}
void CheckLatencyInfoComponentInGestureScrollUpdate(
MockWidgetInputHandler::MessageVector& dispatched_events,
int64_t component_id) {
MockWidgetInputHandler::MessageVector& dispatched_events) {
ASSERT_EQ(2u, dispatched_events.size());
ASSERT_TRUE(dispatched_events[0]->ToEvent());
ASSERT_TRUE(dispatched_events[1]->ToEvent());
......@@ -2087,7 +2083,7 @@ void RenderWidgetHostTest::InputEventRWHLatencyComponent() {
WebMouseWheelEvent::kPhaseBegan);
MockWidgetInputHandler::MessageVector dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kMouseWheel);
// Tests RWHI::ForwardWheelEventWithLatencyInfo().
......@@ -2095,14 +2091,14 @@ void RenderWidgetHostTest::InputEventRWHLatencyComponent() {
-5, 0, 0, true, ui::LatencyInfo(), WebMouseWheelEvent::kPhaseChanged);
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kMouseWheel);
// Tests RWHI::ForwardMouseEvent().
SimulateMouseEvent(WebInputEvent::kMouseMove);
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kMouseMove);
// Tests RWHI::ForwardMouseEventWithLatencyInfo().
......@@ -2110,7 +2106,7 @@ void RenderWidgetHostTest::InputEventRWHLatencyComponent() {
ui::LatencyInfo());
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kMouseMove);
// Tests RWHI::ForwardGestureEvent().
......@@ -2119,14 +2115,14 @@ void RenderWidgetHostTest::InputEventRWHLatencyComponent() {
host_->input_router()->OnSetTouchAction(cc::kTouchActionAuto);
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kTouchStart);
SimulateGestureEvent(WebInputEvent::kGestureScrollBegin,
blink::kWebGestureDeviceTouchscreen);
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kGestureScrollBegin);
// Tests RWHI::ForwardGestureEventWithLatencyInfo().
......@@ -2135,8 +2131,7 @@ void RenderWidgetHostTest::InputEventRWHLatencyComponent() {
ui::LatencyInfo());
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInGestureScrollUpdate(dispatched_events,
GetLatencyComponentId());
CheckLatencyInfoComponentInGestureScrollUpdate(dispatched_events);
ReleaseTouchPoint(0);
SendTouchEvent();
......@@ -2148,7 +2143,7 @@ void RenderWidgetHostTest::InputEventRWHLatencyComponent() {
SendTouchEvent();
dispatched_events =
host_->mock_widget_input_handler_.GetAndResetDispatchedMessages();
CheckLatencyInfoComponentInMessage(dispatched_events, GetLatencyComponentId(),
CheckLatencyInfoComponentInMessage(dispatched_events,
WebInputEvent::kTouchStart);
}
TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) {
......
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