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

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: ready for review 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 "platform/Timer.h"
9 #include "platform/heap/Handle.h"
10 #include "wtf/Noncopyable.h"
11
12 namespace blink {
13
14 class Document;
15 class PaintTiming;
16
17 // FirstMeaningfulPaintDetector observes layout operations during page load
18 // until network stable (2 seconds of no network activity), and computes the
19 // layout-based First Meaningful Paint.
20 // See https://goo.gl/vpaxv6 and http://goo.gl/TEiMi4 for more details.
21 class FirstMeaningfulPaintDetector : public GarbageCollectedFinalized<FirstMeani ngfulPaintDetector> {
22 WTF_MAKE_NONCOPYABLE(FirstMeaningfulPaintDetector);
23 public:
24 class LayoutObjectCounter {
25 public:
26 void reset() { m_count = 0; }
27 void increment() { m_count++; }
28 unsigned count() const { return m_count; }
29 private:
30 unsigned m_count = 0;
31 };
32
33 static FirstMeaningfulPaintDetector& from(Document&);
34
35 FirstMeaningfulPaintDetector(PaintTiming*);
36 virtual ~FirstMeaningfulPaintDetector() { }
37
38 void computeLayoutSignificance(const LayoutObjectCounter&,
39 int contentsHeightBeforeLayout, int contentsHeightAfterLayout, int visib leHeight);
40 void notifyPaint();
41 void checkNetworkStable();
42
43 DECLARE_TRACE();
44
45 private:
46 Document* document();
47 void networkStableTimerFired(Timer<FirstMeaningfulPaintDetector>*);
48
49 enum State { NextPaintIsNotMeaningful, NextPaintIsMeaningful, Reported };
50 State m_state = NextPaintIsNotMeaningful;
51
52 Member<PaintTiming> m_paintTiming;
53 double m_provisionalFirstMeaningfulPaint = 0.0;
54 double m_maxSignificanceSoFar = 0.0;
55 double m_accumulatedSignificanceWhileHavingBlankText = 0.0;
56 unsigned m_prevLayoutObjectCount = 0;
57 Timer<FirstMeaningfulPaintDetector> m_networkStableTimer;
58 };
59
60 } // namespace blink
61
62 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698