Commit 478e85a9 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Remove RenderWidgetHostLatencyTracker::OnSwapCompositorFrame

This method adds the right component id to snapshot-related latency
info, We can just send the right component id to the renderer so that
a correction browser-side is not necessary.

Test: Lots of pixel tests take screenshots. Also tested
Page.captureScreenshot manually.

Bug: 810037, 775030
Change-Id: I61242ad63c5af8975331cb405fc629ce19ef92f8
Reviewed-on: https://chromium-review.googlesource.com/1019389
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552204}
parent 389d3230
......@@ -33,37 +33,6 @@ ukm::SourceId GenerateUkmSourceId() {
return ukm_recorder ? ukm_recorder->GetNewSourceID() : ukm::kInvalidSourceId;
}
// LatencyComponents generated in the renderer must have component IDs
// provided to them by the browser process. This function adds the correct
// component ID where necessary.
void AddLatencyInfoComponentIds(LatencyInfo* latency,
int64_t latency_component_id) {
std::vector<std::pair<ui::LatencyComponentType, int64_t>> new_components_key;
std::vector<LatencyInfo::LatencyComponent> new_components_value;
for (const auto& lc : latency->latency_components()) {
ui::LatencyComponentType component_type = lc.first.first;
if (component_type == ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT) {
// Generate a new component entry with the correct component ID
new_components_key.push_back(std::make_pair(component_type,
latency_component_id));
new_components_value.push_back(lc.second);
}
}
// Remove the entries with invalid component IDs.
latency->RemoveLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT);
// Add newly generated components into the latency info
for (size_t i = 0; i < new_components_key.size(); i++) {
latency->AddLatencyNumberWithTimestamp(
new_components_key[i].first,
new_components_key[i].second,
new_components_value[i].sequence_number,
new_components_value[i].event_time,
new_components_value[i].event_count);
}
}
void RecordEQTAccuracy(base::TimeDelta queueing_time,
base::TimeDelta expected_queueing_time) {
float queueing_time_ms = queueing_time.InMillisecondsF();
......@@ -336,12 +305,4 @@ void RenderWidgetHostLatencyTracker::OnInputEventAck(
*latency, ack_result);
}
void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame(
std::vector<LatencyInfo>* latencies) {
DCHECK(latencies);
for (LatencyInfo& latency : *latencies) {
AddLatencyInfoComponentIds(&latency, latency_component_id_);
}
}
} // namespace content
......@@ -52,11 +52,6 @@ class CONTENT_EXPORT RenderWidgetHostLatencyTracker
ui::LatencyInfo* latency,
InputEventAckState ack_result);
// Populates renderer-created LatencyInfo entries with the appropriate latency
// component id. Called when the RenderWidgetHost receives a compositor swap
// update from the renderer.
void OnSwapCompositorFrame(std::vector<ui::LatencyInfo>* latencies);
void reset_delegate() { render_widget_host_delegate_ = nullptr; }
// Returns the ID that uniquely describes this component to the latency
......
......@@ -1705,7 +1705,7 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser(
pending_surface_browser_snapshots_.insert(std::make_pair(id, callback));
ui::LatencyInfo latency_info;
latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT,
0, id);
GetLatencyComponentId(), id);
Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info));
return;
}
......@@ -1719,8 +1719,8 @@ void RenderWidgetHostImpl::GetSnapshotFromBrowser(
#endif
pending_browser_snapshots_.insert(std::make_pair(id, callback));
ui::LatencyInfo latency_info;
latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, 0,
id);
latency_info.AddLatencyNumber(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT,
GetLatencyComponentId(), id);
Send(new ViewMsg_ForceRedraw(GetRoutingID(), latency_info));
}
......@@ -2020,6 +2020,9 @@ void RenderWidgetHostImpl::ClearDisplayedGraphics() {
void RenderWidgetHostImpl::OnGpuSwapBuffersCompletedInternal(
const ui::LatencyInfo& latency_info) {
// 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.
ui::LatencyInfo::LatencyComponent window_snapshot_component;
if (latency_info.FindLatency(ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT,
GetLatencyComponentId(),
......@@ -2967,8 +2970,6 @@ void RenderWidgetHostImpl::SubmitCompositorFrame(
last_frame_metadata_ = frame.metadata.Clone();
latency_tracker_.OnSwapCompositorFrame(&frame.metadata.latency_info);
bool is_mobile_optimized = IsMobileOptimizedFrame(frame.metadata);
input_router_->NotifySiteIsMobileOptimized(is_mobile_optimized);
if (touch_emulator_)
......
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