| Index: chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc
|
| diff --git a/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ae026e92959695b182e7cddc2a4d8d18027f168a
|
| --- /dev/null
|
| +++ b/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.h"
|
| +
|
| +#include "components/page_load_metrics/browser/page_load_metrics_util.h"
|
| +
|
| +using page_load_metrics::UserAbortType;
|
| +
|
| +AbortsPageLoadMetricsObserver::AbortsPageLoadMetricsObserver() {}
|
| +
|
| +void AbortsPageLoadMetricsObserver::OnComplete(
|
| + const page_load_metrics::PageLoadTiming& timing,
|
| + const page_load_metrics::PageLoadExtraInfo& extra_info) {
|
| + UserAbortType abort_type = extra_info.abort_type;
|
| + if (abort_type == UserAbortType::ABORT_NONE)
|
| + return;
|
| +
|
| + const base::TimeDelta& time_to_abort = extra_info.time_to_abort;
|
| + DCHECK(!time_to_abort.is_zero());
|
| +
|
| + // Loads are not considered aborts if they painted before the abort event.
|
| + if (!timing.first_paint.is_zero() && timing.first_paint < time_to_abort)
|
| + return;
|
| +
|
| + // Don't log abort times if the page was backgrounded before the abort event.
|
| + if (GetBackgroundDelta(extra_info) < time_to_abort)
|
| + return;
|
| +
|
| + // If |timing.IsEmpty()|, then this load was not tracked by the renderer. It
|
| + // is impossible to know whether the abort signals came before the page
|
| + // painted.
|
| + if (extra_info.has_commit && !timing.IsEmpty()) {
|
| + if (abort_type == UserAbortType::ABORT_RELOAD) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortReloadBeforePaint, time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_FORWARD_BACK) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortForwardBackBeforePaint, time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_NEW_NAVIGATION) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortNewNavigationBeforePaint,
|
| + time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_STOP) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortStopBeforePaint, time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_CLOSE) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortCloseBeforePaint, time_to_abort);
|
| + } else {
|
| + DLOG(FATAL) << "Received UserAbortType::ABORT_OTHER for committed load.";
|
| + }
|
| + } else {
|
| + if (abort_type == UserAbortType::ABORT_RELOAD) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortReloadBeforeCommit, time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_FORWARD_BACK) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortForwardBackBeforeCommit,
|
| + time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_NEW_NAVIGATION) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortNewNavigationBeforeCommit,
|
| + time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_STOP) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortStopBeforeCommit, time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_CLOSE) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortCloseBeforeCommit, time_to_abort);
|
| + } else if (abort_type == UserAbortType::ABORT_OTHER) {
|
| + PAGE_LOAD_HISTOGRAM(kHistogramAbortOtherBeforeCommit, time_to_abort);
|
| + }
|
| + }
|
| +}
|
|
|