Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintTiming.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintTiming.cpp b/third_party/WebKit/Source/core/paint/PaintTiming.cpp |
| index fae6893ff847960b441603f6225449b779476646..754646ef012db230cf2eabbc0284ee5027f61c34 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintTiming.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintTiming.cpp |
| @@ -9,10 +9,13 @@ |
| #include "core/frame/LocalDOMWindow.h" |
| #include "core/frame/LocalFrame.h" |
| #include "core/loader/DocumentLoader.h" |
| +#include "core/page/ChromeClient.h" |
| +#include "core/page/Page.h" |
| #include "core/timing/DOMWindowPerformance.h" |
| #include "core/timing/Performance.h" |
| #include "platform/WebFrameScheduler.h" |
| #include "platform/instrumentation/tracing/TraceEvent.h" |
| +#include "public/platform/WebLayerTreeView.h" |
| namespace blink { |
| @@ -100,6 +103,7 @@ void PaintTiming::SetFirstMeaningfulPaint(double stamp) { |
| TraceEvent::ToTraceTimestamp(first_meaningful_paint_), "frame", |
| GetFrame()); |
| NotifyPaintTimingChanged(); |
| + RegisterNotifySwapTime(PaintEvent::kFirstMeaningfulPaint); |
| } |
| void PaintTiming::NotifyPaint(bool is_first_paint, |
| @@ -142,6 +146,7 @@ void PaintTiming::SetFirstPaint(double stamp) { |
| TRACE_EVENT_INSTANT1("loading,rail,devtools.timeline", "firstPaint", |
| TRACE_EVENT_SCOPE_PROCESS, "frame", GetFrame()); |
| + RegisterNotifySwapTime(PaintEvent::kFirstPaint); |
| } |
| void PaintTiming::SetFirstContentfulPaint(double stamp) { |
| @@ -152,8 +157,42 @@ void PaintTiming::SetFirstContentfulPaint(double stamp) { |
| Performance* performance = GetPerformanceInstance(GetFrame()); |
| if (performance) |
| performance->AddFirstContentfulPaintTiming(first_contentful_paint_); |
| + |
| TRACE_EVENT_INSTANT1("loading,rail,devtools.timeline", "firstContentfulPaint", |
| TRACE_EVENT_SCOPE_PROCESS, "frame", GetFrame()); |
| + RegisterNotifySwapTime(PaintEvent::kFirstContentfulPaint); |
| +} |
| + |
| +void PaintTiming::RegisterNotifySwapTime(PaintEvent event) { |
| + // ReportSwapTime on layerTreeView will queue a swap-promise, the callback is |
| + // called when the swap for current render frame completes or fails to happen. |
| + if (GetFrame()->GetPage() && |
|
enne (OOO)
2017/05/01 21:58:11
style nit: could rewrite this as "if (!GetPage) re
panicker
2017/05/02 00:57:04
Done.
|
| + GetFrame()->GetPage()->GetChromeClient().GetWebLayerTreeView( |
| + GetFrame())) { |
| + WebLayerTreeView* layerTreeView = |
| + GetFrame()->GetPage()->GetChromeClient().GetWebLayerTreeView( |
| + GetFrame()); |
| + layerTreeView->NotifySwapTime(ConvertToBaseCallback(WTF::Bind( |
| + &PaintTiming::ReportSwapTime, WrapWeakPersistent(this), event))); |
| + } |
| +} |
| + |
| +void PaintTiming::ReportSwapTime(PaintEvent event, |
| + bool did_swap, |
| + double timestamp) { |
| + if (did_swap) { |
|
enne (OOO)
2017/05/01 21:58:11
style nit: could early out here instead of indenti
panicker
2017/05/02 00:57:04
Done.
|
| + switch (event) { |
| + case PaintEvent::kFirstPaint: |
| + first_paint_swap_ = timestamp; |
| + break; |
| + case PaintEvent::kFirstContentfulPaint: |
| + first_contentful_paint_swap_ = timestamp; |
| + break; |
| + case PaintEvent::kFirstMeaningfulPaint: |
| + first_meaningful_paint_swap_ = timestamp; |
| + break; |
| + } |
| + } |
| } |
| } // namespace blink |