Index: chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc |
diff --git a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc |
index 41c7e02adaa7c8842baacc815cee4e5dca298172..ab3805a6d6cd0d80af85a17ee9876870e04f1f82 100644 |
--- a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc |
+++ b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc |
@@ -166,17 +166,23 @@ void LogPerformanceMetrics( |
} |
} |
-bool WasAbortedInForeground(UserAbortType abort_type, |
- base::TimeDelta time_to_abort, |
- const page_load_metrics::PageLoadExtraInfo& info) { |
- if (time_to_abort.is_zero()) |
+bool WasAbortedInForeground( |
+ UserAbortType abort_type, |
+ const base::Optional<base::TimeDelta>& time_to_abort, |
+ const page_load_metrics::PageLoadExtraInfo& info) { |
+ if (!time_to_abort) |
return false; |
if (abort_type == UserAbortType::ABORT_NONE) |
return false; |
- if (WasStartedInForegroundEventInForeground(time_to_abort, info)) |
+ if (WasStartedInForegroundOptionalEventInForeground(time_to_abort, info)) |
return true; |
- DCHECK_GT(time_to_abort, info.first_background_time); |
- base::TimeDelta bg_abort_delta = time_to_abort - info.first_background_time; |
+ if (!info.started_in_foreground) |
+ return false; |
+ |
+ const base::TimeDelta& time_to_abort_val = time_to_abort.value(); |
+ const base::TimeDelta& time_to_first_bg = info.first_background_time.value(); |
+ DCHECK_GT(time_to_abort_val, time_to_first_bg); |
+ base::TimeDelta bg_abort_delta = time_to_abort_val - time_to_first_bg; |
// Consider this a foregrounded abort if it occurred within 100ms of a |
// background. This is needed for closing some tabs, where the signal for |
// background is often slightly ahead of the signal for close. |
@@ -367,10 +373,10 @@ void FromGWSPageLoadMetricsLogger::OnComplete( |
// consistency with PageLoad.Timing2 metrics, we ignore non-render-tracked |
// loads when tracking aborts after commit. |
UserAbortType abort_type = extra_info.abort_type; |
- base::TimeDelta time_to_abort = extra_info.time_to_abort; |
bool aborted_in_foreground = |
- WasAbortedInForeground(abort_type, time_to_abort, extra_info); |
+ WasAbortedInForeground(abort_type, extra_info.time_to_abort, extra_info); |
+ const base::TimeDelta& time_to_abort = extra_info.time_to_abort.value(); |
if (!extra_info.committed_url.is_empty()) { |
LogPerformanceMetrics(timing, extra_info); |
bool aborted_before_paint = |