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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintTiming.h

Issue 2835763002: Use swap-promise to improve first* paint times (Closed)
Patch Set: address review comments Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef PaintTiming_h 5 #ifndef PaintTiming_h
6 #define PaintTiming_h 6 #define PaintTiming_h
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/paint/FirstMeaningfulPaintDetector.h" 9 #include "core/paint/FirstMeaningfulPaintDetector.h"
10 #include "platform/Supplementable.h" 10 #include "platform/Supplementable.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "platform/wtf/Noncopyable.h" 12 #include "platform/wtf/Noncopyable.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class LocalFrame; 16 class LocalFrame;
17 17
18 // PaintTiming is responsible for tracking paint-related timings for a given 18 // PaintTiming is responsible for tracking paint-related timings for a given
19 // document. 19 // document.
20 class CORE_EXPORT PaintTiming final 20 class CORE_EXPORT PaintTiming final
21 : public GarbageCollectedFinalized<PaintTiming>, 21 : public GarbageCollectedFinalized<PaintTiming>,
22 public Supplement<Document> { 22 public Supplement<Document> {
23 WTF_MAKE_NONCOPYABLE(PaintTiming); 23 WTF_MAKE_NONCOPYABLE(PaintTiming);
24 USING_GARBAGE_COLLECTED_MIXIN(PaintTiming); 24 USING_GARBAGE_COLLECTED_MIXIN(PaintTiming);
25 25
26 public: 26 public:
27 virtual ~PaintTiming() {} 27 virtual ~PaintTiming() {}
28 28
29 enum class PaintEvent {
30 kFirstPaint,
31 kFirstContentfulPaint,
32 kFirstMeaningfulPaint
33 };
34
29 static PaintTiming& From(Document&); 35 static PaintTiming& From(Document&);
30 36
31 // mark*() methods record the time for the given paint event, record a trace 37 // mark*() methods record the time for the given paint event, record a trace
32 // event, and notify that paint timing has changed. These methods do nothing 38 // event, and notify that paint timing has changed. These methods do nothing
33 // (early return) if a time has already been recorded for the given paint 39 // (early return) if a time has already been recorded for the given paint
34 // event. 40 // event.
35 void MarkFirstPaint(); 41 void MarkFirstPaint();
36 42
37 // markFirstTextPaint, markFirstImagePaint, and markFirstContentfulPaint 43 // markFirstTextPaint, markFirstImagePaint, and markFirstContentfulPaint
38 // will also record first paint if first paint hasn't been recorded yet. 44 // will also record first paint if first paint hasn't been recorded yet.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // firstMeaningfulPaint, this signal is available in real time, but it may be 81 // firstMeaningfulPaint, this signal is available in real time, but it may be
76 // an optimistic (i.e., too early) estimate. 82 // an optimistic (i.e., too early) estimate.
77 double FirstMeaningfulPaintCandidate() const { 83 double FirstMeaningfulPaintCandidate() const {
78 return first_meaningful_paint_candidate_; 84 return first_meaningful_paint_candidate_;
79 } 85 }
80 86
81 FirstMeaningfulPaintDetector& GetFirstMeaningfulPaintDetector() { 87 FirstMeaningfulPaintDetector& GetFirstMeaningfulPaintDetector() {
82 return *fmp_detector_; 88 return *fmp_detector_;
83 } 89 }
84 90
91 void ReportSwapTime(PaintEvent, bool did_swap, double timestamp);
sunnyps 2017/05/02 01:20:46 nit: newline after ReportSwapTime
panicker 2017/05/02 21:21:36 Done.
85 DECLARE_VIRTUAL_TRACE(); 92 DECLARE_VIRTUAL_TRACE();
86 93
87 private: 94 private:
88 explicit PaintTiming(Document&); 95 explicit PaintTiming(Document&);
89 LocalFrame* GetFrame() const; 96 LocalFrame* GetFrame() const;
90 void NotifyPaintTimingChanged(); 97 void NotifyPaintTimingChanged();
91 98
92 // set*() set the timing for the given paint event to the given timestamp 99 // set*() set the timing for the given paint event to the given timestamp
93 // and record a trace event if the value is currently zero, but do not 100 // and record a trace event if the value is currently zero, but do not
94 // notify that paint timing changed. These methods can be invoked from other 101 // notify that paint timing changed. These methods can be invoked from other
95 // mark*() or set*() methods to make sure that first paint is marked as part 102 // mark*() or set*() methods to make sure that first paint is marked as part
96 // of marking first contentful paint, or that first contentful paint is 103 // of marking first contentful paint, or that first contentful paint is
97 // marked as part of marking first text/image paint, for example. 104 // marked as part of marking first text/image paint, for example.
98 void SetFirstPaint(double stamp); 105 void SetFirstPaint(double stamp);
99 106
100 // setFirstContentfulPaint will also set first paint time if first paint 107 // setFirstContentfulPaint will also set first paint time if first paint
101 // time has not yet been recorded. 108 // time has not yet been recorded.
102 void SetFirstContentfulPaint(double stamp); 109 void SetFirstContentfulPaint(double stamp);
103 110
111 void RegisterNotifySwapTime(PaintEvent);
112
104 double first_paint_ = 0.0; 113 double first_paint_ = 0.0;
114 double first_paint_swap_ = 0.0;
105 double first_text_paint_ = 0.0; 115 double first_text_paint_ = 0.0;
106 double first_image_paint_ = 0.0; 116 double first_image_paint_ = 0.0;
107 double first_contentful_paint_ = 0.0; 117 double first_contentful_paint_ = 0.0;
118 double first_contentful_paint_swap_ = 0.0;
108 double first_meaningful_paint_ = 0.0; 119 double first_meaningful_paint_ = 0.0;
120 double first_meaningful_paint_swap_ = 0.0;
109 double first_meaningful_paint_candidate_ = 0.0; 121 double first_meaningful_paint_candidate_ = 0.0;
110 122
111 Member<FirstMeaningfulPaintDetector> fmp_detector_; 123 Member<FirstMeaningfulPaintDetector> fmp_detector_;
112 }; 124 };
113 125
114 } // namespace blink 126 } // namespace blink
115 127
116 #endif 128 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698