Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Unified Diff: third_party/WebKit/Source/core/paint/PaintTiming.cpp

Issue 2835763002: Use swap-promise to improve first* paint times (Closed)
Patch Set: address nit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintTiming.h ('k') | third_party/WebKit/public/platform/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d0d77477c9b73283c4baf9f9fdea241b5c8c30de 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,43 @@ 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() || !GetFrame()->GetPage())
+ return;
+ if (WebLayerTreeView* layerTreeView =
+ GetFrame()->GetPage()->GetChromeClient().GetWebLayerTreeView(
+ GetFrame())) {
+ layerTreeView->NotifySwapTime(ConvertToBaseCallback(
+ WTF::Bind(&PaintTiming::ReportSwapTime,
+ WrapCrossThreadWeakPersistent(this), event)));
+ }
+}
+
+void PaintTiming::ReportSwapTime(PaintEvent event,
+ bool did_swap,
+ double timestamp) {
+ if (!did_swap)
+ return;
+ switch (event) {
+ case PaintEvent::kFirstPaint:
+ first_paint_swap_ = timestamp;
+ return;
+ case PaintEvent::kFirstContentfulPaint:
+ first_contentful_paint_swap_ = timestamp;
+ return;
+ case PaintEvent::kFirstMeaningfulPaint:
+ first_meaningful_paint_swap_ = timestamp;
+ return;
+ }
+ NOTREACHED();
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintTiming.h ('k') | third_party/WebKit/public/platform/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698