| OLD | NEW |
| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 } | 432 } |
| 433 | 433 |
| 434 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnShown); | 434 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnShown); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void PageLoadTracker::WillProcessNavigationResponse( | 437 void PageLoadTracker::WillProcessNavigationResponse( |
| 438 content::NavigationHandle* navigation_handle) { | 438 content::NavigationHandle* navigation_handle) { |
| 439 // PlzNavigate: NavigationHandle::GetGlobalRequestID() sometimes returns an | 439 // PlzNavigate: NavigationHandle::GetGlobalRequestID() sometimes returns an |
| 440 // uninitialized GlobalRequestID. Bail early in this case. See | 440 // uninitialized GlobalRequestID. Bail early in this case. See |
| 441 // crbug.com/680841 for details. | 441 // crbug.com/680841 for details. |
| 442 if (content::IsBrowserSideNavigationEnabled() && | 442 // TODO(jkarlin): NavigationSimulator is the first unittest framework to hit |
| 443 navigation_handle->GetGlobalRequestID() == content::GlobalRequestID()) | 443 // this function, and it doesn't provide a GlobalRequestID. Add an ID. See |
| 444 // crbug.com/711352 for details. |
| 445 if (navigation_handle->GetGlobalRequestID() == content::GlobalRequestID()) |
| 444 return; | 446 return; |
| 445 | 447 |
| 446 DCHECK(!navigation_request_id_.has_value()); | 448 DCHECK(!navigation_request_id_.has_value()); |
| 447 navigation_request_id_ = navigation_handle->GetGlobalRequestID(); | 449 navigation_request_id_ = navigation_handle->GetGlobalRequestID(); |
| 448 DCHECK(navigation_request_id_.value() != content::GlobalRequestID()); | 450 DCHECK(navigation_request_id_.value() != content::GlobalRequestID()); |
| 449 } | 451 } |
| 450 | 452 |
| 451 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { | 453 void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) { |
| 452 did_commit_ = true; | 454 did_commit_ = true; |
| 453 url_ = navigation_handle->GetURL(); | 455 url_ = navigation_handle->GetURL(); |
| 454 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. | 456 // Some transitions (like CLIENT_REDIRECT) are only known at commit time. |
| 455 page_transition_ = navigation_handle->GetPageTransition(); | 457 page_transition_ = navigation_handle->GetPageTransition(); |
| 456 user_initiated_info_.user_gesture = navigation_handle->HasUserGesture(); | 458 user_initiated_info_.user_gesture = navigation_handle->HasUserGesture(); |
| 457 | 459 |
| 458 INVOKE_AND_PRUNE_OBSERVERS( | 460 INVOKE_AND_PRUNE_OBSERVERS( |
| 459 observers_, ShouldObserveMimeType, | 461 observers_, ShouldObserveMimeType, |
| 460 navigation_handle->GetWebContents()->GetContentsMimeType()); | 462 navigation_handle->GetWebContents()->GetContentsMimeType()); |
| 461 | 463 |
| 462 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnCommit, navigation_handle); | 464 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnCommit, navigation_handle); |
| 463 LogAbortChainHistograms(navigation_handle); | 465 LogAbortChainHistograms(navigation_handle); |
| 464 } | 466 } |
| 465 | 467 |
| 468 void PageLoadTracker::DidCommitSubFrame( |
| 469 content::NavigationHandle* navigation_handle) { |
| 470 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnCommitSubFrame, navigation_handle); |
| 471 } |
| 472 |
| 466 void PageLoadTracker::FailedProvisionalLoad( | 473 void PageLoadTracker::FailedProvisionalLoad( |
| 467 content::NavigationHandle* navigation_handle, | 474 content::NavigationHandle* navigation_handle, |
| 468 base::TimeTicks failed_load_time) { | 475 base::TimeTicks failed_load_time) { |
| 469 DCHECK(!failed_provisional_load_info_); | 476 DCHECK(!failed_provisional_load_info_); |
| 470 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( | 477 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( |
| 471 failed_load_time - navigation_handle->NavigationStart(), | 478 failed_load_time - navigation_handle->NavigationStart(), |
| 472 navigation_handle->GetNetErrorCode())); | 479 navigation_handle->GetNetErrorCode())); |
| 473 } | 480 } |
| 474 | 481 |
| 475 void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) { | 482 void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 } | 744 } |
| 738 | 745 |
| 739 void PageLoadTracker::MediaStartedPlaying( | 746 void PageLoadTracker::MediaStartedPlaying( |
| 740 const content::WebContentsObserver::MediaPlayerInfo& video_type, | 747 const content::WebContentsObserver::MediaPlayerInfo& video_type, |
| 741 bool is_in_main_frame) { | 748 bool is_in_main_frame) { |
| 742 for (const auto& observer : observers_) | 749 for (const auto& observer : observers_) |
| 743 observer->MediaStartedPlaying(video_type, is_in_main_frame); | 750 observer->MediaStartedPlaying(video_type, is_in_main_frame); |
| 744 } | 751 } |
| 745 | 752 |
| 746 } // namespace page_load_metrics | 753 } // namespace page_load_metrics |
| OLD | NEW |