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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintTiming.cpp

Issue 2528513003: first-paint and first-contentful paint (Closed)
Patch Set: updated layout tests 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PaintTiming.h" 5 #include "core/paint/PaintTiming.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/LocalDOMWindow.h"
8 #include "core/loader/DocumentLoader.h" 9 #include "core/loader/DocumentLoader.h"
10 #include "core/timing/DOMWindowPerformance.h"
11 #include "core/timing/Performance.h"
12 #include "core/timing/PerformancePaintTiming.h"
panicker 2016/12/05 20:51:23 would be nice to avoid this dep directly on Perfor
sunjian 2016/12/07 21:55:43 Done.
9 #include "platform/tracing/TraceEvent.h" 13 #include "platform/tracing/TraceEvent.h"
10 14
11 namespace blink { 15 namespace blink {
12 16
13 static const char kSupplementName[] = "PaintTiming"; 17 static const char kSupplementName[] = "PaintTiming";
14 18
15 PaintTiming& PaintTiming::from(Document& document) { 19 PaintTiming& PaintTiming::from(Document& document) {
16 PaintTiming* timing = static_cast<PaintTiming*>( 20 PaintTiming* timing = static_cast<PaintTiming*>(
17 Supplement<Document>::from(document, kSupplementName)); 21 Supplement<Document>::from(document, kSupplementName));
18 if (!timing) { 22 if (!timing) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 102
99 LocalFrame* PaintTiming::frame() const { 103 LocalFrame* PaintTiming::frame() const {
100 return m_document ? m_document->frame() : nullptr; 104 return m_document ? m_document->frame() : nullptr;
101 } 105 }
102 106
103 void PaintTiming::notifyPaintTimingChanged() { 107 void PaintTiming::notifyPaintTimingChanged() {
104 if (m_document && m_document->loader()) 108 if (m_document && m_document->loader())
105 m_document->loader()->didChangePerformanceTiming(); 109 m_document->loader()->didChangePerformanceTiming();
106 } 110 }
107 111
112 void PaintTiming::addPaintTimingToPerformance(
113 PerformancePaintTiming::PaintType type,
114 double stamp) const {
115 if (frame()) {
116 Performance* performance =
117 DOMWindowPerformance::performance(*frame()->localDOMWindow());
118 DCHECK(performance);
119 performance->addPaintTiming(type, stamp);
120 }
121 }
122
108 void PaintTiming::setFirstPaint(double stamp) { 123 void PaintTiming::setFirstPaint(double stamp) {
109 if (m_firstPaint != 0.0) 124 if (m_firstPaint != 0.0)
110 return; 125 return;
111 m_firstPaint = stamp; 126 m_firstPaint = stamp;
127 addPaintTimingToPerformance(PerformancePaintTiming::PaintType::FirstPaint,
128 m_firstPaint);
129
112 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstPaint", 130 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstPaint",
113 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); 131 TRACE_EVENT_SCOPE_PROCESS, "frame", frame());
114 } 132 }
115 133
116 void PaintTiming::setFirstContentfulPaint(double stamp) { 134 void PaintTiming::setFirstContentfulPaint(double stamp) {
117 if (m_firstContentfulPaint != 0.0) 135 if (m_firstContentfulPaint != 0.0)
118 return; 136 return;
119 setFirstPaint(stamp); 137 setFirstPaint(stamp);
120 m_firstContentfulPaint = stamp; 138 m_firstContentfulPaint = stamp;
139 addPaintTimingToPerformance(
140 PerformancePaintTiming::PaintType::FirstContentfulPaint,
141 m_firstContentfulPaint);
121 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", 142 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint",
122 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); 143 TRACE_EVENT_SCOPE_PROCESS, "frame", frame());
123 } 144 }
124 145
125 } // namespace blink 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698