Chromium Code Reviews| 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 2c57a2b78d543dafaff3170cf9d2447cc2ce5d62..27cb442c153b545662cdbc034cffd4c02b37372b 100644 |
| --- a/content/browser/renderer_host/render_widget_host_impl.cc |
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc |
| @@ -89,6 +89,9 @@ namespace { |
| bool g_check_for_pending_resize_ack = true; |
| +const size_t kBrowserCompositeLatencyHistorySize = 60; |
| +const double kBrowserCompositeLatencyEstimationPercentile = 90.0; |
| + |
| typedef std::pair<int32, int32> RenderWidgetHostID; |
| typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> |
| RoutingIDWidgetMap; |
| @@ -186,7 +189,8 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| has_touch_handler_(false), |
| weak_factory_(this), |
| last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32), |
| - next_browser_snapshot_id_(1) { |
| + next_browser_snapshot_id_(1), |
| + browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize) { |
| CHECK(delegate_); |
| if (routing_id_ == MSG_ROUTING_NONE) { |
| routing_id_ = process_->GetNextRoutingID(); |
| @@ -1451,6 +1455,11 @@ bool RenderWidgetHostImpl::OnSwapCompositorFrame( |
| input_router_->OnViewUpdated( |
| GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); |
| + for (size_t i = 0; i < frame->metadata.latency_info.size(); ++i) { |
| + frame->metadata.latency_info[i].AddLatencyNumber( |
| + ui::INPUT_EVENT_BROWSER_COMPOSITE_COMPONENT, 0, 0); |
|
brianderson
2014/09/18 23:26:15
If the Browser is swap or commit throttled, there
jbauman
2014/09/19 20:40:29
This should specify GetLatencyComponentId() as the
orglofch
2014/09/19 22:40:26
@brian I've renamed the event.
orglofch
2014/09/19 22:40:26
Done.
|
| + } |
| + |
| if (view_) { |
| view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); |
| view_->DidReceiveRendererFrame(); |
| @@ -2142,6 +2151,21 @@ void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
| 100); |
| } |
| } |
| + |
| + ui::LatencyInfo::LatencyComponent gpu_swap_component; |
| + if (!latency_info.FindLatency( |
| + ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, &gpu_swap_component)) { |
| + return; |
| + } |
| + |
| + ui::LatencyInfo::LatencyComponent composite_component; |
| + if (latency_info.FindLatency(ui::INPUT_EVENT_BROWSER_COMPOSITE_COMPONENT, |
|
jbauman
2014/09/19 20:40:29
This should instead find the component with GetLat
orglofch
2014/09/19 22:40:26
Done.
|
| + 0, |
| + &composite_component)) { |
| + base::TimeDelta delta = |
| + gpu_swap_component.event_time - composite_component.event_time; |
| + browser_composite_latency_history_.InsertSample(delta); |
| + } |
| } |
| void RenderWidgetHostImpl::DidReceiveRendererFrame() { |
| @@ -2315,6 +2339,16 @@ BrowserAccessibilityManager* |
| delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| } |
| +base::TimeDelta RenderWidgetHostImpl::GetEstimatedBrowserCompositeTime() { |
| + if (browser_composite_latency_history_.SampleCount() > 0) { |
| + return browser_composite_latency_history_.Percentile( |
| + kBrowserCompositeLatencyEstimationPercentile); |
| + } else { |
| + return base::TimeDelta::FromMicroseconds( |
| + (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60)); |
| + } |
| +} |
| + |
| #if defined(OS_WIN) |
| gfx::NativeViewAccessible |
| RenderWidgetHostImpl::GetParentNativeViewAccessible() { |