Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
| index 8ed17334975b79f18c5239932794bfc79f372ed8..9494a00b374f5d7f2f73ecf1979f19e399261de5 100644 |
| --- a/content/renderer/render_view_impl.cc |
| +++ b/content/renderer/render_view_impl.cc |
| @@ -634,6 +634,36 @@ GetV8CacheStrategiesForCacheStorage() { |
| } |
| } |
| +// This class represents promise which is robust to (will not be broken by) |
| +// |DidNotSwapReason::SWAP_FAILS| events. |
| +class CC_EXPORT AlwaysDrawSwapPromise : public cc::SwapPromise { |
|
danakj
2016/08/11 21:59:00
drop the CC_EXPORT
svartmetal
2016/08/12 10:07:33
Fixed.
|
| + public: |
| + explicit AlwaysDrawSwapPromise(const ui::LatencyInfo& latency_info) |
| + : latency_info_(latency_info) {} |
| + |
| + ~AlwaysDrawSwapPromise() override = default; |
| + |
| + void DidActivate() override {} |
| + |
| + void DidSwap(cc::CompositorFrameMetadata* metadata) override { |
| + DCHECK(!latency_info_.terminated()); |
| + metadata->latency_info.push_back(latency_info_); |
| + } |
| + |
| + DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { |
| + return reason == DidNotSwapReason::SWAP_FAILS |
| + ? DidNotSwapAction::KEEP_ACTIVE |
| + : DidNotSwapAction::BREAK_PROMISE; |
| + } |
| + |
| + void OnCommit() override {} |
| + |
| + int64_t TraceId() const override { return latency_info_.trace_id(); } |
| + |
| + private: |
| + ui::LatencyInfo latency_info_; |
| +}; |
| + |
| } // namespace |
| RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
| @@ -1464,17 +1494,10 @@ void RenderViewImpl::ApplyWebPreferencesInternal( |
| ApplyWebPreferences(prefs, web_view); |
| } |
| -void RenderViewImpl::OnForceRedraw(int id) { |
| - ui::LatencyInfo latency_info; |
| - if (id) { |
| - latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| - 0, |
| - id); |
| - } |
| - std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; |
| +void RenderViewImpl::OnForceRedraw(const ui::LatencyInfo& latency_info) { |
| if (RenderWidgetCompositor* rwc = compositor()) { |
| - latency_info_swap_promise_monitor = |
| - rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info); |
| + rwc->QueueSwapPromise( |
| + base::WrapUnique(new AlwaysDrawSwapPromise(latency_info))); |
|
danakj
2016/08/11 21:59:00
one last nit: prefer base::MakeUnique<AlwaysDrawSw
svartmetal
2016/08/12 10:07:33
Fixed.
|
| } |
| ScheduleCompositeWithForcedRedraw(); |
| } |