| 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 #include "wtf/RawPtr.h" | 10 #include "wtf/RawPtr.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 static const char kSupplementName[] = "PaintTiming"; | 14 static const char kSupplementName[] = "PaintTiming"; |
| 15 | 15 |
| 16 PaintTiming& PaintTiming::from(Document& document) | 16 PaintTiming& PaintTiming::from(Document& document) |
| 17 { | 17 { |
| 18 PaintTiming* timing = static_cast<PaintTiming*>(WillBeHeapSupplement<Documen
t>::from(document, kSupplementName)); | 18 PaintTiming* timing = static_cast<PaintTiming*>(HeapSupplement<Document>::fr
om(document, kSupplementName)); |
| 19 if (!timing) { | 19 if (!timing) { |
| 20 timing = new PaintTiming(document); | 20 timing = new PaintTiming(document); |
| 21 WillBeHeapSupplement<Document>::provideTo(document, kSupplementName, ado
ptPtrWillBeNoop(timing)); | 21 HeapSupplement<Document>::provideTo(document, kSupplementName, adoptPtrW
illBeNoop(timing)); |
| 22 } | 22 } |
| 23 return *timing; | 23 return *timing; |
| 24 } | 24 } |
| 25 | 25 |
| 26 void PaintTiming::markFirstPaint() | 26 void PaintTiming::markFirstPaint() |
| 27 { | 27 { |
| 28 // Test that m_firstPaint is non-zero here, as well as in setFirstPaint, so | 28 // Test that m_firstPaint is non-zero here, as well as in setFirstPaint, so |
| 29 // we avoid invoking monotonicallyIncreasingTime() on every call to | 29 // we avoid invoking monotonicallyIncreasingTime() on every call to |
| 30 // markFirstPaint(). | 30 // markFirstPaint(). |
| 31 if (m_firstPaint != 0.0) | 31 if (m_firstPaint != 0.0) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void PaintTiming::setFirstContentfulPaint(double stamp) | 98 void PaintTiming::setFirstContentfulPaint(double stamp) |
| 99 { | 99 { |
| 100 if (m_firstContentfulPaint != 0.0) | 100 if (m_firstContentfulPaint != 0.0) |
| 101 return; | 101 return; |
| 102 setFirstPaint(stamp); | 102 setFirstPaint(stamp); |
| 103 m_firstContentfulPaint = stamp; | 103 m_firstContentfulPaint = stamp; |
| 104 TRACE_EVENT_INSTANT1("blink.user_timing", "firstContentfulPaint", TRACE_EVEN
T_SCOPE_PROCESS, "frame", frame()); | 104 TRACE_EVENT_INSTANT1("blink.user_timing", "firstContentfulPaint", TRACE_EVEN
T_SCOPE_PROCESS, "frame", frame()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |