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

Side by Side Diff: chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc

Issue 2152683004: Refactor PageLoadMetricsObserver completion callback policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@relevantloads
Patch Set: fix metric Created 4 years, 5 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
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 "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h" 5 #include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_ob server.h"
6 6
7 #include "components/page_load_metrics/browser/page_load_metrics_util.h" 7 #include "components/page_load_metrics/browser/page_load_metrics_util.h"
8 8
9 using page_load_metrics::UserAbortType; 9 using page_load_metrics::UserAbortType;
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 NOTREACHED() << "Received UserAbortType::ABORT_OTHER for committed load."; 160 NOTREACHED() << "Received UserAbortType::ABORT_OTHER for committed load.";
161 return; 161 return;
162 case UserAbortType::ABORT_NONE: 162 case UserAbortType::ABORT_NONE:
163 case UserAbortType::ABORT_LAST_ENTRY: 163 case UserAbortType::ABORT_LAST_ENTRY:
164 NOTREACHED(); 164 NOTREACHED();
165 return; 165 return;
166 } 166 }
167 NOTREACHED(); 167 NOTREACHED();
168 } 168 }
169 169
170 bool ShouldTrackMetrics(
171 const page_load_metrics::PageLoadExtraInfo& extra_info) {
172 UserAbortType abort_type = extra_info.abort_type;
173 if (abort_type == UserAbortType::ABORT_NONE)
174 return false;
175
176 DCHECK(extra_info.time_to_abort);
177
178 // Don't log abort times if the page was backgrounded before the abort event.
179 if (!WasStartedInForegroundOptionalEventInForeground(extra_info.time_to_abort,
180 extra_info))
181 return false;
182
183 return true;
184 }
185
170 } // namespace 186 } // namespace
171 187
172 AbortsPageLoadMetricsObserver::AbortsPageLoadMetricsObserver() {} 188 AbortsPageLoadMetricsObserver::AbortsPageLoadMetricsObserver() {}
173 189
174 void AbortsPageLoadMetricsObserver::OnComplete( 190 void AbortsPageLoadMetricsObserver::OnComplete(
175 const page_load_metrics::PageLoadTiming& timing, 191 const page_load_metrics::PageLoadTiming& timing,
176 const page_load_metrics::PageLoadExtraInfo& extra_info) { 192 const page_load_metrics::PageLoadExtraInfo& extra_info) {
177 UserAbortType abort_type = extra_info.abort_type; 193 if (!ShouldTrackMetrics(extra_info))
178 if (abort_type == UserAbortType::ABORT_NONE)
179 return; 194 return;
180 195
181 DCHECK(extra_info.time_to_abort); 196 // If we did not receive any timing IPCs from the render process, we can't
182 197 // know for certain if the page was truly aborted before paint, or if the
183 // Don't log abort times if the page was backgrounded before the abort event. 198 // abort happened before we received the IPC from the render process. Thus, we
184 if (!WasStartedInForegroundOptionalEventInForeground(extra_info.time_to_abort, 199 // do not log aborts for these page loads. Tracked page loads that receive no
185 extra_info)) 200 // timing IPCs are tracked via the ERR_NO_IPCS_RECEIVED error code in the
201 // PageLoad.Events.InternalError histogram, so we can keep track of how often
202 // this happens.
203 if (timing.IsEmpty())
186 return; 204 return;
187 205
188 const base::TimeDelta& time_to_abort = extra_info.time_to_abort.value(); 206 const base::TimeDelta& time_to_abort = extra_info.time_to_abort.value();
207 if (timing.parse_start && time_to_abort >= timing.parse_start &&
208 (!timing.parse_stop || timing.parse_stop >= time_to_abort)) {
209 RecordAbortDuringParse(extra_info.abort_type, time_to_abort);
210 }
211 if (!timing.first_paint || timing.first_paint >= time_to_abort) {
212 RecordAbortAfterCommitBeforePaint(extra_info.abort_type, time_to_abort);
213 }
214 }
189 215
190 if (!extra_info.time_to_commit) { 216 void AbortsPageLoadMetricsObserver::OnFailedProvisionalLoad(
191 RecordAbortBeforeCommit(abort_type, time_to_abort); 217 const page_load_metrics::FailedProvisionalLoadInfo& failed_load_info,
192 return; 218 const page_load_metrics::PageLoadExtraInfo& extra_info) {
193 } 219 if (!ShouldTrackMetrics(extra_info))
194
195 // If we have a committed load but |timing.IsEmpty()|, then this load was not
196 // tracked by the renderer. In this case, it is not possible to know whether
197 // the abort signals came before the page painted. Additionally, for
198 // consistency with PageLoad.(Document|Paint|Parse)Timing metrics recorded by
199 // the CorePageLoadMetricsObserver, we ignore non-render-tracked loads when
200 // tracking aborts after commit.
201 if (timing.IsEmpty())
202 return; 220 return;
203 221
204 if (timing.parse_start && time_to_abort >= timing.parse_start && 222 RecordAbortBeforeCommit(extra_info.abort_type,
205 (!timing.parse_stop || timing.parse_stop >= time_to_abort)) { 223 extra_info.time_to_abort.value());
206 RecordAbortDuringParse(abort_type, time_to_abort);
207 }
208 if (!timing.first_paint || timing.first_paint >= time_to_abort) {
209 RecordAbortAfterCommitBeforePaint(abort_type, time_to_abort);
210 }
211 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698