Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: components/page_load_metrics/browser/metrics_web_contents_observer.cc

Issue 2103153004: Add a histogram for delay between first paint and client side redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 28 matching lines...) Expand all
39 const char kAbortChainSizeReload[] = 39 const char kAbortChainSizeReload[] =
40 "PageLoad.Internal.ProvisionalAbortChainSize.Reload"; 40 "PageLoad.Internal.ProvisionalAbortChainSize.Reload";
41 const char kAbortChainSizeForwardBack[] = 41 const char kAbortChainSizeForwardBack[] =
42 "PageLoad.Internal.ProvisionalAbortChainSize.ForwardBack"; 42 "PageLoad.Internal.ProvisionalAbortChainSize.ForwardBack";
43 const char kAbortChainSizeNewNavigation[] = 43 const char kAbortChainSizeNewNavigation[] =
44 "PageLoad.Internal.ProvisionalAbortChainSize.NewNavigation"; 44 "PageLoad.Internal.ProvisionalAbortChainSize.NewNavigation";
45 const char kAbortChainSizeSameURL[] = 45 const char kAbortChainSizeSameURL[] =
46 "PageLoad.Internal.ProvisionalAbortChainSize.SameURL"; 46 "PageLoad.Internal.ProvisionalAbortChainSize.SameURL";
47 const char kAbortChainSizeNoCommit[] = 47 const char kAbortChainSizeNoCommit[] =
48 "PageLoad.Internal.ProvisionalAbortChainSize.NoCommit"; 48 "PageLoad.Internal.ProvisionalAbortChainSize.NoCommit";
49 const char kClientRedirectDelayAfterPaint[] =
50 "PageLoad.Internal.ClientRedirectDelayAfterPaint";
49 51
50 } // namespace internal 52 } // namespace internal
51 53
52 namespace { 54 namespace {
53 55
54 // The url we see from the renderer side is not always the same as what 56 // The url we see from the renderer side is not always the same as what
55 // we see from the browser side (e.g. chrome://newtab). We want to be 57 // we see from the browser side (e.g. chrome://newtab). We want to be
56 // sure here that we aren't logging UMA for internal pages. 58 // sure here that we aren't logging UMA for internal pages.
57 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle, 59 bool IsRelevantNavigation(content::NavigationHandle* navigation_handle,
58 const GURL& browser_url, 60 const GURL& browser_url,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 observer->OnRedirect(navigation_handle); 380 observer->OnRedirect(navigation_handle);
379 } 381 }
380 } 382 }
381 383
382 void PageLoadTracker::OnInputEvent(const blink::WebInputEvent& event) { 384 void PageLoadTracker::OnInputEvent(const blink::WebInputEvent& event) {
383 for (const auto& observer : observers_) { 385 for (const auto& observer : observers_) {
384 observer->OnUserInput(event); 386 observer->OnUserInput(event);
385 } 387 }
386 } 388 }
387 389
390 void PageLoadTracker::NotifyClientRedirectTo(
391 const PageLoadTracker& destination) {
392 base::TimeDelta redirect_delay_after_paint;
393 if (!timing_.first_paint.is_zero()) {
394 base::TimeTicks first_paint_time = navigation_start() + timing_.first_paint;
395 if (destination.navigation_start() > first_paint_time)
396 redirect_delay_after_paint =
397 destination.navigation_start() - first_paint_time;
398 }
399 PAGE_LOAD_HISTOGRAM(internal::kClientRedirectDelayAfterPaint,
Charlie Harrison 2016/06/29 20:18:37 I don't think it's necessary but let's keep in min
400 redirect_delay_after_paint);
401 }
402
388 bool PageLoadTracker::UpdateTiming(const PageLoadTiming& new_timing, 403 bool PageLoadTracker::UpdateTiming(const PageLoadTiming& new_timing,
389 const PageLoadMetadata& new_metadata) { 404 const PageLoadMetadata& new_metadata) {
390 // Throw away IPCs that are not relevant to the current navigation. 405 // Throw away IPCs that are not relevant to the current navigation.
391 // Two timing structures cannot refer to the same navigation if they indicate 406 // Two timing structures cannot refer to the same navigation if they indicate
392 // that a navigation started at different times, so a new timing struct with a 407 // that a navigation started at different times, so a new timing struct with a
393 // different start time from an earlier struct is considered invalid. 408 // different start time from an earlier struct is considered invalid.
394 bool valid_timing_descendent = 409 bool valid_timing_descendent =
395 timing_.navigation_start.is_null() || 410 timing_.navigation_start.is_null() ||
396 timing_.navigation_start == new_timing.navigation_start; 411 timing_.navigation_start == new_timing.navigation_start;
397 // Ensure flags sent previously are still present in the new metadata fields. 412 // Ensure flags sent previously are still present in the new metadata fields.
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 aborted_provisional_loads_.push_back(std::move(finished_nav)); 728 aborted_provisional_loads_.push_back(std::move(finished_nav));
714 } 729 }
715 730
716 return; 731 return;
717 } 732 }
718 733
719 // Don't treat a same-page nav as a new page load. 734 // Don't treat a same-page nav as a new page load.
720 if (navigation_handle->IsSamePage()) 735 if (navigation_handle->IsSamePage())
721 return; 736 return;
722 737
738 if (!navigation_handle->HasUserGesture() &&
739 (navigation_handle->GetPageTransition() &
740 ui::PAGE_TRANSITION_CLIENT_REDIRECT) != 0 &&
741 committed_load_)
742 committed_load_->NotifyClientRedirectTo(*finished_nav);
743
723 // Notify other loads that they may have been aborted by this committed load. 744 // Notify other loads that they may have been aborted by this committed load.
724 // Note that by using the committed navigation start as the abort cause, we 745 // Note that by using the committed navigation start as the abort cause, we
725 // lose data on provisional loads that were aborted by other provisional 746 // lose data on provisional loads that were aborted by other provisional
726 // loads. Those will either be listed as ABORT_OTHER or as being aborted by 747 // loads. Those will either be listed as ABORT_OTHER or as being aborted by
727 // this load. 748 // this load.
728 // is_certainly_browser_timestamp is set to false because NavigationStart() 749 // is_certainly_browser_timestamp is set to false because NavigationStart()
729 // could be set in either the renderer or browser process. 750 // could be set in either the renderer or browser process.
730 NotifyAbortAllLoadsWithTimestamp( 751 NotifyAbortAllLoadsWithTimestamp(
731 AbortTypeForPageTransition(navigation_handle->GetPageTransition()), 752 AbortTypeForPageTransition(navigation_handle->GetPageTransition()),
732 navigation_handle->NavigationStart(), false); 753 navigation_handle->NavigationStart(), false);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 912
892 if (!committed_load_->UpdateTiming(timing, metadata)) { 913 if (!committed_load_->UpdateTiming(timing, metadata)) {
893 // If the page load tracker cannot update its timing, something is wrong 914 // If the page load tracker cannot update its timing, something is wrong
894 // with the IPC (it's from another load, or it's invalid in some other way). 915 // with the IPC (it's from another load, or it's invalid in some other way).
895 // We expect this to be a rare occurrence. 916 // We expect this to be a rare occurrence.
896 RecordInternalError(ERR_BAD_TIMING_IPC); 917 RecordInternalError(ERR_BAD_TIMING_IPC);
897 } 918 }
898 } 919 }
899 920
900 } // namespace page_load_metrics 921 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698