Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_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 "chrome/common/page_load_metrics/page_load_timing.h" | 10 #include "chrome/common/page_load_metrics/page_load_timing.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 | 121 |
| 122 // Extra information supplied to the page load metrics system from the | 122 // Extra information supplied to the page load metrics system from the |
| 123 // renderer. | 123 // renderer. |
| 124 const PageLoadMetadata metadata; | 124 const PageLoadMetadata metadata; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 // Interface for PageLoadMetrics observers. All instances of this class are | 127 // Interface for PageLoadMetrics observers. All instances of this class are |
| 128 // owned by the PageLoadTracker tracking a page load. | 128 // owned by the PageLoadTracker tracking a page load. |
| 129 class PageLoadMetricsObserver { | 129 class PageLoadMetricsObserver { |
| 130 public: | 130 public: |
| 131 // ObservePolicy is used as a return value on some PageLoadMetricsObserver | |
| 132 // callbacks to indicate whether the observer would like to continue observing | |
| 133 // metric callbacks. Observers that wish to continue observing metric | |
| 134 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop | |
| 135 // observing callbacks should return STOP_OBSERVING. Observers that return | |
| 136 // STOP_OBSERVING may be deleted. | |
| 137 enum ObservePolicy { | |
|
Charlie Harrison
2016/09/26 20:56:39
Cool. This is a nice generalization of what I had
Bryan McQuade
2016/09/27 13:17:20
Thanks for putting your change together! Glad we c
| |
| 138 CONTINUE_OBSERVING, | |
| 139 STOP_OBSERVING, | |
| 140 }; | |
| 141 | |
| 131 virtual ~PageLoadMetricsObserver() {} | 142 virtual ~PageLoadMetricsObserver() {} |
| 132 | 143 |
| 133 // The page load started, with the given navigation handle. Note that OnStart | 144 // The page load started, with the given navigation handle. Note that OnStart |
| 134 // is called for same-page navigations. Implementers of OnStart that only want | 145 // is called for same-page navigations. Implementers of OnStart that only want |
| 135 // to process non-same-page navigations should also check to see that the page | 146 // to process non-same-page navigations should also check to see that the page |
| 136 // load committed via OnCommit or committed_url in | 147 // load committed via OnCommit or committed_url in |
| 137 // PageLoadExtraInfo. currently_committed_url contains the URL of the | 148 // PageLoadExtraInfo. currently_committed_url contains the URL of the |
| 138 // committed page load at the time the navigation for navigation_handle was | 149 // committed page load at the time the navigation for navigation_handle was |
| 139 // initiated, or the empty URL if there was no committed page load at the time | 150 // initiated, or the empty URL if there was no committed page load at the time |
| 140 // the navigation was initiated. | 151 // the navigation was initiated. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 const PageLoadExtraInfo& extra_info) {} | 209 const PageLoadExtraInfo& extra_info) {} |
| 199 virtual void OnFirstContentfulPaint(const PageLoadTiming& timing, | 210 virtual void OnFirstContentfulPaint(const PageLoadTiming& timing, |
| 200 const PageLoadExtraInfo& extra_info) {} | 211 const PageLoadExtraInfo& extra_info) {} |
| 201 virtual void OnFirstMeaningfulPaint(const PageLoadTiming& timing, | 212 virtual void OnFirstMeaningfulPaint(const PageLoadTiming& timing, |
| 202 const PageLoadExtraInfo& extra_info) {} | 213 const PageLoadExtraInfo& extra_info) {} |
| 203 virtual void OnParseStart(const PageLoadTiming& timing, | 214 virtual void OnParseStart(const PageLoadTiming& timing, |
| 204 const PageLoadExtraInfo& extra_info) {} | 215 const PageLoadExtraInfo& extra_info) {} |
| 205 virtual void OnParseStop(const PageLoadTiming& timing, | 216 virtual void OnParseStop(const PageLoadTiming& timing, |
| 206 const PageLoadExtraInfo& extra_info) {} | 217 const PageLoadExtraInfo& extra_info) {} |
| 207 | 218 |
| 208 // Observer method to be invoked when there is a change in PageLoadMetadata's | 219 // Invoked when there is a change in PageLoadMetadata's behavior_flags. |
| 209 // behavior_flags. | |
| 210 virtual void OnLoadingBehaviorObserved( | 220 virtual void OnLoadingBehaviorObserved( |
| 211 const page_load_metrics::PageLoadExtraInfo& extra_info) {} | 221 const page_load_metrics::PageLoadExtraInfo& extra_info) {} |
| 212 | 222 |
| 223 // Invoked when the UMA metrics subsystem is persisting metrics as the | |
| 224 // application goes into the background, on platforms where metrics are | |
|
Charlie Harrison
2016/09/27 12:50:09
s/are/should be?
Bryan McQuade
2016/09/27 13:17:20
Updated the comment to be a clearer, thanks!
| |
| 225 // persisted as part of backgrounding (Android). Implementers should persist | |
|
Charlie Harrison
2016/09/27 12:50:09
Note: there have been experiments where background
Bryan McQuade
2016/09/27 13:17:20
Ah, I didn't know about this. I think we'd want to
| |
| 226 // any metrics that have been buffered in memory in this callback, as the | |
| 227 // application may be killed at any time after this method is invoked without | |
| 228 // further notification. Note that this may be called both for provisional | |
| 229 // loads as well as committed loads. Implementations that only want to track | |
| 230 // committed loads should check extra_info.time_to_commit to determine if the | |
| 231 // load had committed. The default implementation returns | |
| 232 // CONTINUE_OBSERVING. If the implementation returns CONTINUE_OBSERVING, this | |
| 233 // method may be called multiple times per observer, once for each time that | |
| 234 // the application enters the backround. | |
| 235 virtual ObservePolicy FlushMetricsOnAppEnterBackground( | |
| 236 const PageLoadTiming& timing, | |
| 237 const PageLoadExtraInfo& extra_info); | |
| 238 | |
| 213 // One of OnComplete or OnFailedProvisionalLoad is invoked for tracked page | 239 // One of OnComplete or OnFailedProvisionalLoad is invoked for tracked page |
| 214 // loads, immediately before the observer is deleted. These callbacks will not | 240 // loads, immediately before the observer is deleted. These callbacks will not |
| 215 // be invoked for page loads that did not meet the criteria for being tracked | 241 // be invoked for page loads that did not meet the criteria for being tracked |
| 216 // at the time the navigation completed. The PageLoadTiming struct contains | 242 // at the time the navigation completed. The PageLoadTiming struct contains |
| 217 // timing data and the PageLoadExtraInfo struct contains other useful data | 243 // timing data and the PageLoadExtraInfo struct contains other useful data |
| 218 // collected over the course of the page load. Most observers should not need | 244 // collected over the course of the page load. Most observers should not need |
| 219 // to implement these callbacks, and should implement the On* timing callbacks | 245 // to implement these callbacks, and should implement the On* timing callbacks |
| 220 // instead. | 246 // instead. |
| 221 | 247 |
| 222 // OnComplete is invoked for tracked page loads that committed, immediately | 248 // OnComplete is invoked for tracked page loads that committed, immediately |
| 223 // before the observer is deleted. | 249 // before the observer is deleted. |
| 224 virtual void OnComplete(const PageLoadTiming& timing, | 250 virtual void OnComplete(const PageLoadTiming& timing, |
| 225 const PageLoadExtraInfo& extra_info) {} | 251 const PageLoadExtraInfo& extra_info) {} |
| 226 | 252 |
| 227 // OnFailedProvisionalLoad is invoked for tracked page loads that did not | 253 // OnFailedProvisionalLoad is invoked for tracked page loads that did not |
| 228 // commit, immediately before the observer is deleted. Note that provisional | 254 // commit, immediately before the observer is deleted. Note that provisional |
| 229 // loads that result in downloads or 204s are aborted by the system, and are | 255 // loads that result in downloads or 204s are aborted by the system, and are |
| 230 // also included as failed provisional loads. | 256 // also included as failed provisional loads. |
| 231 virtual void OnFailedProvisionalLoad( | 257 virtual void OnFailedProvisionalLoad( |
| 232 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 258 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
| 233 const PageLoadExtraInfo& extra_info) {} | 259 const PageLoadExtraInfo& extra_info) {} |
| 234 }; | 260 }; |
| 235 | 261 |
| 236 } // namespace page_load_metrics | 262 } // namespace page_load_metrics |
| 237 | 263 |
| 238 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 264 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
| OLD | NEW |