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