OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/paint/PaintTiming.h" |
| 7 |
| 8 #include "core/dom/Document.h" |
| 9 #include "core/loader/DocumentLoader.h" |
| 10 #include "platform/TraceEvent.h" |
| 11 #include "wtf/RawPtr.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 static const char kSupplementName[] = "PaintTiming"; |
| 16 |
| 17 PaintTiming& PaintTiming::from(Document& document) |
| 18 { |
| 19 PaintTiming* timing = static_cast<PaintTiming*>(WillBeHeapSupplement<Documen
t>::from(document, kSupplementName)); |
| 20 if (!timing) { |
| 21 timing = new PaintTiming(document); |
| 22 WillBeHeapSupplement<Document>::provideTo(document, kSupplementName, ado
ptPtrWillBeNoop(timing)); |
| 23 } |
| 24 return *timing; |
| 25 } |
| 26 |
| 27 PaintTiming::PaintTiming(Document& document) |
| 28 : m_document(document) |
| 29 { |
| 30 } |
| 31 |
| 32 DEFINE_TRACE(PaintTiming) |
| 33 { |
| 34 visitor->trace(m_document); |
| 35 } |
| 36 |
| 37 LocalFrame* PaintTiming::frame() const |
| 38 { |
| 39 return m_document ? m_document->frame() : nullptr; |
| 40 } |
| 41 |
| 42 void PaintTiming::notifyPaintTimingChanged() |
| 43 { |
| 44 if (m_document && m_document->loader()) |
| 45 m_document->loader()->didChangePerformanceTiming(); |
| 46 } |
| 47 |
| 48 void PaintTiming::markFirstPaint() |
| 49 { |
| 50 m_firstPaint = monotonicallyIncreasingTime(); |
| 51 TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstPaint", m_firstP
aint, "frame", frame()); |
| 52 notifyPaintTimingChanged(); |
| 53 } |
| 54 |
| 55 void PaintTiming::markFirstTextPaint() |
| 56 { |
| 57 m_firstTextPaint = monotonicallyIncreasingTime(); |
| 58 TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstTextPaint", m_fi
rstTextPaint, "frame", frame()); |
| 59 notifyPaintTimingChanged(); |
| 60 } |
| 61 |
| 62 void PaintTiming::markFirstImagePaint() |
| 63 { |
| 64 m_firstImagePaint = monotonicallyIncreasingTime(); |
| 65 TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstImagePaint", m_f
irstImagePaint, "frame", frame()); |
| 66 notifyPaintTimingChanged(); |
| 67 } |
| 68 |
| 69 } // namespace blink |
OLD | NEW |