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

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

Issue 2738813003: Ensure the scheduler always changes from UseCase LOADING to NONE. (Closed)
Patch Set: Update FMPD to use the provisional time rather than the current time. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/FirstMeaningfulPaintDetector.h" 5 #include "core/paint/FirstMeaningfulPaintDetector.h"
6 6
7 #include "core/css/FontFaceSet.h" 7 #include "core/css/FontFaceSet.h"
8 #include "core/dom/TaskRunnerHelper.h" 8 #include "core/dom/TaskRunnerHelper.h"
9 #include "core/paint/PaintTiming.h" 9 #include "core/paint/PaintTiming.h"
10 #include "platform/instrumentation/tracing/TraceEvent.h" 10 #include "platform/instrumentation/tracing/TraceEvent.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 TRACE_EVENT_MARK_WITH_TIMESTAMP1( 97 TRACE_EVENT_MARK_WITH_TIMESTAMP1(
98 "loading", "firstMeaningfulPaintCandidate", 98 "loading", "firstMeaningfulPaintCandidate",
99 TraceEvent::toTraceTimestamp(m_provisionalFirstMeaningfulPaint), "frame", 99 TraceEvent::toTraceTimestamp(m_provisionalFirstMeaningfulPaint), "frame",
100 document()->frame()); 100 document()->frame());
101 // Ignore the first meaningful paint candidate as this generally is the first 101 // Ignore the first meaningful paint candidate as this generally is the first
102 // contentful paint itself. 102 // contentful paint itself.
103 if (!m_seenFirstMeaningfulPaintCandidate) { 103 if (!m_seenFirstMeaningfulPaintCandidate) {
104 m_seenFirstMeaningfulPaintCandidate = true; 104 m_seenFirstMeaningfulPaintCandidate = true;
105 return; 105 return;
106 } 106 }
107 m_paintTiming->markFirstMeaningfulPaintCandidate(); 107 m_paintTiming->markFirstMeaningfulPaintCandidate(
108 m_provisionalFirstMeaningfulPaint);
108 } 109 }
109 110
110 void FirstMeaningfulPaintDetector::checkNetworkStable() { 111 void FirstMeaningfulPaintDetector::checkNetworkStable() {
111 DCHECK(document()); 112 DCHECK(document());
112 if (m_state == Reported || document()->fetcher()->hasPendingRequest()) 113 if (m_state == Reported || document()->fetcher()->hasPendingRequest())
113 return; 114 return;
114 115
115 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, 116 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold,
116 BLINK_FROM_HERE); 117 BLINK_FROM_HERE);
117 } 118 }
118 119
119 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) { 120 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) {
120 if (m_state == Reported || !document() || 121 if (m_state == Reported || !document() ||
121 document()->fetcher()->hasPendingRequest() || 122 document()->fetcher()->hasPendingRequest() ||
122 !m_paintTiming->firstContentfulPaint()) 123 !m_paintTiming->firstContentfulPaint())
123 return; 124 return;
124 125
125 if (m_provisionalFirstMeaningfulPaint) { 126 if (m_provisionalFirstMeaningfulPaint) {
127 // If there's only been one contentful paint, then there won't have been
128 // a meaningful paint signalled to the Scheduler, so mark one now.
129 // This is a no-op if a FMPC has already been marked.
130 m_paintTiming->markFirstMeaningfulPaintCandidate(
131 m_provisionalFirstMeaningfulPaint);
126 // Enforce FirstContentfulPaint <= FirstMeaningfulPaint. 132 // Enforce FirstContentfulPaint <= FirstMeaningfulPaint.
127 double timestamp = std::max(m_provisionalFirstMeaningfulPaint, 133 double timestamp = std::max(m_provisionalFirstMeaningfulPaint,
128 m_paintTiming->firstContentfulPaint()); 134 m_paintTiming->firstContentfulPaint());
129 m_paintTiming->setFirstMeaningfulPaint(timestamp); 135 m_paintTiming->setFirstMeaningfulPaint(timestamp);
130 } 136 }
131 m_state = Reported; 137 m_state = Reported;
132 } 138 }
133 139
134 DEFINE_TRACE(FirstMeaningfulPaintDetector) { 140 DEFINE_TRACE(FirstMeaningfulPaintDetector) {
135 visitor->trace(m_paintTiming); 141 visitor->trace(m_paintTiming);
136 } 142 }
137 143
138 } // namespace blink 144 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698