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

Unified Diff: third_party/WebKit/Source/core/paint/PaintTiming.cpp

Issue 1456883002: Move paint-related timings out of DocumentTiming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/PaintTiming.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintTiming.cpp b/third_party/WebKit/Source/core/paint/PaintTiming.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..29b9507d92f900416f65e32390d69d7e04b6269d
--- /dev/null
+++ b/third_party/WebKit/Source/core/paint/PaintTiming.cpp
@@ -0,0 +1,69 @@
+// Copyright 2015 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.
+
+#include "config.h"
+#include "core/paint/PaintTiming.h"
+
+#include "core/dom/Document.h"
+#include "core/loader/DocumentLoader.h"
+#include "platform/TraceEvent.h"
+#include "wtf/RawPtr.h"
+
+namespace blink {
+
+static const char kSupplementName[] = "PaintTiming";
+
+PaintTiming& PaintTiming::from(Document& document)
+{
+ PaintTiming* timing = static_cast<PaintTiming*>(WillBeHeapSupplement<Document>::from(document, kSupplementName));
+ if (!timing) {
+ timing = new PaintTiming(document);
+ WillBeHeapSupplement<Document>::provideTo(document, kSupplementName, adoptPtrWillBeNoop(timing));
+ }
+ return *timing;
+}
+
+PaintTiming::PaintTiming(Document& document)
+ : m_document(document)
+{
+}
+
+DEFINE_TRACE(PaintTiming)
+{
+ visitor->trace(m_document);
+}
+
+LocalFrame* PaintTiming::frame() const
+{
+ return m_document ? m_document->frame() : nullptr;
+}
+
+void PaintTiming::notifyPaintTimingChanged()
+{
+ if (m_document && m_document->loader())
+ m_document->loader()->didChangePerformanceTiming();
+}
+
+void PaintTiming::markFirstPaint()
+{
+ m_firstPaint = monotonicallyIncreasingTime();
+ TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstPaint", m_firstPaint, "frame", frame());
+ notifyPaintTimingChanged();
+}
+
+void PaintTiming::markFirstTextPaint()
+{
+ m_firstTextPaint = monotonicallyIncreasingTime();
+ TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstTextPaint", m_firstTextPaint, "frame", frame());
+ notifyPaintTimingChanged();
+}
+
+void PaintTiming::markFirstImagePaint()
+{
+ m_firstImagePaint = monotonicallyIncreasingTime();
+ TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstImagePaint", m_firstImagePaint, "frame", frame());
+ notifyPaintTimingChanged();
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintTiming.h ('k') | third_party/WebKit/Source/core/timing/PerformanceTiming.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698