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/page_load_tracker.cc

Issue 2798953002: [PageLoadMetrics] Keep track of Ad Sizes on Pages (Closed)
Patch Set: Rebase 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
« no previous file with comments | « chrome/browser/page_load_metrics/page_load_tracker.h ('k') | chrome/test/BUILD.gn » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/page_load_tracker.h" 5 #include "chrome/browser/page_load_metrics/page_load_tracker.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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 474 }
475 475
476 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnShown); 476 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnShown);
477 } 477 }
478 478
479 void PageLoadTracker::WillProcessNavigationResponse( 479 void PageLoadTracker::WillProcessNavigationResponse(
480 content::NavigationHandle* navigation_handle) { 480 content::NavigationHandle* navigation_handle) {
481 // PlzNavigate: NavigationHandle::GetGlobalRequestID() sometimes returns an 481 // PlzNavigate: NavigationHandle::GetGlobalRequestID() sometimes returns an
482 // uninitialized GlobalRequestID. Bail early in this case. See 482 // uninitialized GlobalRequestID. Bail early in this case. See
483 // crbug.com/680841 for details. 483 // crbug.com/680841 for details.
484 if (content::IsBrowserSideNavigationEnabled() && 484 // TODO(jkarlin): NavigationSimulator is the first unittest framework to hit
485 navigation_handle->GetGlobalRequestID() == content::GlobalRequestID()) 485 // this function, and it doesn't provide a GlobalRequestID. Add an ID. See
486 // crbug.com/711352 for details.
487 if (navigation_handle->GetGlobalRequestID() == content::GlobalRequestID())
486 return; 488 return;
487 489
488 DCHECK(!navigation_request_id_.has_value()); 490 DCHECK(!navigation_request_id_.has_value());
489 navigation_request_id_ = navigation_handle->GetGlobalRequestID(); 491 navigation_request_id_ = navigation_handle->GetGlobalRequestID();
490 DCHECK(navigation_request_id_.value() != content::GlobalRequestID()); 492 DCHECK(navigation_request_id_.value() != content::GlobalRequestID());
491 } 493 }
492 494
493 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { 495 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) {
494 did_commit_ = true; 496 did_commit_ = true;
495 url_ = navigation_handle->GetURL(); 497 url_ = navigation_handle->GetURL();
496 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. 498 // Some transitions (like CLIENT_REDIRECT) are only known at commit time.
497 page_transition_ = navigation_handle->GetPageTransition(); 499 page_transition_ = navigation_handle->GetPageTransition();
498 user_initiated_info_.user_gesture = navigation_handle->HasUserGesture(); 500 user_initiated_info_.user_gesture = navigation_handle->HasUserGesture();
499 501
500 INVOKE_AND_PRUNE_OBSERVERS( 502 INVOKE_AND_PRUNE_OBSERVERS(
501 observers_, ShouldObserveMimeType, 503 observers_, ShouldObserveMimeType,
502 navigation_handle->GetWebContents()->GetContentsMimeType()); 504 navigation_handle->GetWebContents()->GetContentsMimeType());
503 505
504 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnCommit, navigation_handle); 506 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnCommit, navigation_handle);
505 LogAbortChainHistograms(navigation_handle); 507 LogAbortChainHistograms(navigation_handle);
506 } 508 }
507 509
510 void PageLoadTracker::DidFinishSubFrameNavigation(
511 content::NavigationHandle* navigation_handle) {
512 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnDidFinishSubFrameNavigation,
513 navigation_handle);
514 }
515
508 void PageLoadTracker::FailedProvisionalLoad( 516 void PageLoadTracker::FailedProvisionalLoad(
509 content::NavigationHandle* navigation_handle, 517 content::NavigationHandle* navigation_handle,
510 base::TimeTicks failed_load_time) { 518 base::TimeTicks failed_load_time) {
511 DCHECK(!failed_provisional_load_info_); 519 DCHECK(!failed_provisional_load_info_);
512 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( 520 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo(
513 failed_load_time - navigation_handle->NavigationStart(), 521 failed_load_time - navigation_handle->NavigationStart(),
514 navigation_handle->GetNetErrorCode())); 522 navigation_handle->GetNetErrorCode()));
515 } 523 }
516 524
517 void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) { 525 void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 observer->MediaStartedPlaying(video_type, is_in_main_frame); 812 observer->MediaStartedPlaying(video_type, is_in_main_frame);
805 } 813 }
806 814
807 void PageLoadTracker::OnNavigationDelayComplete(base::TimeDelta scheduled_delay, 815 void PageLoadTracker::OnNavigationDelayComplete(base::TimeDelta scheduled_delay,
808 base::TimeDelta actual_delay) { 816 base::TimeDelta actual_delay) {
809 for (const auto& observer : observers_) 817 for (const auto& observer : observers_)
810 observer->OnNavigationDelayComplete(scheduled_delay, actual_delay); 818 observer->OnNavigationDelayComplete(scheduled_delay, actual_delay);
811 } 819 }
812 820
813 } // namespace page_load_metrics 821 } // namespace page_load_metrics
OLDNEW
« no previous file with comments | « chrome/browser/page_load_metrics/page_load_tracker.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698