| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 : did_stop_tracking_(false), | 293 : did_stop_tracking_(false), |
| 294 app_entered_background_(false), | 294 app_entered_background_(false), |
| 295 navigation_start_(navigation_handle->NavigationStart()), | 295 navigation_start_(navigation_handle->NavigationStart()), |
| 296 start_url_(navigation_handle->GetURL()), | 296 start_url_(navigation_handle->GetURL()), |
| 297 abort_type_(ABORT_NONE), | 297 abort_type_(ABORT_NONE), |
| 298 abort_user_initiated_info_(UserInitiatedInfo::NotUserInitiated()), | 298 abort_user_initiated_info_(UserInitiatedInfo::NotUserInitiated()), |
| 299 started_in_foreground_(in_foreground), | 299 started_in_foreground_(in_foreground), |
| 300 page_transition_(navigation_handle->GetPageTransition()), | 300 page_transition_(navigation_handle->GetPageTransition()), |
| 301 num_cache_requests_(0), | 301 num_cache_requests_(0), |
| 302 num_network_requests_(0), | 302 num_network_requests_(0), |
| 303 cache_bytes_(0), |
| 304 network_bytes_(0), |
| 303 user_initiated_info_(user_initiated_info), | 305 user_initiated_info_(user_initiated_info), |
| 304 aborted_chain_size_(aborted_chain_size), | 306 aborted_chain_size_(aborted_chain_size), |
| 305 aborted_chain_size_same_url_(aborted_chain_size_same_url), | 307 aborted_chain_size_same_url_(aborted_chain_size_same_url), |
| 306 embedder_interface_(embedder_interface) { | 308 embedder_interface_(embedder_interface) { |
| 307 DCHECK(!navigation_handle->HasCommitted()); | 309 DCHECK(!navigation_handle->HasCommitted()); |
| 308 embedder_interface_->RegisterObservers(this); | 310 embedder_interface_->RegisterObservers(this); |
| 309 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnStart, navigation_handle, | 311 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnStart, navigation_handle, |
| 310 currently_committed_url, started_in_foreground_); | 312 currently_committed_url, started_in_foreground_); |
| 311 } | 313 } |
| 312 | 314 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); | 515 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); |
| 514 for (const auto& observer : observers_) { | 516 for (const auto& observer : observers_) { |
| 515 DispatchObserverTimingCallbacks(observer.get(), last_timing, new_timing, | 517 DispatchObserverTimingCallbacks(observer.get(), last_timing, new_timing, |
| 516 last_metadata, info); | 518 last_metadata, info); |
| 517 } | 519 } |
| 518 return true; | 520 return true; |
| 519 } | 521 } |
| 520 return false; | 522 return false; |
| 521 } | 523 } |
| 522 | 524 |
| 523 void PageLoadTracker::OnLoadedSubresource(bool was_cached) { | 525 void PageLoadTracker::OnLoadedResource(bool was_cached, |
| 526 int64_t raw_body_bytes) { |
| 524 if (was_cached) { | 527 if (was_cached) { |
| 525 ++num_cache_requests_; | 528 ++num_cache_requests_; |
| 529 cache_bytes_ += raw_body_bytes; |
| 526 } else { | 530 } else { |
| 527 ++num_network_requests_; | 531 ++num_network_requests_; |
| 532 network_bytes_ += raw_body_bytes; |
| 528 } | 533 } |
| 529 } | 534 } |
| 530 | 535 |
| 531 void PageLoadTracker::StopTracking() { | 536 void PageLoadTracker::StopTracking() { |
| 532 did_stop_tracking_ = true; | 537 did_stop_tracking_ = true; |
| 533 observers_.clear(); | 538 observers_.clear(); |
| 534 } | 539 } |
| 535 | 540 |
| 536 void PageLoadTracker::AddObserver( | 541 void PageLoadTracker::AddObserver( |
| 537 std::unique_ptr<PageLoadMetricsObserver> observer) { | 542 std::unique_ptr<PageLoadMetricsObserver> observer) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 // abort_type_ == ABORT_NONE implies abort_user_initiated_info_ is not user | 595 // abort_type_ == ABORT_NONE implies abort_user_initiated_info_ is not user |
| 591 // initiated. | 596 // initiated. |
| 592 DCHECK(abort_type_ != ABORT_NONE || | 597 DCHECK(abort_type_ != ABORT_NONE || |
| 593 (!abort_user_initiated_info_.browser_initiated && | 598 (!abort_user_initiated_info_.browser_initiated && |
| 594 !abort_user_initiated_info_.user_gesture && | 599 !abort_user_initiated_info_.user_gesture && |
| 595 !abort_user_initiated_info_.user_input_event)); | 600 !abort_user_initiated_info_.user_input_event)); |
| 596 return PageLoadExtraInfo( | 601 return PageLoadExtraInfo( |
| 597 first_background_time, first_foreground_time, started_in_foreground_, | 602 first_background_time, first_foreground_time, started_in_foreground_, |
| 598 user_initiated_info_, committed_url_, start_url_, abort_type_, | 603 user_initiated_info_, committed_url_, start_url_, abort_type_, |
| 599 abort_user_initiated_info_, time_to_abort, num_cache_requests_, | 604 abort_user_initiated_info_, time_to_abort, num_cache_requests_, |
| 600 num_network_requests_, metadata_); | 605 num_network_requests_, cache_bytes_, network_bytes_, metadata_); |
| 601 } | 606 } |
| 602 | 607 |
| 603 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, | 608 void PageLoadTracker::NotifyAbort(UserAbortType abort_type, |
| 604 UserInitiatedInfo user_initiated_info, | 609 UserInitiatedInfo user_initiated_info, |
| 605 base::TimeTicks timestamp, | 610 base::TimeTicks timestamp, |
| 606 bool is_certainly_browser_timestamp) { | 611 bool is_certainly_browser_timestamp) { |
| 607 DCHECK_NE(abort_type, ABORT_NONE); | 612 DCHECK_NE(abort_type, ABORT_NONE); |
| 608 // Use UpdateAbort to update an already notified PageLoadTracker. | 613 // Use UpdateAbort to update an already notified PageLoadTracker. |
| 609 if (abort_type_ != ABORT_NONE) | 614 if (abort_type_ != ABORT_NONE) |
| 610 return; | 615 return; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 // user initiated. | 680 // user initiated. |
| 676 if (abort_type != ABORT_CLIENT_REDIRECT) | 681 if (abort_type != ABORT_CLIENT_REDIRECT) |
| 677 abort_user_initiated_info_ = user_initiated_info; | 682 abort_user_initiated_info_ = user_initiated_info; |
| 678 | 683 |
| 679 if (is_certainly_browser_timestamp) { | 684 if (is_certainly_browser_timestamp) { |
| 680 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); | 685 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); |
| 681 } | 686 } |
| 682 } | 687 } |
| 683 | 688 |
| 684 } // namespace page_load_metrics | 689 } // namespace page_load_metrics |
| OLD | NEW |