Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintTiming.cpp

Issue 2873033002: Update PaintTiming Web Perf APIs for FP & FCP to report swap time (Closed)
Patch Set: missed virtual/mojo-loading tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/observable.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 void PaintTiming::NotifyPaintTimingChanged() { 134 void PaintTiming::NotifyPaintTimingChanged() {
135 if (GetSupplementable()->Loader()) 135 if (GetSupplementable()->Loader())
136 GetSupplementable()->Loader()->DidChangePerformanceTiming(); 136 GetSupplementable()->Loader()->DidChangePerformanceTiming();
137 } 137 }
138 138
139 void PaintTiming::SetFirstPaint(double stamp) { 139 void PaintTiming::SetFirstPaint(double stamp) {
140 if (first_paint_ != 0.0) 140 if (first_paint_ != 0.0)
141 return; 141 return;
142 first_paint_ = stamp; 142 first_paint_ = stamp;
143 Performance* performance = GetPerformanceInstance(GetFrame());
144 if (performance)
145 performance->AddFirstPaintTiming(first_paint_);
146
147 TRACE_EVENT_INSTANT1("loading,rail,devtools.timeline", "firstPaint", 143 TRACE_EVENT_INSTANT1("loading,rail,devtools.timeline", "firstPaint",
148 TRACE_EVENT_SCOPE_PROCESS, "frame", GetFrame()); 144 TRACE_EVENT_SCOPE_PROCESS, "frame", GetFrame());
149 RegisterNotifySwapTime(PaintEvent::kFirstPaint); 145 RegisterNotifySwapTime(PaintEvent::kFirstPaint);
150 } 146 }
151 147
152 void PaintTiming::SetFirstContentfulPaint(double stamp) { 148 void PaintTiming::SetFirstContentfulPaint(double stamp) {
153 if (first_contentful_paint_ != 0.0) 149 if (first_contentful_paint_ != 0.0)
154 return; 150 return;
155 SetFirstPaint(stamp); 151 SetFirstPaint(stamp);
156 first_contentful_paint_ = stamp; 152 first_contentful_paint_ = stamp;
157 Performance* performance = GetPerformanceInstance(GetFrame());
158 if (performance)
159 performance->AddFirstContentfulPaintTiming(first_contentful_paint_);
160
161 TRACE_EVENT_INSTANT1("loading,rail,devtools.timeline", "firstContentfulPaint", 153 TRACE_EVENT_INSTANT1("loading,rail,devtools.timeline", "firstContentfulPaint",
162 TRACE_EVENT_SCOPE_PROCESS, "frame", GetFrame()); 154 TRACE_EVENT_SCOPE_PROCESS, "frame", GetFrame());
163 RegisterNotifySwapTime(PaintEvent::kFirstContentfulPaint); 155 RegisterNotifySwapTime(PaintEvent::kFirstContentfulPaint);
164 } 156 }
165 157
166 void PaintTiming::RegisterNotifySwapTime(PaintEvent event) { 158 void PaintTiming::RegisterNotifySwapTime(PaintEvent event) {
167 // ReportSwapTime on layerTreeView will queue a swap-promise, the callback is 159 // ReportSwapTime on layerTreeView will queue a swap-promise, the callback is
168 // called when the swap for current render frame completes or fails to happen. 160 // called when the swap for current render frame completes or fails to happen.
169 if (!GetFrame() || !GetFrame()->GetPage()) 161 if (!GetFrame() || !GetFrame()->GetPage())
170 return; 162 return;
171 if (WebLayerTreeView* layerTreeView = 163 if (WebLayerTreeView* layerTreeView =
172 GetFrame()->GetPage()->GetChromeClient().GetWebLayerTreeView( 164 GetFrame()->GetPage()->GetChromeClient().GetWebLayerTreeView(
173 GetFrame())) { 165 GetFrame())) {
174 layerTreeView->NotifySwapTime(ConvertToBaseCallback( 166 layerTreeView->NotifySwapTime(ConvertToBaseCallback(
175 WTF::Bind(&PaintTiming::ReportSwapTime, 167 WTF::Bind(&PaintTiming::ReportSwapTime,
176 WrapCrossThreadWeakPersistent(this), event))); 168 WrapCrossThreadWeakPersistent(this), event)));
177 } 169 }
178 } 170 }
179 171
180 void PaintTiming::ReportSwapTime(PaintEvent event, 172 void PaintTiming::ReportSwapTime(PaintEvent event,
181 bool did_swap, 173 bool did_swap,
182 double timestamp) { 174 double timestamp) {
183 if (!did_swap) 175 if (!did_swap)
184 return; 176 return;
177
178 Performance* performance = GetPerformanceInstance(GetFrame());
185 switch (event) { 179 switch (event) {
186 case PaintEvent::kFirstPaint: 180 case PaintEvent::kFirstPaint:
187 first_paint_swap_ = timestamp; 181 first_paint_swap_ = timestamp;
182 if (performance)
183 performance->AddFirstPaintTiming(first_paint_);
188 return; 184 return;
189 case PaintEvent::kFirstContentfulPaint: 185 case PaintEvent::kFirstContentfulPaint:
190 first_contentful_paint_swap_ = timestamp; 186 first_contentful_paint_swap_ = timestamp;
187 if (performance)
188 performance->AddFirstContentfulPaintTiming(first_contentful_paint_);
191 return; 189 return;
192 case PaintEvent::kFirstMeaningfulPaint: 190 case PaintEvent::kFirstMeaningfulPaint:
193 first_meaningful_paint_swap_ = timestamp; 191 first_meaningful_paint_swap_ = timestamp;
194 return; 192 return;
195 } 193 }
196 NOTREACHED(); 194 NOTREACHED();
197 } 195 }
198 196
199 } // namespace blink 197 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/performance-timing/paint-timing/observable.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698