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

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

Issue 2528513003: first-paint and first-contentful paint (Closed)
Patch Set: addressed comments Created 4 years 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
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 b5964500258f47b528af52a1acbf486c6e3e5453..34185f974d7d10140a15d5e2dc6cc37ccb2b4230 100644
--- a/third_party/WebKit/Source/core/paint/PaintTiming.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintTiming.cpp
@@ -6,13 +6,29 @@
#include "core/dom/Document.h"
#include "core/frame/FrameView.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/loader/DocumentLoader.h"
+#include "core/timing/DOMWindowPerformance.h"
+#include "core/timing/Performance.h"
#include "platform/tracing/TraceEvent.h"
#include "public/platform/WebFrameScheduler.h"
namespace blink {
+namespace {
+
+Performance* getPerformanceInstance(LocalFrame* frame) {
+ Performance* performance = nullptr;
+ if (frame) {
+ performance = DOMWindowPerformance::performance(*frame->localDOMWindow());
haraken 2016/12/09 00:30:03 frame->localDOMWindow() may return null. Check it.
sunjian 2016/12/09 19:06:49 Done.
+ DCHECK(performance);
+ }
+ return performance;
+}
+
+} // namespace
+
static const char kSupplementName[] = "PaintTiming";
PaintTiming& PaintTiming::from(Document& document) {
@@ -122,6 +138,10 @@ void PaintTiming::setFirstPaint(double stamp) {
if (m_firstPaint != 0.0)
return;
m_firstPaint = stamp;
+ Performance* performance = getPerformanceInstance(frame());
+ if (performance)
+ performance->addFirstPaintTiming(m_firstPaint);
+
TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstPaint",
TRACE_EVENT_SCOPE_PROCESS, "frame", frame());
}
@@ -131,6 +151,9 @@ void PaintTiming::setFirstContentfulPaint(double stamp) {
return;
setFirstPaint(stamp);
m_firstContentfulPaint = stamp;
+ Performance* performance = getPerformanceInstance(frame());
+ if (performance)
+ performance->addFirstContentfulPaintTiming(m_firstContentfulPaint);
TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint",
TRACE_EVENT_SCOPE_PROCESS, "frame", frame());
}

Powered by Google App Engine
This is Rietveld 408576698