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

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

Issue 2039363003: FirstMeaningfulPaint UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wait in renderer Created 4 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef FirstMeaningfulPaintDetector_h
6 #define FirstMeaningfulPaintDetector_h
7
8 #include "core/CoreExport.h"
9 #include "platform/Timer.h"
10 #include "platform/heap/Handle.h"
11 #include "wtf/Noncopyable.h"
12
13 namespace blink {
14
15 class Document;
16 class PaintTiming;
17
18 // FirstMeaningfulPaintDetector observes layout operations during page load
19 // until network stable (2 seconds of no network activity), and computes the
20 // layout-based First Meaningful Paint.
21 // See https://goo.gl/vpaxv6 and http://goo.gl/TEiMi4 for more details.
22 class CORE_EXPORT FirstMeaningfulPaintDetector : public GarbageCollectedFinalize d<FirstMeaningfulPaintDetector> {
Charlie Harrison 2016/08/09 16:27:32 Just to make sure: does this have to be finalized
Kunihiko Sakamoto 2016/08/10 02:33:32 Yes.
23 WTF_MAKE_NONCOPYABLE(FirstMeaningfulPaintDetector);
24 public:
25 class LayoutObjectCounter {
Charlie Harrison 2016/08/09 16:27:33 Can you document this class and who should be usin
Kunihiko Sakamoto 2016/08/10 02:33:32 Done.
26 public:
27 void reset() { m_count = 0; }
28 void increment() { m_count++; }
29 unsigned count() const { return m_count; }
30 private:
31 unsigned m_count = 0;
32 };
33
34 static FirstMeaningfulPaintDetector& from(Document&);
35
36 FirstMeaningfulPaintDetector(PaintTiming*);
37 virtual ~FirstMeaningfulPaintDetector() { }
38
39 void computeLayoutSignificance(const LayoutObjectCounter&,
40 int contentsHeightBeforeLayout, int contentsHeightAfterLayout, int visib leHeight);
41 void notifyPaint();
42 void checkNetworkStable();
43
44 DECLARE_TRACE();
45
46 private:
47 friend class FirstMeaningfulPaintDetectorTest;
48
49 Document* document();
50 void networkStableTimerFired(TimerBase*);
51
52 enum State { NextPaintIsNotMeaningful, NextPaintIsMeaningful, Reported };
53 State m_state = NextPaintIsNotMeaningful;
54
55 Member<PaintTiming> m_paintTiming;
56 double m_provisionalFirstMeaningfulPaint = 0.0;
57 double m_maxSignificanceSoFar = 0.0;
58 double m_accumulatedSignificanceWhileHavingBlankText = 0.0;
59 unsigned m_prevLayoutObjectCount = 0;
60 Timer<FirstMeaningfulPaintDetector> m_networkStableTimer;
61 };
62
63 } // namespace blink
64
65 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698