| 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/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 DEFINE_TRACE(PaintTiming) { | 116 DEFINE_TRACE(PaintTiming) { |
| 117 visitor->trace(m_fmpDetector); | 117 visitor->trace(m_fmpDetector); |
| 118 Supplement<Document>::trace(visitor); | 118 Supplement<Document>::trace(visitor); |
| 119 } | 119 } |
| 120 | 120 |
| 121 PaintTiming::PaintTiming(Document& document) | 121 PaintTiming::PaintTiming(Document& document) |
| 122 : Supplement<Document>(document), | 122 : Supplement<Document>(document), |
| 123 m_fmpDetector(new FirstMeaningfulPaintDetector(this)) {} | 123 m_fmpDetector(new FirstMeaningfulPaintDetector(this)) {} |
| 124 | 124 |
| 125 LocalFrame* PaintTiming::frame() const { | 125 LocalFrame* PaintTiming::frame() const { |
| 126 return host()->frame(); | 126 return supplementable()->frame(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void PaintTiming::notifyPaintTimingChanged() { | 129 void PaintTiming::notifyPaintTimingChanged() { |
| 130 if (host()->loader()) | 130 if (supplementable()->loader()) |
| 131 host()->loader()->didChangePerformanceTiming(); | 131 supplementable()->loader()->didChangePerformanceTiming(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void PaintTiming::setFirstPaint(double stamp) { | 134 void PaintTiming::setFirstPaint(double stamp) { |
| 135 if (m_firstPaint != 0.0) | 135 if (m_firstPaint != 0.0) |
| 136 return; | 136 return; |
| 137 m_firstPaint = stamp; | 137 m_firstPaint = stamp; |
| 138 Performance* performance = getPerformanceInstance(frame()); | 138 Performance* performance = getPerformanceInstance(frame()); |
| 139 if (performance) | 139 if (performance) |
| 140 performance->addFirstPaintTiming(m_firstPaint); | 140 performance->addFirstPaintTiming(m_firstPaint); |
| 141 | 141 |
| 142 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstPaint", | 142 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstPaint", |
| 143 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); | 143 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void PaintTiming::setFirstContentfulPaint(double stamp) { | 146 void PaintTiming::setFirstContentfulPaint(double stamp) { |
| 147 if (m_firstContentfulPaint != 0.0) | 147 if (m_firstContentfulPaint != 0.0) |
| 148 return; | 148 return; |
| 149 setFirstPaint(stamp); | 149 setFirstPaint(stamp); |
| 150 m_firstContentfulPaint = stamp; | 150 m_firstContentfulPaint = stamp; |
| 151 Performance* performance = getPerformanceInstance(frame()); | 151 Performance* performance = getPerformanceInstance(frame()); |
| 152 if (performance) | 152 if (performance) |
| 153 performance->addFirstContentfulPaintTiming(m_firstContentfulPaint); | 153 performance->addFirstContentfulPaintTiming(m_firstContentfulPaint); |
| 154 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", | 154 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", |
| 155 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); | 155 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace blink | 158 } // namespace blink |
| OLD | NEW |