| 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/LocalDOMWindow.h" |    8 #include "core/frame/LocalDOMWindow.h" | 
|    9 #include "core/frame/LocalFrame.h" |    9 #include "core/frame/LocalFrame.h" | 
|   10 #include "core/frame/LocalFrameView.h" |   10 #include "core/frame/LocalFrameView.h" | 
|   11 #include "core/loader/DocumentLoader.h" |   11 #include "core/loader/DocumentLoader.h" | 
|   12 #include "core/loader/ProgressTracker.h" |   12 #include "core/loader/ProgressTracker.h" | 
|   13 #include "core/page/ChromeClient.h" |   13 #include "core/page/ChromeClient.h" | 
|   14 #include "core/page/Page.h" |   14 #include "core/page/Page.h" | 
|   15 #include "core/timing/DOMWindowPerformance.h" |   15 #include "core/timing/DOMWindowPerformance.h" | 
|   16 #include "core/timing/Performance.h" |   16 #include "core/timing/Performance.h" | 
 |   17 #include "platform/Histogram.h" | 
|   17 #include "platform/WebFrameScheduler.h" |   18 #include "platform/WebFrameScheduler.h" | 
|   18 #include "platform/instrumentation/tracing/TraceEvent.h" |   19 #include "platform/instrumentation/tracing/TraceEvent.h" | 
|   19 #include "public/platform/WebLayerTreeView.h" |   20 #include "public/platform/WebLayerTreeView.h" | 
|   20  |   21  | 
|   21 namespace blink { |   22 namespace blink { | 
|   22  |   23  | 
|   23 namespace { |   24 namespace { | 
|   24  |   25  | 
|   25 Performance* GetPerformanceInstance(LocalFrame* frame) { |   26 Performance* GetPerformanceInstance(LocalFrame* frame) { | 
|   26   Performance* performance = nullptr; |   27   Performance* performance = nullptr; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   89  |   90  | 
|   90 void PaintTiming::SetFirstMeaningfulPaintCandidate(double timestamp) { |   91 void PaintTiming::SetFirstMeaningfulPaintCandidate(double timestamp) { | 
|   91   if (first_meaningful_paint_candidate_) |   92   if (first_meaningful_paint_candidate_) | 
|   92     return; |   93     return; | 
|   93   first_meaningful_paint_candidate_ = timestamp; |   94   first_meaningful_paint_candidate_ = timestamp; | 
|   94   if (GetFrame() && GetFrame()->View() && !GetFrame()->View()->IsAttached()) { |   95   if (GetFrame() && GetFrame()->View() && !GetFrame()->View()->IsAttached()) { | 
|   95     GetFrame()->FrameScheduler()->OnFirstMeaningfulPaint(); |   96     GetFrame()->FrameScheduler()->OnFirstMeaningfulPaint(); | 
|   96   } |   97   } | 
|   97 } |   98 } | 
|   98  |   99  | 
|   99 void PaintTiming::SetFirstMeaningfulPaint(double stamp) { |  100 void PaintTiming::SetFirstMeaningfulPaint( | 
 |  101     double stamp, | 
 |  102     FirstMeaningfulPaintDetector::HadUserInput had_input) { | 
|  100   DCHECK_EQ(first_meaningful_paint_, 0.0); |  103   DCHECK_EQ(first_meaningful_paint_, 0.0); | 
|  101   first_meaningful_paint_ = stamp; |  104   TRACE_EVENT_MARK_WITH_TIMESTAMP2("loading,rail,devtools.timeline", | 
|  102   TRACE_EVENT_MARK_WITH_TIMESTAMP1( |  105                                    "firstMeaningfulPaint", | 
|  103       "loading,rail,devtools.timeline", "firstMeaningfulPaint", |  106                                    TraceEvent::ToTraceTimestamp(stamp), "frame", | 
|  104       TraceEvent::ToTraceTimestamp(first_meaningful_paint_), "frame", |  107                                    GetFrame(), "afterUserInput", had_input); | 
|  105       GetFrame()); |  108  | 
|  106   NotifyPaintTimingChanged(); |  109   // Notify FMP for UMA only if there's no user input before FMP, so that layout | 
|  107   RegisterNotifySwapTime(PaintEvent::kFirstMeaningfulPaint); |  110   // changes caused by user interactions wouldn't be considered as FMP. | 
 |  111   if (had_input == FirstMeaningfulPaintDetector::kNoUserInput) { | 
 |  112     first_meaningful_paint_ = stamp; | 
 |  113     NotifyPaintTimingChanged(); | 
 |  114     RegisterNotifySwapTime(PaintEvent::kFirstMeaningfulPaint); | 
 |  115   } | 
 |  116  | 
 |  117   ReportUserInputHistogram(had_input); | 
 |  118 } | 
 |  119  | 
 |  120 void PaintTiming::ReportUserInputHistogram( | 
 |  121     FirstMeaningfulPaintDetector::HadUserInput had_input) { | 
 |  122   DEFINE_STATIC_LOCAL(EnumerationHistogram, had_user_input_histogram, | 
 |  123                       ("PageLoad.Internal.PaintTiming." | 
 |  124                        "HadUserInputBeforeFirstMeaningfulPaint", | 
 |  125                        FirstMeaningfulPaintDetector::kHadUserInputEnumMax)); | 
 |  126  | 
 |  127   if (GetFrame() && GetFrame()->IsMainFrame()) | 
 |  128     had_user_input_histogram.Count(had_input); | 
|  108 } |  129 } | 
|  109  |  130  | 
|  110 void PaintTiming::NotifyPaint(bool is_first_paint, |  131 void PaintTiming::NotifyPaint(bool is_first_paint, | 
|  111                               bool text_painted, |  132                               bool text_painted, | 
|  112                               bool image_painted) { |  133                               bool image_painted) { | 
|  113   if (is_first_paint) |  134   if (is_first_paint) | 
|  114     MarkFirstPaint(); |  135     MarkFirstPaint(); | 
|  115   if (text_painted) |  136   if (text_painted) | 
|  116     MarkFirstTextPaint(); |  137     MarkFirstTextPaint(); | 
|  117   if (image_painted) |  138   if (image_painted) | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  189         performance->AddFirstContentfulPaintTiming(first_contentful_paint_); |  210         performance->AddFirstContentfulPaintTiming(first_contentful_paint_); | 
|  190       return; |  211       return; | 
|  191     case PaintEvent::kFirstMeaningfulPaint: |  212     case PaintEvent::kFirstMeaningfulPaint: | 
|  192       first_meaningful_paint_swap_ = timestamp; |  213       first_meaningful_paint_swap_ = timestamp; | 
|  193       return; |  214       return; | 
|  194   } |  215   } | 
|  195   NOTREACHED(); |  216   NOTREACHED(); | 
|  196 } |  217 } | 
|  197  |  218  | 
|  198 }  // namespace blink |  219 }  // namespace blink | 
| OLD | NEW |