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

Unified Diff: components/page_load_metrics/browser/page_load_metrics_observer.h

Issue 2152683004: Refactor PageLoadMetricsObserver completion callback policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@relevantloads
Patch Set: remove histogram checks that can be flaky due to immediate logging 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/page_load_metrics_observer.h
diff --git a/components/page_load_metrics/browser/page_load_metrics_observer.h b/components/page_load_metrics/browser/page_load_metrics_observer.h
index 1d73ed05dfa0426032cdaadefea9aa17cea7eac5..ffc494793ca1dd4551b80734cfbd65665f393881 100644
--- a/components/page_load_metrics/browser/page_load_metrics_observer.h
+++ b/components/page_load_metrics/browser/page_load_metrics_observer.h
@@ -50,6 +50,15 @@ enum UserAbortType {
ABORT_LAST_ENTRY
};
+// Information related to failed provisional loads.
+struct FailedProvisionalLoadInfo {
+ FailedProvisionalLoadInfo(base::TimeDelta interval, net::Error error);
+ ~FailedProvisionalLoadInfo();
+
+ base::TimeDelta time_to_failed_provisional_load;
+ net::Error error;
+};
+
struct PageLoadExtraInfo {
PageLoadExtraInfo(
const base::Optional<base::TimeDelta>& first_background_time,
@@ -122,12 +131,6 @@ class PageLoadMetricsObserver {
// Note that this does not get called for same page navigations.
virtual void OnCommit(content::NavigationHandle* navigation_handle) {}
- // OnFailedProvisionalLoad is triggered when a provisional load failed and did
- // not commit. Note that provisional loads that result in downloads or 204s
- // are aborted by the system, and thus considered failed provisional loads.
- virtual void OnFailedProvisionalLoad(
- content::NavigationHandle* navigation_handle) {}
-
// OnHidden is triggered when a page leaves the foreground. It does not fire
// when a foreground page is permanently closed; for that, listen to
// OnComplete instead.
@@ -150,7 +153,6 @@ class PageLoadMetricsObserver {
// loading-dev@chromium.org if you intend to override this method.
virtual void OnTimingUpdate(const PageLoadTiming& timing,
const PageLoadExtraInfo& extra_info) {}
-
// OnUserInput is triggered when a new user input is passed in to
// web_contents. Contains a TimeDelta from navigation start.
virtual void OnUserInput(const blink::WebInputEvent& event) {}
@@ -182,13 +184,27 @@ class PageLoadMetricsObserver {
virtual void OnLoadingBehaviorObserved(
const page_load_metrics::PageLoadExtraInfo& extra_info) {}
- // OnComplete is invoked for tracked page loads, immediately before the
- // observer is deleted. The PageLoadTiming struct contains timing data and
- // the PageLoadExtraInfo struct contains other useful data collected over the
- // course of the page load. Most observers should not need to implement this
- // method, and should implement the On* timing callbacks instead.
+ // One of OnComplete or OnFailedProvisionalLoad is invoked for tracked page
+ // loads, immediately before the observer is deleted. These callbacks will not
+ // be invoked for page loads that did not meet the criteria for being tracked
+ // at the time the navigation completed. The PageLoadTiming struct contains
+ // timing data and the PageLoadExtraInfo struct contains other useful data
+ // collected over the course of the page load. Most observers should not need
+ // to implement these callbacks, and should implement the On* timing callbacks
+ // instead.
+
+ // OnComplete is invoked for tracked page loads that committed, immediately
+ // before the observer is deleted.
virtual void OnComplete(const PageLoadTiming& timing,
const PageLoadExtraInfo& extra_info) {}
+
+ // OnFailedProvisionalLoad is invoked for tracked page loads that did not
+ // commit, immediately before the observer is deleted. Note that provisional
+ // loads that result in downloads or 204s are aborted by the system, and are
+ // also included as failed provisional loads.
+ virtual void OnFailedProvisionalLoad(
+ const FailedProvisionalLoadInfo& failed_provisional_load_info,
+ const PageLoadExtraInfo& extra_info) {}
};
} // namespace page_load_metrics

Powered by Google App Engine
This is Rietveld 408576698