| Index: components/page_load_metrics/browser/metrics_web_contents_observer.cc
|
| diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.cc b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
|
| index 58ac2356a78dce652dd191a608476267d57fa99a..fbe58d0bddaf9fc225cb2c5ac38c7da1e4731b7c 100644
|
| --- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc
|
| +++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
|
| @@ -76,11 +76,6 @@ bool IsValidPageLoadTiming(const PageLoadTiming& timing) {
|
| return true;
|
| }
|
|
|
| -base::Time WallTimeFromTimeTicks(const base::TimeTicks& time) {
|
| - return base::Time::FromDoubleT(
|
| - (time - base::TimeTicks::UnixEpoch()).InSecondsF());
|
| -}
|
| -
|
| void RecordInternalError(InternalErrorLoadEvent event) {
|
| UMA_HISTOGRAM_ENUMERATION(kErrorEvents, event, ERR_LAST_ENTRY);
|
| }
|
| @@ -120,9 +115,11 @@ uint64_t RapporHistogramBucketIndex(const base::TimeDelta& time) {
|
|
|
| PageLoadTracker::PageLoadTracker(
|
| bool in_foreground,
|
| + content::NavigationHandle* navigation_handle,
|
| rappor::RapporService* const rappor_service,
|
| base::ObserverList<PageLoadMetricsObserver, true>* observers)
|
| : has_commit_(false),
|
| + navigation_start_(navigation_handle->GetNavigationStart()),
|
| started_in_foreground_(in_foreground),
|
| rappor_service_(rappor_service),
|
| observers_(observers) {}
|
| @@ -181,14 +178,10 @@ bool PageLoadTracker::HasBackgrounded() {
|
| PageLoadExtraInfo PageLoadTracker::GetPageLoadMetricsInfo() {
|
| base::TimeDelta first_background_time;
|
| base::TimeDelta first_foreground_time;
|
| - if (!background_time_.is_null() && started_in_foreground_) {
|
| - first_background_time =
|
| - WallTimeFromTimeTicks(background_time_) - timing_.navigation_start;
|
| - }
|
| - if (!foreground_time_.is_null() && !started_in_foreground_) {
|
| - first_foreground_time =
|
| - WallTimeFromTimeTicks(foreground_time_) - timing_.navigation_start;
|
| - }
|
| + if (!background_time_.is_null() && started_in_foreground_)
|
| + first_background_time = background_time_ - navigation_start_;
|
| + if (!foreground_time_.is_null() && !started_in_foreground_)
|
| + first_foreground_time = foreground_time_ - navigation_start_;
|
| return PageLoadExtraInfo(first_background_time, first_foreground_time,
|
| started_in_foreground_);
|
| }
|
| @@ -212,9 +205,8 @@ const GURL& PageLoadTracker::GetCommittedURL() {
|
| // backgrounded.
|
| base::TimeDelta PageLoadTracker::GetBackgroundDelta() {
|
| if (started_in_foreground_) {
|
| - if (background_time_.is_null())
|
| - return base::TimeDelta::Max();
|
| - return WallTimeFromTimeTicks(background_time_) - timing_.navigation_start;
|
| + return background_time_.is_null() ? base::TimeDelta::Max()
|
| + : background_time_ - navigation_start_;
|
| }
|
| return base::TimeDelta();
|
| }
|
| @@ -300,9 +292,8 @@ void PageLoadTracker::RecordTimingHistograms() {
|
| if (!background_time_.is_null()) {
|
| PAGE_LOAD_HISTOGRAM(kHistogramFirstBackground, background_delta);
|
| } else if (!foreground_time_.is_null()) {
|
| - PAGE_LOAD_HISTOGRAM(
|
| - kHistogramFirstForeground,
|
| - WallTimeFromTimeTicks(foreground_time_) - timing_.navigation_start);
|
| + PAGE_LOAD_HISTOGRAM(kHistogramFirstForeground,
|
| + foreground_time_ - navigation_start_);
|
| }
|
| }
|
|
|
| @@ -416,9 +407,10 @@ void MetricsWebContentsObserver::DidStartNavigation(
|
| // Passing a raw pointer to observers_ is safe because the
|
| // MetricsWebContentsObserver owns the PageLoadMetricsObserver list and is
|
| // torn down after the PageLoadTracker.
|
| - provisional_loads_.insert(navigation_handle,
|
| - make_scoped_ptr(new PageLoadTracker(
|
| - in_foreground_, rappor_service_, &observers_)));
|
| + provisional_loads_.insert(
|
| + navigation_handle,
|
| + make_scoped_ptr(new PageLoadTracker(in_foreground_, navigation_handle,
|
| + rappor_service_, &observers_)));
|
| }
|
|
|
| void MetricsWebContentsObserver::DidFinishNavigation(
|
|
|