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 49faa4f434487bef4b222ab5f066b7375bf2426b..3cf2d12708ffabf4a0498f9c5d0d0d77c458117f 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 |
@@ -11,7 +11,7 @@ |
#include "chrome/common/page_load_metrics/page_load_timing.h" |
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
-using page_load_metrics::UserAbortType; |
+using page_load_metrics::PageAbortReason; |
namespace internal { |
@@ -100,114 +100,113 @@ const char kHistogramFromGWSAbortBackgroundBeforeInteraction[] = |
namespace { |
-void LogCommittedAbortsBeforePaint(UserAbortType abort_type, |
- base::TimeDelta time_to_abort) { |
- switch (abort_type) { |
- case UserAbortType::ABORT_STOP: |
+void LogCommittedAbortsBeforePaint(PageAbortReason abort_reason, |
+ base::TimeDelta page_end_time) { |
+ switch (abort_reason) { |
+ case PageAbortReason::ABORT_STOP: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortStopBeforePaint, |
- time_to_abort); |
+ page_end_time); |
break; |
- case UserAbortType::ABORT_CLOSE: |
+ case PageAbortReason::ABORT_CLOSE: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortCloseBeforePaint, |
- time_to_abort); |
+ page_end_time); |
break; |
- case UserAbortType::ABORT_NEW_NAVIGATION: |
+ case PageAbortReason::ABORT_NEW_NAVIGATION: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortNewNavigationBeforePaint, |
- time_to_abort); |
+ page_end_time); |
break; |
- case UserAbortType::ABORT_RELOAD: |
+ case PageAbortReason::ABORT_RELOAD: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortReloadBeforePaint, |
- time_to_abort); |
+ page_end_time); |
break; |
- case UserAbortType::ABORT_FORWARD_BACK: |
+ case PageAbortReason::ABORT_FORWARD_BACK: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortForwardBackBeforePaint, |
- time_to_abort); |
+ page_end_time); |
break; |
- case UserAbortType::ABORT_BACKGROUND: |
+ case PageAbortReason::ABORT_BACKGROUND: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortBackgroundBeforePaint, |
- time_to_abort); |
+ page_end_time); |
break; |
default: |
// These should only be logged for provisional aborts. |
- DCHECK_NE(abort_type, UserAbortType::ABORT_OTHER); |
+ DCHECK_NE(abort_reason, PageAbortReason::ABORT_OTHER); |
break; |
} |
} |
-void LogAbortsAfterPaintBeforeInteraction(UserAbortType abort_type, |
- base::TimeDelta time_to_abort) { |
- switch (abort_type) { |
- case UserAbortType::ABORT_STOP: |
+void LogAbortsAfterPaintBeforeInteraction( |
+ const page_load_metrics::PageAbortInfo& abort_info) { |
+ switch (abort_info.reason) { |
+ case PageAbortReason::ABORT_STOP: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortStopBeforeInteraction, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_CLOSE: |
+ case PageAbortReason::ABORT_CLOSE: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortCloseBeforeInteraction, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_NEW_NAVIGATION: |
+ case PageAbortReason::ABORT_NEW_NAVIGATION: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortNewNavigationBeforeInteraction, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_RELOAD: |
+ case PageAbortReason::ABORT_RELOAD: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortReloadBeforeInteraction, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_FORWARD_BACK: |
+ case PageAbortReason::ABORT_FORWARD_BACK: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortForwardBackBeforeInteraction, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_BACKGROUND: |
+ case PageAbortReason::ABORT_BACKGROUND: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortBackgroundBeforeInteraction, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
default: |
// These should only be logged for provisional aborts. |
- DCHECK_NE(abort_type, UserAbortType::ABORT_OTHER); |
+ DCHECK_NE(abort_info.reason, PageAbortReason::ABORT_OTHER); |
break; |
} |
} |
-void LogProvisionalAborts(UserAbortType abort_type, |
- base::TimeDelta time_to_abort) { |
- switch (abort_type) { |
- case UserAbortType::ABORT_STOP: |
+void LogProvisionalAborts(const page_load_metrics::PageAbortInfo& abort_info) { |
+ switch (abort_info.reason) { |
+ case PageAbortReason::ABORT_STOP: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortStopBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_CLOSE: |
+ case PageAbortReason::ABORT_CLOSE: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortCloseBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_OTHER: |
+ case PageAbortReason::ABORT_OTHER: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortOtherBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_NEW_NAVIGATION: |
+ case PageAbortReason::ABORT_NEW_NAVIGATION: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortNewNavigationBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_RELOAD: |
+ case PageAbortReason::ABORT_RELOAD: |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFromGWSAbortReloadBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_FORWARD_BACK: |
+ case PageAbortReason::ABORT_FORWARD_BACK: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortForwardBackBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
- case UserAbortType::ABORT_BACKGROUND: |
+ case PageAbortReason::ABORT_BACKGROUND: |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramFromGWSAbortBackgroundBeforeCommit, |
- time_to_abort); |
+ abort_info.time_to_abort); |
break; |
default: |
NOTREACHED(); |
@@ -216,24 +215,21 @@ void LogProvisionalAborts(UserAbortType abort_type, |
} |
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) |
+ const page_load_metrics::PageLoadExtraInfo& info, |
+ const page_load_metrics::PageAbortInfo& abort_info) { |
+ if (!info.started_in_foreground || |
+ abort_info.reason == PageAbortReason::ABORT_NONE) |
return false; |
+ |
+ base::Optional<base::TimeDelta> time_to_abort(abort_info.time_to_abort); |
if (WasStartedInForegroundOptionalEventInForeground(time_to_abort, info)) |
return true; |
- if (!info.started_in_foreground) |
- return false; |
- const base::TimeDelta time_to_abort_val = time_to_abort.value(); |
const base::TimeDelta time_to_first_background = |
info.first_background_time.value(); |
- DCHECK_GT(time_to_abort_val, time_to_first_background); |
+ DCHECK_GT(abort_info.time_to_abort, time_to_first_background); |
base::TimeDelta background_abort_delta = |
- time_to_abort_val - time_to_first_background; |
+ abort_info.time_to_abort - time_to_first_background; |
// 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. |
@@ -243,14 +239,12 @@ bool WasAbortedInForeground( |
} |
bool WasAbortedBeforeInteraction( |
- UserAbortType abort_type, |
- const base::Optional<base::TimeDelta>& time_to_interaction, |
- const base::Optional<base::TimeDelta>& time_to_abort) { |
+ const page_load_metrics::PageAbortInfo& abort_info, |
+ const base::Optional<base::TimeDelta>& time_to_interaction) { |
// These conditions should be guaranteed by the call to |
// WasAbortedInForeground, which is called before WasAbortedBeforeInteraction |
// gets invoked. |
- DCHECK(time_to_abort); |
- DCHECK(abort_type != UserAbortType::ABORT_NONE); |
+ DCHECK(abort_info.reason != PageAbortReason::ABORT_NONE); |
if (!time_to_interaction) |
return true; |
@@ -264,13 +258,13 @@ bool WasAbortedBeforeInteraction( |
// 1000ms is enough to perform a pull to reload / forward_back gesture. |
// It's also too short a time for a user to consume any content |
// revealed by the interaction. |
- if (abort_type == UserAbortType::ABORT_RELOAD || |
- abort_type == UserAbortType::ABORT_FORWARD_BACK) { |
+ if (abort_info.reason == PageAbortReason::ABORT_RELOAD || |
+ abort_info.reason == PageAbortReason::ABORT_FORWARD_BACK) { |
return time_to_interaction.value() + |
base::TimeDelta::FromMilliseconds(1000) > |
- time_to_abort; |
+ abort_info.time_to_abort; |
} else { |
- return time_to_interaction > time_to_abort; |
+ return time_to_interaction > abort_info.time_to_abort; |
} |
} |
@@ -532,8 +526,8 @@ void FromGWSPageLoadMetricsLogger::OnComplete( |
if (!ShouldLogPostCommitMetrics(extra_info.url)) |
return; |
- UserAbortType abort_type = extra_info.abort_type; |
- if (!WasAbortedInForeground(abort_type, extra_info.time_to_abort, extra_info)) |
+ page_load_metrics::PageAbortInfo abort_info = GetPageAbortInfo(extra_info); |
+ if (!WasAbortedInForeground(extra_info, abort_info)) |
return; |
// If we did not receive any timing IPCs from the render process, we can't |
@@ -546,13 +540,11 @@ void FromGWSPageLoadMetricsLogger::OnComplete( |
if (timing.IsEmpty()) |
return; |
- base::TimeDelta time_to_abort = extra_info.time_to_abort.value(); |
- if (!timing.first_paint || timing.first_paint >= time_to_abort) { |
- LogCommittedAbortsBeforePaint(abort_type, time_to_abort); |
- } else if (WasAbortedBeforeInteraction(abort_type, |
- first_user_interaction_after_paint_, |
- extra_info.time_to_abort)) { |
- LogAbortsAfterPaintBeforeInteraction(abort_type, time_to_abort); |
+ if (!timing.first_paint || timing.first_paint >= abort_info.time_to_abort) { |
+ LogCommittedAbortsBeforePaint(abort_info.reason, abort_info.time_to_abort); |
+ } else if (WasAbortedBeforeInteraction(abort_info, |
+ first_user_interaction_after_paint_)) { |
+ LogAbortsAfterPaintBeforeInteraction(abort_info); |
} |
} |
@@ -562,11 +554,11 @@ void FromGWSPageLoadMetricsLogger::OnFailedProvisionalLoad( |
if (!ShouldLogFailedProvisionalLoadMetrics()) |
return; |
- UserAbortType abort_type = extra_info.abort_type; |
- if (!WasAbortedInForeground(abort_type, extra_info.time_to_abort, extra_info)) |
+ page_load_metrics::PageAbortInfo abort_info = GetPageAbortInfo(extra_info); |
+ if (!WasAbortedInForeground(extra_info, abort_info)) |
return; |
- LogProvisionalAborts(abort_type, extra_info.time_to_abort.value()); |
+ LogProvisionalAborts(abort_info); |
} |
bool FromGWSPageLoadMetricsLogger::ShouldLogFailedProvisionalLoadMetrics() { |