Chromium Code Reviews| 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 5ca418e271de989d0e38c62fb8fb3c904efb6dfb..8c1e201a23700b1483b628ed0c8b60d36abc42b2 100644 |
| --- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc |
| +++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc |
| @@ -101,21 +101,23 @@ const char kErrorEvents[] = "PageLoad.Events.InternalError"; |
| } // namespace internal |
| PageLoadTracker::PageLoadTracker( |
| bool in_foreground, |
| PageLoadMetricsEmbedderInterface* embedder_interface, |
| content::NavigationHandle* navigation_handle) |
| : renderer_tracked_(false), |
| navigation_start_(navigation_handle->NavigationStart()), |
| abort_type_(ABORT_NONE), |
| started_in_foreground_(in_foreground), |
| - embedder_interface_(embedder_interface) { |
| + embedder_interface_(embedder_interface), |
| + is_using_lofi_(false), |
| + was_fetched_via_data_reduction_proxy_(false) { |
| embedder_interface_->RegisterObservers(this); |
| for (const auto& observer : observers_) { |
| observer->OnStart(navigation_handle); |
| } |
| } |
| PageLoadTracker::~PageLoadTracker() { |
| const PageLoadExtraInfo info = GetPageLoadMetricsInfo(); |
| if (!info.time_to_commit.is_zero() && renderer_tracked() && |
| timing_.IsEmpty()) { |
| @@ -183,20 +185,29 @@ bool PageLoadTracker::HasBackgrounded() { |
| void PageLoadTracker::set_renderer_tracked(bool renderer_tracked) { |
| renderer_tracked_ = renderer_tracked; |
| } |
| void PageLoadTracker::AddObserver( |
| scoped_ptr<PageLoadMetricsObserver> observer) { |
| observers_.push_back(std::move(observer)); |
| } |
| +void PageLoadTracker::set_is_using_lofi(bool is_using_lofi) { |
| + is_using_lofi_ = is_using_lofi; |
| +} |
| + |
| +void PageLoadTracker::set_was_fetched_via_data_reduction_proxy( |
| + bool was_fetched_via_data_reduction_proxy) { |
| + was_fetched_via_data_reduction_proxy_ = was_fetched_via_data_reduction_proxy; |
| +} |
| + |
| PageLoadExtraInfo PageLoadTracker::GetPageLoadMetricsInfo() { |
| base::TimeDelta first_background_time; |
| base::TimeDelta first_foreground_time; |
| base::TimeDelta time_to_abort; |
| base::TimeDelta time_to_commit; |
| 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_; |
| if (abort_type_ != ABORT_NONE) { |
| @@ -204,23 +215,25 @@ PageLoadExtraInfo PageLoadTracker::GetPageLoadMetricsInfo() { |
| time_to_abort = abort_time_ - navigation_start_; |
| } else { |
| DCHECK(abort_time_.is_null()); |
| } |
| if (!committed_url_.is_empty()) { |
| DCHECK_GT(commit_time_, navigation_start_); |
| time_to_commit = commit_time_ - navigation_start_; |
| } else { |
| DCHECK(commit_time_.is_null()); |
| } |
| - return PageLoadExtraInfo(first_background_time, first_foreground_time, |
| - started_in_foreground_, committed_url_, |
| - time_to_commit, abort_type_, time_to_abort); |
| + |
| + return PageLoadExtraInfo( |
| + first_background_time, first_foreground_time, started_in_foreground_, |
| + committed_url_, time_to_commit, abort_type_, time_to_abort, |
| + is_using_lofi_, was_fetched_via_data_reduction_proxy_); |
| } |
| void PageLoadTracker::NotifyAbort(UserAbortType abort_type, |
| const base::TimeTicks& timestamp) { |
| DCHECK_NE(abort_type, ABORT_NONE); |
| // Use UpdateAbort to update an already notified PageLoadTracker. |
| if (abort_type_ != ABORT_NONE) |
| return; |
| UpdateAbortInternal(abort_type, timestamp); |
| @@ -353,20 +366,24 @@ void MetricsWebContentsObserver::DidFinishNavigation( |
| aborted_provisional_loads_.push_back(std::move(finished_nav)); |
| } |
| return; |
| } |
| // Don't treat a same-page nav as a new page load. |
| if (navigation_handle->IsSamePage()) |
| return; |
| + finished_nav->set_is_using_lofi(navigation_handle->IsUsingLofi()); |
|
bengr
2016/02/26 22:53:57
Is there an existing pattern to set the PageLoadTr
RyanSturm
2016/03/01 19:36:04
set_renderer_tracked is the only setter I see on P
|
| + finished_nav->set_was_fetched_via_data_reduction_proxy( |
| + navigation_handle->WasFetchedViaDataReductionProxy()); |
| + |
| // Notify other loads that they may have been aborted by this committed load. |
| // Note that by using the committed navigation start as the abort cause, we |
| // lose data on provisional loads that were aborted by other provisional |
| // loads. Those will either be listed as ABORT_OTHER or as being aborted by |
| // this load. |
| NotifyAbortAllLoadsWithTimestamp( |
| AbortTypeForPageTransition(navigation_handle->GetPageTransition()), |
| navigation_handle->NavigationStart()); |
| committed_load_ = std::move(finished_nav); |