| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/PaintTiming.h" | 5 #include "core/paint/PaintTiming.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/loader/DocumentLoader.h" | 8 #include "core/loader/DocumentLoader.h" |
| 9 #include "platform/TraceEvent.h" | 9 #include "platform/TraceEvent.h" |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void PaintTiming::markFirstImagePaint() | 58 void PaintTiming::markFirstImagePaint() |
| 59 { | 59 { |
| 60 if (m_firstImagePaint != 0.0) | 60 if (m_firstImagePaint != 0.0) |
| 61 return; | 61 return; |
| 62 m_firstImagePaint = monotonicallyIncreasingTime(); | 62 m_firstImagePaint = monotonicallyIncreasingTime(); |
| 63 setFirstContentfulPaint(m_firstImagePaint); | 63 setFirstContentfulPaint(m_firstImagePaint); |
| 64 TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing,rail", "firstImagePaint"
, m_firstImagePaint, "frame", frame()); | 64 TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing,rail", "firstImagePaint"
, m_firstImagePaint, "frame", frame()); |
| 65 notifyPaintTimingChanged(); | 65 notifyPaintTimingChanged(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void PaintTiming::setFirstMeaningfulPaint(double stamp) |
| 69 { |
| 70 DCHECK_EQ(m_firstMeaningfulPaint, 0.0); |
| 71 m_firstMeaningfulPaint = stamp; |
| 72 TRACE_EVENT_MARK_WITH_TIMESTAMP1("blink.user_timing", "firstMeaningfulPaint"
, m_firstMeaningfulPaint, "frame", frame()); |
| 73 notifyPaintTimingChanged(); |
| 74 } |
| 75 |
| 76 void PaintTiming::notifyPaint(bool isFirstPaint, bool textPainted, bool imagePai
nted) |
| 77 { |
| 78 if (isFirstPaint) |
| 79 markFirstPaint(); |
| 80 if (textPainted) |
| 81 markFirstTextPaint(); |
| 82 if (imagePainted) |
| 83 markFirstImagePaint(); |
| 84 m_fmpDetector->notifyPaint(); |
| 85 } |
| 86 |
| 68 DEFINE_TRACE(PaintTiming) | 87 DEFINE_TRACE(PaintTiming) |
| 69 { | 88 { |
| 70 visitor->trace(m_document); | 89 visitor->trace(m_document); |
| 90 visitor->trace(m_fmpDetector); |
| 71 Supplement<Document>::trace(visitor); | 91 Supplement<Document>::trace(visitor); |
| 72 } | 92 } |
| 73 | 93 |
| 74 PaintTiming::PaintTiming(Document& document) | 94 PaintTiming::PaintTiming(Document& document) |
| 75 : m_document(document) | 95 : m_document(document) |
| 96 , m_fmpDetector(new FirstMeaningfulPaintDetector(this)) |
| 76 { | 97 { |
| 77 } | 98 } |
| 78 | 99 |
| 79 LocalFrame* PaintTiming::frame() const | 100 LocalFrame* PaintTiming::frame() const |
| 80 { | 101 { |
| 81 return m_document ? m_document->frame() : nullptr; | 102 return m_document ? m_document->frame() : nullptr; |
| 82 } | 103 } |
| 83 | 104 |
| 84 void PaintTiming::notifyPaintTimingChanged() | 105 void PaintTiming::notifyPaintTimingChanged() |
| 85 { | 106 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 98 void PaintTiming::setFirstContentfulPaint(double stamp) | 119 void PaintTiming::setFirstContentfulPaint(double stamp) |
| 99 { | 120 { |
| 100 if (m_firstContentfulPaint != 0.0) | 121 if (m_firstContentfulPaint != 0.0) |
| 101 return; | 122 return; |
| 102 setFirstPaint(stamp); | 123 setFirstPaint(stamp); |
| 103 m_firstContentfulPaint = stamp; | 124 m_firstContentfulPaint = stamp; |
| 104 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", TRACE
_EVENT_SCOPE_PROCESS, "frame", frame()); | 125 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", TRACE
_EVENT_SCOPE_PROCESS, "frame", frame()); |
| 105 } | 126 } |
| 106 | 127 |
| 107 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |