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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (destination.navigation_start() > first_paint_time) | 499 if (destination.navigation_start() > first_paint_time) |
500 first_paint_to_navigation = | 500 first_paint_to_navigation = |
501 destination.navigation_start() - first_paint_time; | 501 destination.navigation_start() - first_paint_time; |
502 PAGE_LOAD_HISTOGRAM(internal::kClientRedirectFirstPaintToNavigation, | 502 PAGE_LOAD_HISTOGRAM(internal::kClientRedirectFirstPaintToNavigation, |
503 first_paint_to_navigation); | 503 first_paint_to_navigation); |
504 } else { | 504 } else { |
505 UMA_HISTOGRAM_BOOLEAN(internal::kClientRedirectWithoutPaint, true); | 505 UMA_HISTOGRAM_BOOLEAN(internal::kClientRedirectWithoutPaint, true); |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
| 509 void PageLoadTracker::UpdateChildMetadata( |
| 510 const PageLoadMetadata& child_metadata) { |
| 511 // Merge the child loading behavior flags with any we've already observed, |
| 512 // possibly from other child frames. |
| 513 const int last_child_loading_behavior_flags = |
| 514 child_frame_metadata_.behavior_flags; |
| 515 child_frame_metadata_.behavior_flags |= child_metadata.behavior_flags; |
| 516 if (last_child_loading_behavior_flags == child_frame_metadata_.behavior_flags) |
| 517 return; |
| 518 |
| 519 PageLoadExtraInfo extra_info(ComputePageLoadExtraInfo()); |
| 520 for (const auto& observer : observers_) { |
| 521 observer->OnLoadingBehaviorObserved(extra_info); |
| 522 } |
| 523 } |
| 524 |
509 bool PageLoadTracker::UpdateTiming(const PageLoadTiming& new_timing, | 525 bool PageLoadTracker::UpdateTiming(const PageLoadTiming& new_timing, |
510 const PageLoadMetadata& new_metadata) { | 526 const PageLoadMetadata& new_metadata) { |
511 // Throw away IPCs that are not relevant to the current navigation. | 527 // Throw away IPCs that are not relevant to the current navigation. |
512 // Two timing structures cannot refer to the same navigation if they indicate | 528 // Two timing structures cannot refer to the same navigation if they indicate |
513 // that a navigation started at different times, so a new timing struct with a | 529 // that a navigation started at different times, so a new timing struct with a |
514 // different start time from an earlier struct is considered invalid. | 530 // different start time from an earlier struct is considered invalid. |
515 bool valid_timing_descendent = | 531 bool valid_timing_descendent = |
516 timing_.navigation_start.is_null() || | 532 timing_.navigation_start.is_null() || |
517 timing_.navigation_start == new_timing.navigation_start; | 533 timing_.navigation_start == new_timing.navigation_start; |
518 // Ensure flags sent previously are still present in the new metadata fields. | 534 // Ensure flags sent previously are still present in the new metadata fields. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 // page_end_reason_ == END_NONE implies page_end_user_initiated_info_ is not | 628 // page_end_reason_ == END_NONE implies page_end_user_initiated_info_ is not |
613 // user initiated. | 629 // user initiated. |
614 DCHECK(page_end_reason_ != END_NONE || | 630 DCHECK(page_end_reason_ != END_NONE || |
615 (!page_end_user_initiated_info_.browser_initiated && | 631 (!page_end_user_initiated_info_.browser_initiated && |
616 !page_end_user_initiated_info_.user_gesture && | 632 !page_end_user_initiated_info_.user_gesture && |
617 !page_end_user_initiated_info_.user_input_event)); | 633 !page_end_user_initiated_info_.user_input_event)); |
618 return PageLoadExtraInfo(navigation_start_, first_background_time, | 634 return PageLoadExtraInfo(navigation_start_, first_background_time, |
619 first_foreground_time, started_in_foreground_, | 635 first_foreground_time, started_in_foreground_, |
620 user_initiated_info_, url(), start_url_, did_commit_, | 636 user_initiated_info_, url(), start_url_, did_commit_, |
621 page_end_reason_, page_end_user_initiated_info_, | 637 page_end_reason_, page_end_user_initiated_info_, |
622 page_end_time, metadata_); | 638 page_end_time, metadata_, child_frame_metadata_); |
623 } | 639 } |
624 | 640 |
625 bool PageLoadTracker::HasMatchingNavigationRequestID( | 641 bool PageLoadTracker::HasMatchingNavigationRequestID( |
626 const content::GlobalRequestID& request_id) const { | 642 const content::GlobalRequestID& request_id) const { |
627 DCHECK(request_id != content::GlobalRequestID()); | 643 DCHECK(request_id != content::GlobalRequestID()); |
628 return navigation_request_id_.has_value() && | 644 return navigation_request_id_.has_value() && |
629 navigation_request_id_.value() == request_id; | 645 navigation_request_id_.value() == request_id; |
630 } | 646 } |
631 | 647 |
632 void PageLoadTracker::NotifyPageEnd(PageEndReason page_end_reason, | 648 void PageLoadTracker::NotifyPageEnd(PageEndReason page_end_reason, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 // user initiated. | 724 // user initiated. |
709 if (page_end_reason != END_CLIENT_REDIRECT) | 725 if (page_end_reason != END_CLIENT_REDIRECT) |
710 page_end_user_initiated_info_ = user_initiated_info; | 726 page_end_user_initiated_info_ = user_initiated_info; |
711 | 727 |
712 if (is_certainly_browser_timestamp) { | 728 if (is_certainly_browser_timestamp) { |
713 ClampBrowserTimestampIfInterProcessTimeTickSkew(&page_end_time_); | 729 ClampBrowserTimestampIfInterProcessTimeTickSkew(&page_end_time_); |
714 } | 730 } |
715 } | 731 } |
716 | 732 |
717 } // namespace page_load_metrics | 733 } // namespace page_load_metrics |
OLD | NEW |