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

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

Issue 2397753006: scheduler: Detect load RAIL mode (Closed)
Patch Set: Rebased 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 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/fetch/ResourceFetcher.h" 8 #include "core/fetch/ResourceFetcher.h"
9 #include "core/paint/PaintTiming.h" 9 #include "core/paint/PaintTiming.h"
10 #include "platform/tracing/TraceEvent.h" 10 #include "platform/tracing/TraceEvent.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (m_paintTiming->firstPaint() == 0.0) 88 if (m_paintTiming->firstPaint() == 0.0)
89 return; 89 return;
90 90
91 m_provisionalFirstMeaningfulPaint = monotonicallyIncreasingTime(); 91 m_provisionalFirstMeaningfulPaint = monotonicallyIncreasingTime();
92 m_state = NextPaintIsNotMeaningful; 92 m_state = NextPaintIsNotMeaningful;
93 93
94 TRACE_EVENT_MARK_WITH_TIMESTAMP1( 94 TRACE_EVENT_MARK_WITH_TIMESTAMP1(
95 "loading", "firstMeaningfulPaintCandidate", 95 "loading", "firstMeaningfulPaintCandidate",
96 TraceEvent::toTraceTimestamp(m_provisionalFirstMeaningfulPaint), "frame", 96 TraceEvent::toTraceTimestamp(m_provisionalFirstMeaningfulPaint), "frame",
97 document()->frame()); 97 document()->frame());
98 // Ignore the first meaningful paint candidate as this generally is the first
99 // contentful paint itself.
100 if (!m_seenFirstMeaningfulPaintCandidate) {
101 m_seenFirstMeaningfulPaintCandidate = true;
102 return;
103 }
104 m_paintTiming->markFirstMeaningfulPaintCandidate();
98 } 105 }
99 106
100 void FirstMeaningfulPaintDetector::checkNetworkStable() { 107 void FirstMeaningfulPaintDetector::checkNetworkStable() {
101 DCHECK(document()); 108 DCHECK(document());
102 if (m_state == Reported || document()->fetcher()->hasPendingRequest()) 109 if (m_state == Reported || document()->fetcher()->hasPendingRequest())
103 return; 110 return;
104 111
105 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, 112 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold,
106 BLINK_FROM_HERE); 113 BLINK_FROM_HERE);
107 } 114 }
108 115
109 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) { 116 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) {
110 if (m_state == Reported || !document() || 117 if (m_state == Reported || !document() ||
111 document()->fetcher()->hasPendingRequest()) 118 document()->fetcher()->hasPendingRequest())
112 return; 119 return;
113 120
114 if (m_provisionalFirstMeaningfulPaint) 121 if (m_provisionalFirstMeaningfulPaint)
115 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint); 122 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint);
116 m_state = Reported; 123 m_state = Reported;
117 } 124 }
118 125
119 DEFINE_TRACE(FirstMeaningfulPaintDetector) { 126 DEFINE_TRACE(FirstMeaningfulPaintDetector) {
120 visitor->trace(m_paintTiming); 127 visitor->trace(m_paintTiming);
121 } 128 }
122 129
123 } // namespace blink 130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698