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

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

Issue 2645803003: Move FirstMeaningfulPaintDetector timer to frame-specific TaskRunnerTimer (Closed)
Patch Set: Created 3 years, 11 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/fetch/ResourceFetcher.h" 9 #include "core/fetch/ResourceFetcher.h"
9 #include "core/paint/PaintTiming.h" 10 #include "core/paint/PaintTiming.h"
10 #include "platform/instrumentation/tracing/TraceEvent.h" 11 #include "platform/instrumentation/tracing/TraceEvent.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 namespace { 15 namespace {
15 16
16 // Web fonts that laid out more than this number of characters block First 17 // Web fonts that laid out more than this number of characters block First
17 // Meaningful Paint. 18 // Meaningful Paint.
18 const int kBlankCharactersThreshold = 200; 19 const int kBlankCharactersThreshold = 200;
19 20
20 // FirstMeaningfulPaintDetector stops observing layouts and reports First 21 // FirstMeaningfulPaintDetector stops observing layouts and reports First
21 // Meaningful Paint when this duration passed from last network activity. 22 // Meaningful Paint when this duration passed from last network activity.
22 const double kSecondsWithoutNetworkActivityThreshold = 0.5; 23 const double kSecondsWithoutNetworkActivityThreshold = 0.5;
23 24
24 } // namespace 25 } // namespace
25 26
26 FirstMeaningfulPaintDetector& FirstMeaningfulPaintDetector::from( 27 FirstMeaningfulPaintDetector& FirstMeaningfulPaintDetector::from(
27 Document& document) { 28 Document& document) {
28 return PaintTiming::from(document).firstMeaningfulPaintDetector(); 29 return PaintTiming::from(document).firstMeaningfulPaintDetector();
29 } 30 }
30 31
31 FirstMeaningfulPaintDetector::FirstMeaningfulPaintDetector( 32 FirstMeaningfulPaintDetector::FirstMeaningfulPaintDetector(
32 PaintTiming* paintTiming) 33 PaintTiming* paintTiming,
34 Document& document)
33 : m_paintTiming(paintTiming), 35 : m_paintTiming(paintTiming),
34 m_networkStableTimer( 36 m_networkStableTimer(
37 TaskRunnerHelper::get(TaskType::UnspecedTimer, &document),
35 this, 38 this,
36 &FirstMeaningfulPaintDetector::networkStableTimerFired) {} 39 &FirstMeaningfulPaintDetector::networkStableTimerFired) {}
37 40
38 Document* FirstMeaningfulPaintDetector::document() { 41 Document* FirstMeaningfulPaintDetector::document() {
39 return m_paintTiming->supplementable(); 42 return m_paintTiming->supplementable();
40 } 43 }
41 44
42 // Computes "layout significance" (http://goo.gl/rytlPL) of a layout operation. 45 // Computes "layout significance" (http://goo.gl/rytlPL) of a layout operation.
43 // Significance of a layout is the number of layout objects newly added to the 46 // Significance of a layout is the number of layout objects newly added to the
44 // layout tree, weighted by page height (before and after the layout). 47 // layout tree, weighted by page height (before and after the layout).
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (m_provisionalFirstMeaningfulPaint) 125 if (m_provisionalFirstMeaningfulPaint)
123 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint); 126 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint);
124 m_state = Reported; 127 m_state = Reported;
125 } 128 }
126 129
127 DEFINE_TRACE(FirstMeaningfulPaintDetector) { 130 DEFINE_TRACE(FirstMeaningfulPaintDetector) {
128 visitor->trace(m_paintTiming); 131 visitor->trace(m_paintTiming);
129 } 132 }
130 133
131 } // namespace blink 134 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698