Index: chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc |
diff --git a/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc |
index d4d6ea2cc84113efbccc819c87a53fbd9d1c9818..7558508e28a20fa505294158ab12ed571377c14c 100644 |
--- a/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc |
+++ b/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc |
@@ -111,6 +111,13 @@ void CorePageLoadMetricsObserver::OnComplete( |
RecordRappor(timing, info); |
} |
+CorePageLoadMetricsObserver::FailedProvisionalLoadInfo:: |
+ FailedProvisionalLoadInfo() |
+ : error(net::OK) {} |
+ |
+CorePageLoadMetricsObserver::FailedProvisionalLoadInfo:: |
+ ~FailedProvisionalLoadInfo() {} |
+ |
void CorePageLoadMetricsObserver::OnFailedProvisionalLoad( |
content::NavigationHandle* navigation_handle) { |
// Only handle actual failures; provisional loads that failed due to another |
@@ -134,38 +141,44 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms( |
const page_load_metrics::PageLoadExtraInfo& info) { |
// Record metrics for pages which starts in the foreground and is backgrounded |
// prior to the first paint. |
- if (info.started_in_foreground && !info.first_background_time.is_zero() && |
+ if (info.started_in_foreground && info.first_background_time && |
(timing.first_paint.is_zero() || |
- timing.first_paint > info.first_background_time)) { |
- if (!info.time_to_commit.is_zero()) { |
+ timing.first_paint > info.first_background_time.value())) { |
+ const base::TimeDelta& first_background_time = |
+ info.first_background_time.value(); |
+ |
+ if (info.time_to_commit) { |
PAGE_LOAD_HISTOGRAM(internal::kHistogramBackgroundBeforePaint, |
- info.first_background_time); |
+ first_background_time); |
} else { |
PAGE_LOAD_HISTOGRAM(internal::kHistogramBackgroundBeforeCommit, |
- info.first_background_time); |
+ first_background_time); |
} |
} |
if (failed_provisional_load_info_.error != net::OK) { |
+ DCHECK(failed_provisional_load_info_.interval); |
+ |
// Ignores a background failed provisional load. |
- if (WasStartedInForegroundEventInForeground( |
+ if (WasStartedInForegroundOptionalEventInForeground( |
failed_provisional_load_info_.interval, info)) { |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFailedProvisionalLoad, |
- failed_provisional_load_info_.interval); |
+ failed_provisional_load_info_.interval.value()); |
} |
} |
// The rest of the histograms require the load to have committed and be |
// relevant. If |timing.IsEmpty()|, then this load was not tracked by the |
// renderer. |
- if (info.time_to_commit.is_zero() || timing.IsEmpty()) |
+ if (!info.time_to_commit || timing.IsEmpty()) |
return; |
- if (WasStartedInForegroundEventInForeground(info.time_to_commit, info)) { |
- PAGE_LOAD_HISTOGRAM(internal::kHistogramCommit, info.time_to_commit); |
+ const base::TimeDelta time_to_commit = info.time_to_commit.value(); |
+ if (WasStartedInForegroundOptionalEventInForeground(info.time_to_commit, |
+ info)) { |
+ PAGE_LOAD_HISTOGRAM(internal::kHistogramCommit, time_to_commit); |
} else { |
- PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramCommit, |
- info.time_to_commit); |
+ PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramCommit, time_to_commit); |
} |
if (!timing.dom_content_loaded_event_start.is_zero()) { |
if (WasStartedInForegroundEventInForeground( |
@@ -209,13 +222,13 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms( |
// - Opened in the background. |
// - Moved to the foreground prior to the first paint. |
// - Not moved back to the background prior to the first paint. |
- if (!info.started_in_foreground && !info.first_foreground_time.is_zero() && |
- timing.first_paint > info.first_foreground_time && |
- (info.first_background_time.is_zero() || |
- timing.first_paint < info.first_background_time)) { |
+ if (!info.started_in_foreground && info.first_foreground_time && |
+ timing.first_paint > info.first_foreground_time.value() && |
+ (!info.first_background_time || |
+ timing.first_paint < info.first_background_time.value())) { |
PAGE_LOAD_HISTOGRAM( |
internal::kHistogramForegroundToFirstPaint, |
- timing.first_paint - info.first_foreground_time); |
+ timing.first_paint - info.first_foreground_time.value()); |
} |
} |
if (!timing.first_text_paint.is_zero()) { |
@@ -263,13 +276,13 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms( |
// Log time to first foreground / time to first background. Log counts that we |
// started a relevant page load in the foreground / background. |
if (info.started_in_foreground) { |
- if (!info.first_background_time.is_zero()) |
+ if (info.first_background_time) |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstBackground, |
- info.first_background_time); |
+ info.first_background_time.value()); |
} else { |
- if (!info.first_foreground_time.is_zero()) |
+ if (info.first_foreground_time) |
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstForeground, |
- info.first_foreground_time); |
+ info.first_foreground_time.value()); |
} |
} |
@@ -285,7 +298,7 @@ void CorePageLoadMetricsObserver::RecordRappor( |
rappor::RapporService* rappor_service = g_browser_process->rappor_service(); |
if (!rappor_service) |
return; |
- if (info.time_to_commit.is_zero()) |
+ if (!info.time_to_commit) |
return; |
DCHECK(!info.committed_url.is_empty()); |
// Log the eTLD+1 of sites that show poor loading performance. |