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

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

Issue 2397753006: scheduler: Detect load RAIL mode (Closed)
Patch Set: Add fallback for missing FMP 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/FrameView.h"
9 #include "core/frame/LocalFrame.h"
8 #include "core/loader/DocumentLoader.h" 10 #include "core/loader/DocumentLoader.h"
9 #include "platform/tracing/TraceEvent.h" 11 #include "platform/tracing/TraceEvent.h"
12 #include "public/platform/WebFrameScheduler.h"
10 13
11 namespace blink { 14 namespace blink {
12 15
13 static const char kSupplementName[] = "PaintTiming"; 16 static const char kSupplementName[] = "PaintTiming";
14 17
15 PaintTiming& PaintTiming::from(Document& document) { 18 PaintTiming& PaintTiming::from(Document& document) {
16 PaintTiming* timing = static_cast<PaintTiming*>( 19 PaintTiming* timing = static_cast<PaintTiming*>(
17 Supplement<Document>::from(document, kSupplementName)); 20 Supplement<Document>::from(document, kSupplementName));
18 if (!timing) { 21 if (!timing) {
19 timing = new PaintTiming(document); 22 timing = new PaintTiming(document);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (m_firstImagePaint != 0.0) 61 if (m_firstImagePaint != 0.0)
59 return; 62 return;
60 m_firstImagePaint = monotonicallyIncreasingTime(); 63 m_firstImagePaint = monotonicallyIncreasingTime();
61 setFirstContentfulPaint(m_firstImagePaint); 64 setFirstContentfulPaint(m_firstImagePaint);
62 TRACE_EVENT_MARK_WITH_TIMESTAMP1( 65 TRACE_EVENT_MARK_WITH_TIMESTAMP1(
63 "blink.user_timing,rail", "firstImagePaint", 66 "blink.user_timing,rail", "firstImagePaint",
64 TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); 67 TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame());
65 notifyPaintTimingChanged(); 68 notifyPaintTimingChanged();
66 } 69 }
67 70
71 void PaintTiming::markFirstMeaningfulPaintCandidate() {
72 // The first meaningful paint candidate can be reported very early, even
73 // before the first contentful paint. To cut down on false positives, we only
74 // report the first meaningful paint candidate after the first contentful
75 // paint.
76 if (!m_firstContentfulPaint)
77 return;
78 // Ignore the first meaningful paint candidate as this generally is the first
79 // contentful paint itself.
80 if (!m_seenFirstMeaningfulPaintCandidate) {
81 m_seenFirstMeaningfulPaintCandidate = true;
82 return;
83 }
84 if (m_document->frame() && m_document->frame()->view() &&
85 !m_document->frame()->view()->parent()) {
86 m_document->frame()->frameScheduler()->onFirstMeaningfulPaint();
87 }
88 }
89
68 void PaintTiming::setFirstMeaningfulPaint(double stamp) { 90 void PaintTiming::setFirstMeaningfulPaint(double stamp) {
69 DCHECK_EQ(m_firstMeaningfulPaint, 0.0); 91 DCHECK_EQ(m_firstMeaningfulPaint, 0.0);
70 m_firstMeaningfulPaint = stamp; 92 m_firstMeaningfulPaint = stamp;
71 TRACE_EVENT_MARK_WITH_TIMESTAMP1( 93 TRACE_EVENT_MARK_WITH_TIMESTAMP1(
72 "blink.user_timing", "firstMeaningfulPaint", 94 "blink.user_timing", "firstMeaningfulPaint",
73 TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); 95 TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame());
74 notifyPaintTimingChanged(); 96 notifyPaintTimingChanged();
75 } 97 }
76 98
77 void PaintTiming::notifyPaint(bool isFirstPaint, 99 void PaintTiming::notifyPaint(bool isFirstPaint,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void PaintTiming::setFirstContentfulPaint(double stamp) { 138 void PaintTiming::setFirstContentfulPaint(double stamp) {
117 if (m_firstContentfulPaint != 0.0) 139 if (m_firstContentfulPaint != 0.0)
118 return; 140 return;
119 setFirstPaint(stamp); 141 setFirstPaint(stamp);
120 m_firstContentfulPaint = stamp; 142 m_firstContentfulPaint = stamp;
121 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", 143 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint",
122 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); 144 TRACE_EVENT_SCOPE_PROCESS, "frame", frame());
123 } 145 }
124 146
125 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698