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

Unified Diff: components/page_load_metrics/browser/metrics_web_contents_observer.cc

Issue 2152683004: Refactor PageLoadMetricsObserver completion callback policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@relevantloads
Patch Set: fix metric 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 side-by-side diff with in-line comments
Download patch
Index: components/page_load_metrics/browser/metrics_web_contents_observer.cc
diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.cc b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
index 5039557a870d9105b727da9e2eddc1834b170424..17f9c102caaa0a17934b041abce18f424ae00417 100644
--- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
@@ -49,6 +49,8 @@ const char kAbortChainSizeNoCommit[] =
"PageLoad.Internal.ProvisionalAbortChainSize.NoCommit";
const char kClientRedirectDelayAfterPaint[] =
"PageLoad.Internal.ClientRedirectDelayAfterPaint";
+const char kCommitToCompleteNoTimingIPCs[] =
+ "PageLoad.Internal.CommitToComplete.NoTimingIPCs";
} // namespace internal
@@ -263,9 +265,14 @@ PageLoadTracker::~PageLoadTracker() {
return;
const PageLoadExtraInfo info = ComputePageLoadExtraInfo();
-
+ DCHECK_NE(static_cast<bool>(info.time_to_commit),
+ static_cast<bool>(failed_provisional_load_info_));
if (info.time_to_commit && timing_.IsEmpty()) {
RecordInternalError(ERR_NO_IPCS_RECEIVED);
+ const base::TimeTicks commit_time =
+ navigation_start_ + info.time_to_commit.value();
+ PAGE_LOAD_HISTOGRAM(internal::kCommitToCompleteNoTimingIPCs,
+ base::TimeTicks::Now() - commit_time);
}
// Recall that trackers that are given ABORT_UNKNOWN_NAVIGATION have their
// chain length added to the next navigation. Take care not to double count
@@ -274,7 +281,12 @@ PageLoadTracker::~PageLoadTracker() {
LogAbortChainHistograms(nullptr);
for (const auto& observer : observers_) {
- observer->OnComplete(timing_, info);
+ if (failed_provisional_load_info_) {
+ observer->OnFailedProvisionalLoad(failed_provisional_load_info_.value(),
+ info);
+ } else {
+ observer->OnComplete(timing_, info);
+ }
}
}
@@ -367,9 +379,9 @@ void PageLoadTracker::Commit(content::NavigationHandle* navigation_handle) {
void PageLoadTracker::FailedProvisionalLoad(
content::NavigationHandle* navigation_handle) {
- for (const auto& observer : observers_) {
- observer->OnFailedProvisionalLoad(navigation_handle);
- }
+ failed_provisional_load_info_ = FailedProvisionalLoadInfo(
+ base::TimeTicks::Now() - navigation_handle->NavigationStart(),
+ navigation_handle->GetNetErrorCode());
}
void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) {

Powered by Google App Engine
This is Rietveld 408576698