Chromium Code Reviews| 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(double stamp, |
| 101 bool was_after_user_input) { | |
| 100 DCHECK_EQ(first_meaningful_paint_, 0.0); | 102 DCHECK_EQ(first_meaningful_paint_, 0.0); |
| 101 first_meaningful_paint_ = stamp; | 103 TRACE_EVENT_MARK_WITH_TIMESTAMP2( |
| 102 TRACE_EVENT_MARK_WITH_TIMESTAMP1( | |
| 103 "loading,rail,devtools.timeline", "firstMeaningfulPaint", | 104 "loading,rail,devtools.timeline", "firstMeaningfulPaint", |
| 104 TraceEvent::ToTraceTimestamp(first_meaningful_paint_), "frame", | 105 TraceEvent::ToTraceTimestamp(stamp), "frame", GetFrame(), |
| 105 GetFrame()); | 106 "afterUserInput", was_after_user_input); |
| 106 NotifyPaintTimingChanged(); | 107 |
| 107 RegisterNotifySwapTime(PaintEvent::kFirstMeaningfulPaint); | 108 // Notify FMP for UMA only if there's no user input before FMP, so that layout |
| 109 // changes caused by user interactions wouldn't be considered as FMP. | |
| 110 if (!was_after_user_input) { | |
| 111 first_meaningful_paint_ = stamp; | |
| 112 NotifyPaintTimingChanged(); | |
| 113 RegisterNotifySwapTime(PaintEvent::kFirstMeaningfulPaint); | |
| 114 } | |
| 115 | |
| 116 ReportUserInputHistogram(was_after_user_input); | |
| 117 } | |
| 118 | |
| 119 void PaintTiming::ReportUserInputHistogram(bool had_input) { | |
| 120 enum HadUserInput { kNoUserInput, kHadUserInput, kHadUserInputEnumMax }; | |
| 121 DEFINE_STATIC_LOCAL(EnumerationHistogram, had_user_input_histogram, | |
|
Bryan McQuade
2017/06/08 17:47:12
i'd rather not use PageLoad as the prefix here, as
Kunihiko Sakamoto
2017/06/09 05:48:16
Thanks for the suggestions, renamed to PageLoad.In
| |
| 122 ("PageLoad.Experimental.Renderer.PaintTiming." | |
| 123 "HadUserInputBeforeFirstMeaningfulPaint", | |
| 124 kHadUserInputEnumMax)); | |
| 125 | |
| 126 if (GetFrame()->IsMainFrame()) | |
| 127 had_user_input_histogram.Count(had_input ? kHadUserInput : kNoUserInput); | |
| 108 } | 128 } |
| 109 | 129 |
| 110 void PaintTiming::NotifyPaint(bool is_first_paint, | 130 void PaintTiming::NotifyPaint(bool is_first_paint, |
| 111 bool text_painted, | 131 bool text_painted, |
| 112 bool image_painted) { | 132 bool image_painted) { |
| 113 if (is_first_paint) | 133 if (is_first_paint) |
| 114 MarkFirstPaint(); | 134 MarkFirstPaint(); |
| 115 if (text_painted) | 135 if (text_painted) |
| 116 MarkFirstTextPaint(); | 136 MarkFirstTextPaint(); |
| 117 if (image_painted) | 137 if (image_painted) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 first_contentful_paint_swap_ = timestamp; | 212 first_contentful_paint_swap_ = timestamp; |
| 193 return; | 213 return; |
| 194 case PaintEvent::kFirstMeaningfulPaint: | 214 case PaintEvent::kFirstMeaningfulPaint: |
| 195 first_meaningful_paint_swap_ = timestamp; | 215 first_meaningful_paint_swap_ = timestamp; |
| 196 return; | 216 return; |
| 197 } | 217 } |
| 198 NOTREACHED(); | 218 NOTREACHED(); |
| 199 } | 219 } |
| 200 | 220 |
| 201 } // namespace blink | 221 } // namespace blink |
| OLD | NEW |