| 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" | 
 |    9 #include "core/frame/LocalFrame.h" | 
|    8 #include "core/loader/DocumentLoader.h" |   10 #include "core/loader/DocumentLoader.h" | 
|    9 #include "platform/tracing/TraceEvent.h" |   11 #include "platform/tracing/TraceEvent.h" | 
 |   12 #include "public/platform/WebFrameScheduler.h" | 
|   10  |   13  | 
|   11 namespace blink { |   14 namespace blink { | 
|   12  |   15  | 
|   13 static const char kSupplementName[] = "PaintTiming"; |   16 static const char kSupplementName[] = "PaintTiming"; | 
|   14  |   17  | 
|   15 PaintTiming& PaintTiming::from(Document& document) { |   18 PaintTiming& PaintTiming::from(Document& document) { | 
|   16   PaintTiming* timing = static_cast<PaintTiming*>( |   19   PaintTiming* timing = static_cast<PaintTiming*>( | 
|   17       Supplement<Document>::from(document, kSupplementName)); |   20       Supplement<Document>::from(document, kSupplementName)); | 
|   18   if (!timing) { |   21   if (!timing) { | 
|   19     timing = new PaintTiming(document); |   22     timing = new PaintTiming(document); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   58   if (m_firstImagePaint != 0.0) |   61   if (m_firstImagePaint != 0.0) | 
|   59     return; |   62     return; | 
|   60   m_firstImagePaint = monotonicallyIncreasingTime(); |   63   m_firstImagePaint = monotonicallyIncreasingTime(); | 
|   61   setFirstContentfulPaint(m_firstImagePaint); |   64   setFirstContentfulPaint(m_firstImagePaint); | 
|   62   TRACE_EVENT_MARK_WITH_TIMESTAMP1( |   65   TRACE_EVENT_MARK_WITH_TIMESTAMP1( | 
|   63       "blink.user_timing,rail", "firstImagePaint", |   66       "blink.user_timing,rail", "firstImagePaint", | 
|   64       TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); |   67       TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); | 
|   65   notifyPaintTimingChanged(); |   68   notifyPaintTimingChanged(); | 
|   66 } |   69 } | 
|   67  |   70  | 
 |   71 void PaintTiming::markFirstMeaningfulPaintCandidate() { | 
 |   72   if (m_firstMeaningfulPaintCandidate) | 
 |   73     return; | 
 |   74   m_firstMeaningfulPaintCandidate = monotonicallyIncreasingTime(); | 
 |   75   if (m_document->frame() && m_document->frame()->view() && | 
 |   76       !m_document->frame()->view()->parent()) { | 
 |   77     m_document->frame()->frameScheduler()->onFirstMeaningfulPaint(); | 
 |   78   } | 
 |   79 } | 
 |   80  | 
|   68 void PaintTiming::setFirstMeaningfulPaint(double stamp) { |   81 void PaintTiming::setFirstMeaningfulPaint(double stamp) { | 
|   69   DCHECK_EQ(m_firstMeaningfulPaint, 0.0); |   82   DCHECK_EQ(m_firstMeaningfulPaint, 0.0); | 
|   70   m_firstMeaningfulPaint = stamp; |   83   m_firstMeaningfulPaint = stamp; | 
|   71   TRACE_EVENT_MARK_WITH_TIMESTAMP1( |   84   TRACE_EVENT_MARK_WITH_TIMESTAMP1( | 
|   72       "blink.user_timing", "firstMeaningfulPaint", |   85       "blink.user_timing", "firstMeaningfulPaint", | 
|   73       TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); |   86       TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); | 
|   74   notifyPaintTimingChanged(); |   87   notifyPaintTimingChanged(); | 
|   75 } |   88 } | 
|   76  |   89  | 
|   77 void PaintTiming::notifyPaint(bool isFirstPaint, |   90 void PaintTiming::notifyPaint(bool isFirstPaint, | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  116 void PaintTiming::setFirstContentfulPaint(double stamp) { |  129 void PaintTiming::setFirstContentfulPaint(double stamp) { | 
|  117   if (m_firstContentfulPaint != 0.0) |  130   if (m_firstContentfulPaint != 0.0) | 
|  118     return; |  131     return; | 
|  119   setFirstPaint(stamp); |  132   setFirstPaint(stamp); | 
|  120   m_firstContentfulPaint = stamp; |  133   m_firstContentfulPaint = stamp; | 
|  121   TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", |  134   TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", | 
|  122                        TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); |  135                        TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); | 
|  123 } |  136 } | 
|  124  |  137  | 
|  125 }  // namespace blink |  138 }  // namespace blink | 
| OLD | NEW |