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) { |
Bryan McQuade
2015/12/09 20:35:23
nit: should we do this in a switch/case? should be
Charlie Harrison
2015/12/09 22:46:43
I'll hold off on this until kinuko@ chimes in. I'm
kinuko
2015/12/10 08:39:35
Either would work, but yeah I think I also prefer
|
+ 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) { |
Bryan McQuade
2015/12/09 20:35:23
same suggestion for switch/case
Bryan McQuade
2015/12/09 20:35:23
i know it'd be odd, but if extra_info.has_commit i
Charlie Harrison
2015/12/09 22:46:43
The timing object should always be empty for provi
|
+ 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); |
+ } |
+ } |
+} |