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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetector.h
diff --git a/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetector.h b/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetector.h
new file mode 100644
index 0000000000000000000000000000000000000000..ad7aae32ee199b8143c10adcddd3b1606a08a7d6
--- /dev/null
+++ b/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetector.h
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FirstMeaningfulPaintDetector_h
+#define FirstMeaningfulPaintDetector_h
+
+#include "core/CoreExport.h"
+#include "platform/Timer.h"
+#include "platform/heap/Handle.h"
+#include "wtf/Noncopyable.h"
+
+namespace blink {
+
+class Document;
+class PaintTiming;
+
+// FirstMeaningfulPaintDetector observes layout operations during page load
+// until network stable (2 seconds of no network activity), and computes the
+// layout-based First Meaningful Paint.
+// See https://goo.gl/vpaxv6 and http://goo.gl/TEiMi4 for more details.
+class CORE_EXPORT FirstMeaningfulPaintDetector : public GarbageCollectedFinalized<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.
+ WTF_MAKE_NONCOPYABLE(FirstMeaningfulPaintDetector);
+public:
+ 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.
+ public:
+ void reset() { m_count = 0; }
+ void increment() { m_count++; }
+ unsigned count() const { return m_count; }
+ private:
+ unsigned m_count = 0;
+ };
+
+ static FirstMeaningfulPaintDetector& from(Document&);
+
+ FirstMeaningfulPaintDetector(PaintTiming*);
+ virtual ~FirstMeaningfulPaintDetector() { }
+
+ void computeLayoutSignificance(const LayoutObjectCounter&,
+ int contentsHeightBeforeLayout, int contentsHeightAfterLayout, int visibleHeight);
+ void notifyPaint();
+ void checkNetworkStable();
+
+ DECLARE_TRACE();
+
+private:
+ friend class FirstMeaningfulPaintDetectorTest;
+
+ Document* document();
+ void networkStableTimerFired(TimerBase*);
+
+ enum State { NextPaintIsNotMeaningful, NextPaintIsMeaningful, Reported };
+ State m_state = NextPaintIsNotMeaningful;
+
+ Member<PaintTiming> m_paintTiming;
+ double m_provisionalFirstMeaningfulPaint = 0.0;
+ double m_maxSignificanceSoFar = 0.0;
+ double m_accumulatedSignificanceWhileHavingBlankText = 0.0;
+ unsigned m_prevLayoutObjectCount = 0;
+ Timer<FirstMeaningfulPaintDetector> m_networkStableTimer;
+};
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698