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

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

Issue 2276573003: Add trace event for FirstMeaningfulPaint candidates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/TraceEvent.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 namespace { 14 namespace {
14 15
15 // Web fonts that laid out more than this number of characters block First 16 // Web fonts that laid out more than this number of characters block First
16 // Meaningful Paint. 17 // Meaningful Paint.
17 const int kBlankCharactersThreshold = 200; 18 const int kBlankCharactersThreshold = 200;
18 19
19 // FirstMeaningfulPaintDetector stops observing layouts and reports First 20 // FirstMeaningfulPaintDetector stops observing layouts and reports First
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 { 80 {
80 if (m_state != NextPaintIsMeaningful) 81 if (m_state != NextPaintIsMeaningful)
81 return; 82 return;
82 83
83 // Skip document background-only paints. 84 // Skip document background-only paints.
84 if (m_paintTiming->firstPaint() == 0.0) 85 if (m_paintTiming->firstPaint() == 0.0)
85 return; 86 return;
86 87
87 m_provisionalFirstMeaningfulPaint = monotonicallyIncreasingTime(); 88 m_provisionalFirstMeaningfulPaint = monotonicallyIncreasingTime();
88 m_state = NextPaintIsNotMeaningful; 89 m_state = NextPaintIsNotMeaningful;
90
91 TRACE_EVENT_MARK_WITH_TIMESTAMP1("loading", "firstMeaningfulPaintCandidate", m_provisionalFirstMeaningfulPaint, "frame", document()->frame());
89 } 92 }
90 93
91 void FirstMeaningfulPaintDetector::checkNetworkStable() 94 void FirstMeaningfulPaintDetector::checkNetworkStable()
92 { 95 {
93 DCHECK(document()); 96 DCHECK(document());
94 if (m_state == Reported || document()->fetcher()->hasPendingRequest()) 97 if (m_state == Reported || document()->fetcher()->hasPendingRequest())
95 return; 98 return;
96 99
97 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, B LINK_FROM_HERE); 100 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, B LINK_FROM_HERE);
98 } 101 }
99 102
100 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) 103 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*)
101 { 104 {
102 if (m_state == Reported || !document() || document()->fetcher()->hasPendingR equest()) 105 if (m_state == Reported || !document() || document()->fetcher()->hasPendingR equest())
103 return; 106 return;
104 107
105 if (m_provisionalFirstMeaningfulPaint) 108 if (m_provisionalFirstMeaningfulPaint)
106 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint ); 109 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint );
107 m_state = Reported; 110 m_state = Reported;
108 } 111 }
109 112
110 DEFINE_TRACE(FirstMeaningfulPaintDetector) 113 DEFINE_TRACE(FirstMeaningfulPaintDetector)
111 { 114 {
112 visitor->trace(m_paintTiming); 115 visitor->trace(m_paintTiming);
113 } 116 }
114 117
115 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698