Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2882513005: Propagate opener to BackgroundsContents. (Closed)
Patch Set: Added (and re-enabled) tests. Suppressed opener propagation in one case. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 if (!ShouldTrackNavigation(navigation_handle)) 173 if (!ShouldTrackNavigation(navigation_handle))
174 return; 174 return;
175 175
176 // Pass in the last committed url to the PageLoadTracker. If the MWCO has 176 // Pass in the last committed url to the PageLoadTracker. If the MWCO has
177 // never observed a committed load, use the last committed url from this 177 // never observed a committed load, use the last committed url from this
178 // WebContent's opener. This is more accurate than using referrers due to 178 // WebContent's opener. This is more accurate than using referrers due to
179 // referrer sanitizing and origin referrers. Note that this could potentially 179 // referrer sanitizing and origin referrers. Note that this could potentially
180 // be inaccurate if the opener has since navigated. 180 // be inaccurate if the opener has since navigated.
181 content::WebContents* opener = web_contents()->GetOpener(); 181 content::RenderFrameHost* opener = web_contents()->GetOpener();
182 const GURL& opener_url = 182 const GURL& opener_url = !has_navigated_ && opener
183 !has_navigated_ && opener 183 ? opener->GetLastCommittedURL()
ncarter (slow) 2017/05/22 17:32:42 I think this is an accuracy improvement, but let's
Łukasz Anforowicz 2017/05/22 18:25:38 Good point. Some notes about the change above: -
Bryan McQuade 2017/05/23 13:57:02 Thanks so much for the thorough analysis & reachin
Łukasz Anforowicz 2017/05/23 18:56:03 The change of return type of WebContents::GetOpene
Bryan McQuade 2017/05/23 19:06:40 Thanks! I see now. This change SGTM, thanks!
184 ? web_contents()->GetOpener()->GetLastCommittedURL() 184 : GURL::EmptyGURL();
185 : GURL::EmptyGURL();
186 const GURL& currently_committed_url = 185 const GURL& currently_committed_url =
187 committed_load_ ? committed_load_->url() : opener_url; 186 committed_load_ ? committed_load_->url() : opener_url;
188 has_navigated_ = true; 187 has_navigated_ = true;
189 188
190 // We can have two provisional loads in some cases. E.g. a same-site 189 // We can have two provisional loads in some cases. E.g. a same-site
191 // navigation can have a concurrent cross-process navigation started 190 // navigation can have a concurrent cross-process navigation started
192 // from the omnibox. 191 // from the omnibox.
193 DCHECK_GT(2ul, provisional_loads_.size()); 192 DCHECK_GT(2ul, provisional_loads_.size());
194 // Passing raw pointers to observers_ and embedder_interface_ is safe because 193 // Passing raw pointers to observers_ and embedder_interface_ is safe because
195 // the MetricsWebContentsObserver owns them both list and they are torn down 194 // the MetricsWebContentsObserver owns them both list and they are torn down
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 observer_->RemoveTestingObserver(this); 641 observer_->RemoveTestingObserver(this);
643 observer_ = nullptr; 642 observer_ = nullptr;
644 } 643 }
645 } 644 }
646 645
647 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { 646 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() {
648 observer_ = nullptr; 647 observer_ = nullptr;
649 } 648 }
650 649
651 } // namespace page_load_metrics 650 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698