Chromium Code Reviews| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 // never observed a committed load, use the last committed url from this | 150 // never observed a committed load, use the last committed url from this |
| 151 // WebContent's opener. This is more accurate than using referrers due to | 151 // WebContent's opener. This is more accurate than using referrers due to |
| 152 // referrer sanitizing and origin referrers. Note that this could potentially | 152 // referrer sanitizing and origin referrers. Note that this could potentially |
| 153 // be inaccurate if the opener has since navigated. | 153 // be inaccurate if the opener has since navigated. |
| 154 content::WebContents* opener = web_contents()->GetOpener(); | 154 content::WebContents* opener = web_contents()->GetOpener(); |
| 155 const GURL& opener_url = | 155 const GURL& opener_url = |
| 156 !has_navigated_ && opener | 156 !has_navigated_ && opener |
| 157 ? web_contents()->GetOpener()->GetLastCommittedURL() | 157 ? web_contents()->GetOpener()->GetLastCommittedURL() |
| 158 : GURL::EmptyGURL(); | 158 : GURL::EmptyGURL(); |
| 159 const GURL& currently_committed_url = | 159 const GURL& currently_committed_url = |
| 160 committed_load_ ? committed_load_->committed_url() : opener_url; | 160 committed_load_ && committed_load_->did_commit() ? committed_load_->url() |
|
jkarlin
2017/02/15 19:55:36
committed_load_->did_commit() must be true, right?
Bryan McQuade
2017/02/15 20:27:10
Done, thanks!
I added the DCHECK at the location
| |
| 161 : opener_url; | |
| 161 has_navigated_ = true; | 162 has_navigated_ = true; |
| 162 | 163 |
| 163 // We can have two provisional loads in some cases. E.g. a same-site | 164 // We can have two provisional loads in some cases. E.g. a same-site |
| 164 // navigation can have a concurrent cross-process navigation started | 165 // navigation can have a concurrent cross-process navigation started |
| 165 // from the omnibox. | 166 // from the omnibox. |
| 166 DCHECK_GT(2ul, provisional_loads_.size()); | 167 DCHECK_GT(2ul, provisional_loads_.size()); |
| 167 // Passing raw pointers to observers_ and embedder_interface_ is safe because | 168 // Passing raw pointers to observers_ and embedder_interface_ is safe because |
| 168 // the MetricsWebContentsObserver owns them both list and they are torn down | 169 // the MetricsWebContentsObserver owns them both list and they are torn down |
| 169 // after the PageLoadTracker. The PageLoadTracker does not hold on to | 170 // after the PageLoadTracker. The PageLoadTracker does not hold on to |
| 170 // committed_load_ or navigation_handle beyond the scope of the constructor. | 171 // committed_load_ or navigation_handle beyond the scope of the constructor. |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 content::NavigationHandle* navigation_handle) const { | 530 content::NavigationHandle* navigation_handle) const { |
| 530 DCHECK(navigation_handle->IsInMainFrame()); | 531 DCHECK(navigation_handle->IsInMainFrame()); |
| 531 DCHECK(!navigation_handle->HasCommitted() || | 532 DCHECK(!navigation_handle->HasCommitted() || |
| 532 !navigation_handle->IsSamePage()); | 533 !navigation_handle->IsSamePage()); |
| 533 | 534 |
| 534 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 535 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 535 navigation_handle).ShouldTrack(); | 536 navigation_handle).ShouldTrack(); |
| 536 } | 537 } |
| 537 | 538 |
| 538 } // namespace page_load_metrics | 539 } // namespace page_load_metrics |
| OLD | NEW |