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

Side by Side Diff: chrome/browser/page_load_metrics/page_load_metrics_observer.h

Issue 2371883002: Add PLMObserver::FlushMetricsOnAppEnterBackground. (Closed)
Patch Set: fix comment Created 4 years, 2 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 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
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 {
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
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 the browser
225 // process may be killed after backgrounding (Android). Implementers should
226 // persist any metrics that have been buffered in memory in this callback, as
227 // the application may be killed at any time after this method is invoked
228 // without further notification. Note that this may be called both for
229 // provisional loads as well as committed loads. Implementations that only
230 // want to track committed loads should check extra_info.time_to_commit to
231 // determine if the load had committed. If the implementation returns
232 // CONTINUE_OBSERVING, this method may be called multiple times per observer,
233 // once for each time that the application enters the backround.
234 //
235 // The default implementation does nothing, and returns CONTINUE_OBSERVING.
236 virtual ObservePolicy FlushMetricsOnAppEnterBackground(
237 const PageLoadTiming& timing,
238 const PageLoadExtraInfo& extra_info);
239
213 // One of OnComplete or OnFailedProvisionalLoad is invoked for tracked page 240 // One of OnComplete or OnFailedProvisionalLoad is invoked for tracked page
214 // loads, immediately before the observer is deleted. These callbacks will not 241 // 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 242 // 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 243 // at the time the navigation completed. The PageLoadTiming struct contains
217 // timing data and the PageLoadExtraInfo struct contains other useful data 244 // timing data and the PageLoadExtraInfo struct contains other useful data
218 // collected over the course of the page load. Most observers should not need 245 // 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 246 // to implement these callbacks, and should implement the On* timing callbacks
220 // instead. 247 // instead.
221 248
222 // OnComplete is invoked for tracked page loads that committed, immediately 249 // OnComplete is invoked for tracked page loads that committed, immediately
223 // before the observer is deleted. 250 // before the observer is deleted.
224 virtual void OnComplete(const PageLoadTiming& timing, 251 virtual void OnComplete(const PageLoadTiming& timing,
225 const PageLoadExtraInfo& extra_info) {} 252 const PageLoadExtraInfo& extra_info) {}
226 253
227 // OnFailedProvisionalLoad is invoked for tracked page loads that did not 254 // OnFailedProvisionalLoad is invoked for tracked page loads that did not
228 // commit, immediately before the observer is deleted. Note that provisional 255 // 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 256 // loads that result in downloads or 204s are aborted by the system, and are
230 // also included as failed provisional loads. 257 // also included as failed provisional loads.
231 virtual void OnFailedProvisionalLoad( 258 virtual void OnFailedProvisionalLoad(
232 const FailedProvisionalLoadInfo& failed_provisional_load_info, 259 const FailedProvisionalLoadInfo& failed_provisional_load_info,
233 const PageLoadExtraInfo& extra_info) {} 260 const PageLoadExtraInfo& extra_info) {}
234 }; 261 };
235 262
236 } // namespace page_load_metrics 263 } // namespace page_load_metrics
237 264
238 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ 265 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698