| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" | 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 abort_user_initiated_(false), | 294 abort_user_initiated_(false), |
| 295 started_in_foreground_(in_foreground), | 295 started_in_foreground_(in_foreground), |
| 296 page_transition_(navigation_handle->GetPageTransition()), | 296 page_transition_(navigation_handle->GetPageTransition()), |
| 297 num_cache_requests_(0), | 297 num_cache_requests_(0), |
| 298 num_network_requests_(0), | 298 num_network_requests_(0), |
| 299 user_gesture_(IsNavigationUserInitiated(navigation_handle)), | 299 user_gesture_(IsNavigationUserInitiated(navigation_handle)), |
| 300 aborted_chain_size_(aborted_chain_size), | 300 aborted_chain_size_(aborted_chain_size), |
| 301 aborted_chain_size_same_url_(aborted_chain_size_same_url), | 301 aborted_chain_size_same_url_(aborted_chain_size_same_url), |
| 302 embedder_interface_(embedder_interface) { | 302 embedder_interface_(embedder_interface) { |
| 303 DCHECK(!navigation_handle->HasCommitted()); | 303 DCHECK(!navigation_handle->HasCommitted()); |
| 304 if (embedder_interface_->IsPrerendering( |
| 305 navigation_handle->GetWebContents())) { |
| 306 DCHECK(!started_in_foreground_); |
| 307 // For the time being, we do not track prerenders. See crbug.com/648338 for |
| 308 // details. |
| 309 StopTracking(); |
| 310 return; |
| 311 } |
| 312 |
| 304 embedder_interface_->RegisterObservers(this); | 313 embedder_interface_->RegisterObservers(this); |
| 305 for (const auto& observer : observers_) { | 314 for (const auto& observer : observers_) { |
| 306 observer->OnStart(navigation_handle, currently_committed_url, | 315 observer->OnStart(navigation_handle, currently_committed_url, |
| 307 started_in_foreground_); | 316 started_in_foreground_); |
| 308 } | 317 } |
| 309 } | 318 } |
| 310 | 319 |
| 311 PageLoadTracker::~PageLoadTracker() { | 320 PageLoadTracker::~PageLoadTracker() { |
| 312 if (app_entered_background_) { | 321 if (app_entered_background_) { |
| 313 RecordAppBackgroundPageLoadCompleted(true); | 322 RecordAppBackgroundPageLoadCompleted(true); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } else if (last_aborted->aborted_chain_size_same_url() > 0) { | 758 } else if (last_aborted->aborted_chain_size_same_url() > 0) { |
| 750 LogAbortChainSameURLHistogram( | 759 LogAbortChainSameURLHistogram( |
| 751 last_aborted->aborted_chain_size_same_url()); | 760 last_aborted->aborted_chain_size_same_url()); |
| 752 } | 761 } |
| 753 chain_size = last_aborted->aborted_chain_size() + 1; | 762 chain_size = last_aborted->aborted_chain_size() + 1; |
| 754 } | 763 } |
| 755 | 764 |
| 756 if (!ShouldTrackNavigation(navigation_handle)) | 765 if (!ShouldTrackNavigation(navigation_handle)) |
| 757 return; | 766 return; |
| 758 | 767 |
| 759 // TODO(bmcquade): add support for tracking prerendered pages when they become | |
| 760 // visible. | |
| 761 if (embedder_interface_->IsPrerendering(web_contents())) | |
| 762 return; | |
| 763 | |
| 764 // Pass in the last committed url to the PageLoadTracker. If the MWCO has | 768 // Pass in the last committed url to the PageLoadTracker. If the MWCO has |
| 765 // never observed a committed load, use the last committed url from this | 769 // never observed a committed load, use the last committed url from this |
| 766 // WebContent's opener. This is more accurate than using referrers due to | 770 // WebContent's opener. This is more accurate than using referrers due to |
| 767 // referrer sanitizing and origin referrers. Note that this could potentially | 771 // referrer sanitizing and origin referrers. Note that this could potentially |
| 768 // be inaccurate if the opener has since navigated. | 772 // be inaccurate if the opener has since navigated. |
| 769 content::WebContents* opener = web_contents()->GetOpener(); | 773 content::WebContents* opener = web_contents()->GetOpener(); |
| 770 const GURL& opener_url = | 774 const GURL& opener_url = |
| 771 !has_navigated_ && opener | 775 !has_navigated_ && opener |
| 772 ? web_contents()->GetOpener()->GetLastCommittedURL() | 776 ? web_contents()->GetOpener()->GetLastCommittedURL() |
| 773 : GURL::EmptyGURL(); | 777 : GURL::EmptyGURL(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 content::NavigationHandle* navigation_handle) const { | 1071 content::NavigationHandle* navigation_handle) const { |
| 1068 DCHECK(navigation_handle->IsInMainFrame()); | 1072 DCHECK(navigation_handle->IsInMainFrame()); |
| 1069 DCHECK(!navigation_handle->HasCommitted() || | 1073 DCHECK(!navigation_handle->HasCommitted() || |
| 1070 !navigation_handle->IsSamePage()); | 1074 !navigation_handle->IsSamePage()); |
| 1071 | 1075 |
| 1072 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 1076 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 1073 navigation_handle).ShouldTrack(); | 1077 navigation_handle).ShouldTrack(); |
| 1074 } | 1078 } |
| 1075 | 1079 |
| 1076 } // namespace page_load_metrics | 1080 } // namespace page_load_metrics |
| OLD | NEW |