OLD | NEW |
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 #include "platform/TraceEvent.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (m_state != NextPaintIsMeaningful) | 81 if (m_state != NextPaintIsMeaningful) |
82 return; | 82 return; |
83 | 83 |
84 // Skip document background-only paints. | 84 // Skip document background-only paints. |
85 if (m_paintTiming->firstPaint() == 0.0) | 85 if (m_paintTiming->firstPaint() == 0.0) |
86 return; | 86 return; |
87 | 87 |
88 m_provisionalFirstMeaningfulPaint = monotonicallyIncreasingTime(); | 88 m_provisionalFirstMeaningfulPaint = monotonicallyIncreasingTime(); |
89 m_state = NextPaintIsNotMeaningful; | 89 m_state = NextPaintIsNotMeaningful; |
90 | 90 |
91 TRACE_EVENT_MARK_WITH_TIMESTAMP1("loading", "firstMeaningfulPaintCandidate",
m_provisionalFirstMeaningfulPaint, "frame", document()->frame()); | 91 TRACE_EVENT_MARK_WITH_TIMESTAMP1("loading", "firstMeaningfulPaintCandidate",
TraceEvent::toTraceTimestamp(m_provisionalFirstMeaningfulPaint), "frame", docum
ent()->frame()); |
92 } | 92 } |
93 | 93 |
94 void FirstMeaningfulPaintDetector::checkNetworkStable() | 94 void FirstMeaningfulPaintDetector::checkNetworkStable() |
95 { | 95 { |
96 DCHECK(document()); | 96 DCHECK(document()); |
97 if (m_state == Reported || document()->fetcher()->hasPendingRequest()) | 97 if (m_state == Reported || document()->fetcher()->hasPendingRequest()) |
98 return; | 98 return; |
99 | 99 |
100 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, B
LINK_FROM_HERE); | 100 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, B
LINK_FROM_HERE); |
101 } | 101 } |
102 | 102 |
103 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) | 103 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) |
104 { | 104 { |
105 if (m_state == Reported || !document() || document()->fetcher()->hasPendingR
equest()) | 105 if (m_state == Reported || !document() || document()->fetcher()->hasPendingR
equest()) |
106 return; | 106 return; |
107 | 107 |
108 if (m_provisionalFirstMeaningfulPaint) | 108 if (m_provisionalFirstMeaningfulPaint) |
109 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint
); | 109 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint
); |
110 m_state = Reported; | 110 m_state = Reported; |
111 } | 111 } |
112 | 112 |
113 DEFINE_TRACE(FirstMeaningfulPaintDetector) | 113 DEFINE_TRACE(FirstMeaningfulPaintDetector) |
114 { | 114 { |
115 visitor->trace(m_paintTiming); | 115 visitor->trace(m_paintTiming); |
116 } | 116 } |
117 | 117 |
118 } // namespace blink | 118 } // namespace blink |
OLD | NEW |