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

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

Issue 2692373003: Refactor PageLoadExtraInfo::committed_url to url and did_commit fields. (Closed)
Patch Set: address comments Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_->url() : opener_url;
161 has_navigated_ = true; 161 has_navigated_ = true;
162 162
163 // We can have two provisional loads in some cases. E.g. a same-site 163 // We can have two provisional loads in some cases. E.g. a same-site
164 // navigation can have a concurrent cross-process navigation started 164 // navigation can have a concurrent cross-process navigation started
165 // from the omnibox. 165 // from the omnibox.
166 DCHECK_GT(2ul, provisional_loads_.size()); 166 DCHECK_GT(2ul, provisional_loads_.size());
167 // Passing raw pointers to observers_ and embedder_interface_ is safe because 167 // Passing raw pointers to observers_ and embedder_interface_ is safe because
168 // the MetricsWebContentsObserver owns them both list and they are torn down 168 // the MetricsWebContentsObserver owns them both list and they are torn down
169 // after the PageLoadTracker. The PageLoadTracker does not hold on to 169 // after the PageLoadTracker. The PageLoadTracker does not hold on to
170 // committed_load_ or navigation_handle beyond the scope of the constructor. 170 // committed_load_ or navigation_handle beyond the scope of the constructor.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 (navigation_handle->GetPageTransition() & 338 (navigation_handle->GetPageTransition() &
339 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 && 339 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 &&
340 committed_load_) { 340 committed_load_) {
341 // TODO(bmcquade): consider carrying the user_gesture bit forward to the 341 // TODO(bmcquade): consider carrying the user_gesture bit forward to the
342 // redirected navigation. 342 // redirected navigation.
343 committed_load_->NotifyClientRedirectTo(*tracker); 343 committed_load_->NotifyClientRedirectTo(*tracker);
344 } 344 }
345 345
346 committed_load_ = std::move(tracker); 346 committed_load_ = std::move(tracker);
347 committed_load_->Commit(navigation_handle); 347 committed_load_->Commit(navigation_handle);
348 DCHECK(committed_load_->did_commit());
348 } 349 }
349 350
350 void MetricsWebContentsObserver::NavigationStopped() { 351 void MetricsWebContentsObserver::NavigationStopped() {
351 // TODO(csharrison): Use a more user-initiated signal for STOP. 352 // TODO(csharrison): Use a more user-initiated signal for STOP.
352 NotifyAbortAllLoads(ABORT_STOP, UserInitiatedInfo::NotUserInitiated()); 353 NotifyAbortAllLoads(ABORT_STOP, UserInitiatedInfo::NotUserInitiated());
353 } 354 }
354 355
355 void MetricsWebContentsObserver::OnInputEvent( 356 void MetricsWebContentsObserver::OnInputEvent(
356 const blink::WebInputEvent& event) { 357 const blink::WebInputEvent& event) {
357 // Ignore browser navigation or reload which comes with type Undefined. 358 // Ignore browser navigation or reload which comes with type Undefined.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698