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

Side by Side Diff: components/page_load_metrics/browser/metrics_web_contents_observer.cc

Issue 1817263003: Allow TimeTicks for serialized page load operations to be equal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add param Created 4 years, 9 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 embedder_interface_(embedder_interface) { 185 embedder_interface_(embedder_interface) {
186 DCHECK(!navigation_handle->HasCommitted()); 186 DCHECK(!navigation_handle->HasCommitted());
187 embedder_interface_->RegisterObservers(this); 187 embedder_interface_->RegisterObservers(this);
188 for (const auto& observer : observers_) { 188 for (const auto& observer : observers_) {
189 observer->OnStart(navigation_handle); 189 observer->OnStart(navigation_handle);
190 } 190 }
191 } 191 }
192 192
193 PageLoadTracker::~PageLoadTracker() { 193 PageLoadTracker::~PageLoadTracker() {
194 const PageLoadExtraInfo info = GetPageLoadMetricsInfo(); 194 const PageLoadExtraInfo info = GetPageLoadMetricsInfo();
195 if (!info.time_to_commit.is_zero() && renderer_tracked() && 195 if (info.committed && renderer_tracked() && timing_.IsEmpty()) {
196 timing_.IsEmpty()) {
197 RecordInternalError(ERR_NO_IPCS_RECEIVED); 196 RecordInternalError(ERR_NO_IPCS_RECEIVED);
198 } 197 }
199 // Recall that trackers that are given ABORT_UNKNOWN_NAVIGATION have their 198 // Recall that trackers that are given ABORT_UNKNOWN_NAVIGATION have their
200 // chain length added to the next navigation. Take care not to double count 199 // chain length added to the next navigation. Take care not to double count
201 // them. Also do not double count committed loads, which call this already. 200 // them. Also do not double count committed loads, which call this already.
202 if (commit_time_.is_null() && abort_type_ != ABORT_UNKNOWN_NAVIGATION) 201 if (commit_time_.is_null() && abort_type_ != ABORT_UNKNOWN_NAVIGATION)
203 LogAbortChainHistograms(nullptr); 202 LogAbortChainHistograms(nullptr);
204 203
205 for (const auto& observer : observers_) { 204 for (const auto& observer : observers_) {
206 observer->OnComplete(timing_, info); 205 observer->OnComplete(timing_, info);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 void PageLoadTracker::AddObserver( 323 void PageLoadTracker::AddObserver(
325 scoped_ptr<PageLoadMetricsObserver> observer) { 324 scoped_ptr<PageLoadMetricsObserver> observer) {
326 observers_.push_back(std::move(observer)); 325 observers_.push_back(std::move(observer));
327 } 326 }
328 327
329 PageLoadExtraInfo PageLoadTracker::GetPageLoadMetricsInfo() { 328 PageLoadExtraInfo PageLoadTracker::GetPageLoadMetricsInfo() {
330 base::TimeDelta first_background_time; 329 base::TimeDelta first_background_time;
331 base::TimeDelta first_foreground_time; 330 base::TimeDelta first_foreground_time;
332 base::TimeDelta time_to_abort; 331 base::TimeDelta time_to_abort;
333 base::TimeDelta time_to_commit; 332 base::TimeDelta time_to_commit;
333 bool committed = false;
334 if (!background_time_.is_null()) 334 if (!background_time_.is_null())
335 first_background_time = background_time_ - navigation_start_; 335 first_background_time = background_time_ - navigation_start_;
336 if (!foreground_time_.is_null()) 336 if (!foreground_time_.is_null())
337 first_foreground_time = foreground_time_ - navigation_start_; 337 first_foreground_time = foreground_time_ - navigation_start_;
338 if (abort_type_ != ABORT_NONE) { 338 if (abort_type_ != ABORT_NONE) {
339 DCHECK_GT(abort_time_, navigation_start_); 339 DCHECK_GE(abort_time_, navigation_start_);
340 time_to_abort = abort_time_ - navigation_start_; 340 time_to_abort = abort_time_ - navigation_start_;
341 } else { 341 } else {
342 DCHECK(abort_time_.is_null()); 342 DCHECK(abort_time_.is_null());
343 } 343 }
344 344
345 if (!commit_time_.is_null()) { 345 if (!commit_time_.is_null()) {
346 DCHECK_GT(commit_time_, navigation_start_); 346 DCHECK_GE(commit_time_, navigation_start_);
347 time_to_commit = commit_time_ - navigation_start_; 347 time_to_commit = commit_time_ - navigation_start_;
348 committed = true;
348 } else { 349 } else {
349 DCHECK(commit_time_.is_null()); 350 DCHECK(commit_time_.is_null());
350 } 351 }
352
351 return PageLoadExtraInfo(first_background_time, first_foreground_time, 353 return PageLoadExtraInfo(first_background_time, first_foreground_time,
352 started_in_foreground_, 354 started_in_foreground_, committed ? url_ : GURL(),
353 commit_time_.is_null() ? GURL() : url_, 355 committed, time_to_commit, abort_type_,
354 time_to_commit, abort_type_, time_to_abort); 356 time_to_abort);
355 } 357 }
356 358
357 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, 359 void PageLoadTracker::NotifyAbort(UserAbortType abort_type,
358 base::TimeTicks timestamp) { 360 base::TimeTicks timestamp) {
359 DCHECK_NE(abort_type, ABORT_NONE); 361 DCHECK_NE(abort_type, ABORT_NONE);
360 // Use UpdateAbort to update an already notified PageLoadTracker. 362 // Use UpdateAbort to update an already notified PageLoadTracker.
361 if (abort_type_ != ABORT_NONE) 363 if (abort_type_ != ABORT_NONE)
362 return; 364 return;
363 365
364 UpdateAbortInternal(abort_type, timestamp); 366 UpdateAbortInternal(abort_type, timestamp);
(...skipping 30 matching lines...) Expand all
395 base::TimeTicks timestamp) { 397 base::TimeTicks timestamp) {
396 // When a provisional navigation commits, that navigation's start time is 398 // When a provisional navigation commits, that navigation's start time is
397 // interpreted as the abort time for other provisional loads in the tab. 399 // interpreted as the abort time for other provisional loads in the tab.
398 // However, this only makes sense if the committed load started after the 400 // However, this only makes sense if the committed load started after the
399 // aborted provisional loads started. Thus we ignore cases where the committed 401 // aborted provisional loads started. Thus we ignore cases where the committed
400 // load started before the aborted provisional load, as this would result in 402 // load started before the aborted provisional load, as this would result in
401 // recording a negative time-to-abort. The real issue here is that we have to 403 // recording a negative time-to-abort. The real issue here is that we have to
402 // infer the cause of aborts. It would be better if the navigation code could 404 // infer the cause of aborts. It would be better if the navigation code could
403 // instead report the actual cause of an aborted navigation. See crbug/571647 405 // instead report the actual cause of an aborted navigation. See crbug/571647
404 // for details. 406 // for details.
405 if (timestamp <= navigation_start_) { 407 if (timestamp < navigation_start_) {
406 RecordInternalError(ERR_ABORT_BEFORE_NAVIGATION_START); 408 RecordInternalError(ERR_ABORT_BEFORE_NAVIGATION_START);
407 abort_type_ = ABORT_NONE; 409 abort_type_ = ABORT_NONE;
408 abort_time_ = base::TimeTicks(); 410 abort_time_ = base::TimeTicks();
409 return; 411 return;
410 } 412 }
411 abort_type_ = abort_type; 413 abort_type_ = abort_type;
412 abort_time_ = timestamp; 414 abort_time_ = timestamp;
413 } 415 }
414 416
415 // static 417 // static
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 682
681 if (!committed_load_->UpdateTiming(timing)) { 683 if (!committed_load_->UpdateTiming(timing)) {
682 // If the page load tracker cannot update its timing, something is wrong 684 // If the page load tracker cannot update its timing, something is wrong
683 // with the IPC (it's from another load, or it's invalid in some other way). 685 // with the IPC (it's from another load, or it's invalid in some other way).
684 // We expect this to be a rare occurrence. 686 // We expect this to be a rare occurrence.
685 RecordInternalError(ERR_BAD_TIMING_IPC); 687 RecordInternalError(ERR_BAD_TIMING_IPC);
686 } 688 }
687 } 689 }
688 690
689 } // namespace page_load_metrics 691 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698