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 2737563007: Add support for tracking loading behavior of child frames. (Closed)
Patch Set: test fixes Created 3 years, 9 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
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 app_entered_background_(false), 296 app_entered_background_(false),
297 navigation_start_(navigation_handle->NavigationStart()), 297 navigation_start_(navigation_handle->NavigationStart()),
298 url_(navigation_handle->GetURL()), 298 url_(navigation_handle->GetURL()),
299 start_url_(navigation_handle->GetURL()), 299 start_url_(navigation_handle->GetURL()),
300 did_commit_(false), 300 did_commit_(false),
301 page_end_reason_(END_NONE), 301 page_end_reason_(END_NONE),
302 page_end_user_initiated_info_(UserInitiatedInfo::NotUserInitiated()), 302 page_end_user_initiated_info_(UserInitiatedInfo::NotUserInitiated()),
303 started_in_foreground_(in_foreground), 303 started_in_foreground_(in_foreground),
304 page_transition_(navigation_handle->GetPageTransition()), 304 page_transition_(navigation_handle->GetPageTransition()),
305 user_initiated_info_(user_initiated_info), 305 user_initiated_info_(user_initiated_info),
306 child_loading_behavior_flags_(0),
306 aborted_chain_size_(aborted_chain_size), 307 aborted_chain_size_(aborted_chain_size),
307 aborted_chain_size_same_url_(aborted_chain_size_same_url), 308 aborted_chain_size_same_url_(aborted_chain_size_same_url),
308 embedder_interface_(embedder_interface) { 309 embedder_interface_(embedder_interface) {
309 DCHECK(!navigation_handle->HasCommitted()); 310 DCHECK(!navigation_handle->HasCommitted());
310 embedder_interface_->RegisterObservers(this); 311 embedder_interface_->RegisterObservers(this);
311 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnStart, navigation_handle, 312 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnStart, navigation_handle,
312 currently_committed_url, started_in_foreground_); 313 currently_committed_url, started_in_foreground_);
313 } 314 }
314 315
315 PageLoadTracker::~PageLoadTracker() { 316 PageLoadTracker::~PageLoadTracker() {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 if (destination.navigation_start() > first_paint_time) 500 if (destination.navigation_start() > first_paint_time)
500 first_paint_to_navigation = 501 first_paint_to_navigation =
501 destination.navigation_start() - first_paint_time; 502 destination.navigation_start() - first_paint_time;
502 PAGE_LOAD_HISTOGRAM(internal::kClientRedirectFirstPaintToNavigation, 503 PAGE_LOAD_HISTOGRAM(internal::kClientRedirectFirstPaintToNavigation,
503 first_paint_to_navigation); 504 first_paint_to_navigation);
504 } else { 505 } else {
505 UMA_HISTOGRAM_BOOLEAN(internal::kClientRedirectWithoutPaint, true); 506 UMA_HISTOGRAM_BOOLEAN(internal::kClientRedirectWithoutPaint, true);
506 } 507 }
507 } 508 }
508 509
510 void PageLoadTracker::UpdateChildMetadata(
511 const PageLoadMetadata& child_metadata) {
512 // Merge the child loading behavior flags with any we've already observed,
513 // possibly from other child frames.
514 const int last_child_loading_behavior_flags = child_loading_behavior_flags_;
515 child_loading_behavior_flags_ |= child_metadata.behavior_flags;
516 if (last_child_loading_behavior_flags == child_loading_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } else { 624 } else {
609 DCHECK(page_end_time_.is_null()); 625 DCHECK(page_end_time_.is_null());
610 } 626 }
611 627
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(
619 first_foreground_time, started_in_foreground_, 635 navigation_start_, first_background_time, first_foreground_time,
620 user_initiated_info_, url(), start_url_, did_commit_, 636 started_in_foreground_, user_initiated_info_, url(), start_url_,
621 page_end_reason_, page_end_user_initiated_info_, 637 did_commit_, page_end_reason_, page_end_user_initiated_info_,
622 page_end_time, metadata_); 638 page_end_time, metadata_, child_loading_behavior_flags_);
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698