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

Side by Side 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 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 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/optional.h" 9 #include "base/optional.h"
10 #include "components/page_load_metrics/common/page_load_timing.h" 10 #include "components/page_load_metrics/common/page_load_timing.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 ABORT_OTHER, 43 ABORT_OTHER,
44 44
45 // The load aborted due to another navigation, but it isn't clear what type of 45 // The load aborted due to another navigation, but it isn't clear what type of
46 // navigation it was. 46 // navigation it was.
47 ABORT_UNKNOWN_NAVIGATION, 47 ABORT_UNKNOWN_NAVIGATION,
48 48
49 // Add values before this final count. 49 // Add values before this final count.
50 ABORT_LAST_ENTRY 50 ABORT_LAST_ENTRY
51 }; 51 };
52 52
53 // Information related to failed provisional loads.
54 struct FailedProvisionalLoadInfo {
55 FailedProvisionalLoadInfo(base::TimeDelta interval, net::Error error);
56 ~FailedProvisionalLoadInfo();
57
58 base::TimeDelta time_to_failed_provisional_load;
59 net::Error error;
60 };
61
53 struct PageLoadExtraInfo { 62 struct PageLoadExtraInfo {
54 PageLoadExtraInfo( 63 PageLoadExtraInfo(
55 const base::Optional<base::TimeDelta>& first_background_time, 64 const base::Optional<base::TimeDelta>& first_background_time,
56 const base::Optional<base::TimeDelta>& first_foreground_time, 65 const base::Optional<base::TimeDelta>& first_foreground_time,
57 bool started_in_foreground, 66 bool started_in_foreground,
58 const GURL& committed_url, 67 const GURL& committed_url,
59 const base::Optional<base::TimeDelta>& time_to_commit, 68 const base::Optional<base::TimeDelta>& time_to_commit,
60 UserAbortType abort_type, 69 UserAbortType abort_type,
61 const base::Optional<base::TimeDelta>& time_to_abort, 70 const base::Optional<base::TimeDelta>& time_to_abort,
62 const PageLoadMetadata& metadata); 71 const PageLoadMetadata& metadata);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // be called multiple times. 124 // be called multiple times.
116 virtual void OnRedirect(content::NavigationHandle* navigation_handle) {} 125 virtual void OnRedirect(content::NavigationHandle* navigation_handle) {}
117 126
118 // OnCommit is triggered when a page load commits, i.e. when we receive the 127 // OnCommit is triggered when a page load commits, i.e. when we receive the
119 // first data for the request. The navigation handle holds relevant data for 128 // first data for the request. The navigation handle holds relevant data for
120 // the navigation, but will be destroyed soon after this call. Don't hold a 129 // the navigation, but will be destroyed soon after this call. Don't hold a
121 // reference to it. 130 // reference to it.
122 // Note that this does not get called for same page navigations. 131 // Note that this does not get called for same page navigations.
123 virtual void OnCommit(content::NavigationHandle* navigation_handle) {} 132 virtual void OnCommit(content::NavigationHandle* navigation_handle) {}
124 133
125 // OnFailedProvisionalLoad is triggered when a provisional load failed and did
126 // not commit. Note that provisional loads that result in downloads or 204s
127 // are aborted by the system, and thus considered failed provisional loads.
128 virtual void OnFailedProvisionalLoad(
129 content::NavigationHandle* navigation_handle) {}
130
131 // OnHidden is triggered when a page leaves the foreground. It does not fire 134 // OnHidden is triggered when a page leaves the foreground. It does not fire
132 // when a foreground page is permanently closed; for that, listen to 135 // when a foreground page is permanently closed; for that, listen to
133 // OnComplete instead. 136 // OnComplete instead.
134 virtual void OnHidden() {} 137 virtual void OnHidden() {}
135 138
136 // OnShown is triggered when a page is brought to the foreground. It does not 139 // OnShown is triggered when a page is brought to the foreground. It does not
137 // fire when the page first loads; for that, listen for OnStart instead. 140 // fire when the page first loads; for that, listen for OnStart instead.
138 virtual void OnShown() {} 141 virtual void OnShown() {}
139 142
140 // The callbacks below are only invoked after a navigation commits, for 143 // The callbacks below are only invoked after a navigation commits, for
141 // tracked page loads. Page loads that don't meet the criteria for being 144 // tracked page loads. Page loads that don't meet the criteria for being
142 // tracked at the time a navigation commits will not receive any of the 145 // tracked at the time a navigation commits will not receive any of the
143 // callbacks below. 146 // callbacks below.
144 147
145 // OnTimingUpdate is triggered when an updated PageLoadTiming is 148 // OnTimingUpdate is triggered when an updated PageLoadTiming is
146 // available. This method may be called multiple times over the course of the 149 // available. This method may be called multiple times over the course of the
147 // page load. This method is currently only intended for use in testing. Most 150 // page load. This method is currently only intended for use in testing. Most
148 // implementers should implement one of the On* callbacks, such as 151 // implementers should implement one of the On* callbacks, such as
149 // OnFirstContentfulPaint or OnDomContentLoadedEventStart. Please email 152 // OnFirstContentfulPaint or OnDomContentLoadedEventStart. Please email
150 // loading-dev@chromium.org if you intend to override this method. 153 // loading-dev@chromium.org if you intend to override this method.
151 virtual void OnTimingUpdate(const PageLoadTiming& timing, 154 virtual void OnTimingUpdate(const PageLoadTiming& timing,
152 const PageLoadExtraInfo& extra_info) {} 155 const PageLoadExtraInfo& extra_info) {}
153
154 // OnUserInput is triggered when a new user input is passed in to 156 // OnUserInput is triggered when a new user input is passed in to
155 // web_contents. Contains a TimeDelta from navigation start. 157 // web_contents. Contains a TimeDelta from navigation start.
156 virtual void OnUserInput(const blink::WebInputEvent& event) {} 158 virtual void OnUserInput(const blink::WebInputEvent& event) {}
157 159
158 // The following methods are invoked at most once, when the timing for the 160 // The following methods are invoked at most once, when the timing for the
159 // associated event first becomes available. 161 // associated event first becomes available.
160 virtual void OnDomContentLoadedEventStart( 162 virtual void OnDomContentLoadedEventStart(
161 const PageLoadTiming& timing, 163 const PageLoadTiming& timing,
162 const PageLoadExtraInfo& extra_info) {} 164 const PageLoadExtraInfo& extra_info) {}
163 virtual void OnLoadEventStart(const PageLoadTiming& timing, 165 virtual void OnLoadEventStart(const PageLoadTiming& timing,
(...skipping 11 matching lines...) Expand all
175 virtual void OnParseStart(const PageLoadTiming& timing, 177 virtual void OnParseStart(const PageLoadTiming& timing,
176 const PageLoadExtraInfo& extra_info) {} 178 const PageLoadExtraInfo& extra_info) {}
177 virtual void OnParseStop(const PageLoadTiming& timing, 179 virtual void OnParseStop(const PageLoadTiming& timing,
178 const PageLoadExtraInfo& extra_info) {} 180 const PageLoadExtraInfo& extra_info) {}
179 181
180 // Observer method to be invoked when there is a change in PageLoadMetadata's 182 // Observer method to be invoked when there is a change in PageLoadMetadata's
181 // behavior_flags. 183 // behavior_flags.
182 virtual void OnLoadingBehaviorObserved( 184 virtual void OnLoadingBehaviorObserved(
183 const page_load_metrics::PageLoadExtraInfo& extra_info) {} 185 const page_load_metrics::PageLoadExtraInfo& extra_info) {}
184 186
185 // OnComplete is invoked for tracked page loads, immediately before the 187 // One of OnComplete or OnFailedProvisionalLoad is invoked for tracked page
186 // observer is deleted. The PageLoadTiming struct contains timing data and 188 // loads, immediately before the observer is deleted. These callbacks will not
187 // the PageLoadExtraInfo struct contains other useful data collected over the 189 // be invoked for page loads that did not meet the criteria for being tracked
188 // course of the page load. Most observers should not need to implement this 190 // at the time the navigation completed. The PageLoadTiming struct contains
189 // method, and should implement the On* timing callbacks instead. 191 // timing data and the PageLoadExtraInfo struct contains other useful data
192 // collected over the course of the page load. Most observers should not need
193 // to implement these callbacks, and should implement the On* timing callbacks
194 // instead.
195
196 // OnComplete is invoked for tracked page loads that committed, immediately
197 // before the observer is deleted.
190 virtual void OnComplete(const PageLoadTiming& timing, 198 virtual void OnComplete(const PageLoadTiming& timing,
191 const PageLoadExtraInfo& extra_info) {} 199 const PageLoadExtraInfo& extra_info) {}
200
201 // OnFailedProvisionalLoad is invoked for tracked page loads that did not
202 // commit, immediately before the observer is deleted. Note that provisional
203 // loads that result in downloads or 204s are aborted by the system, and are
204 // also included as failed provisional loads.
205 virtual void OnFailedProvisionalLoad(
206 const FailedProvisionalLoadInfo& failed_provisional_load_info,
207 const PageLoadExtraInfo& extra_info) {}
192 }; 208 };
193 209
194 } // namespace page_load_metrics 210 } // namespace page_load_metrics
195 211
196 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 212 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698