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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 const base::Optional<base::TimeDelta>& first_foreground_time, | 116 const base::Optional<base::TimeDelta>& first_foreground_time, |
117 bool started_in_foreground, | 117 bool started_in_foreground, |
118 UserInitiatedInfo user_initiated_info, | 118 UserInitiatedInfo user_initiated_info, |
119 const GURL& url, | 119 const GURL& url, |
120 const GURL& start_url, | 120 const GURL& start_url, |
121 bool did_commit, | 121 bool did_commit, |
122 PageEndReason page_end_reason, | 122 PageEndReason page_end_reason, |
123 UserInitiatedInfo page_end_user_initiated_info, | 123 UserInitiatedInfo page_end_user_initiated_info, |
124 const base::Optional<base::TimeDelta>& page_end_time, | 124 const base::Optional<base::TimeDelta>& page_end_time, |
125 const PageLoadMetadata& main_frame_metadata, | 125 const PageLoadMetadata& main_frame_metadata, |
126 const PageLoadMetadata& child_frame_metadata); | 126 const PageLoadMetadata& subframe_metadata); |
127 | 127 |
128 // Simplified version of the constructor, intended for use in tests. | 128 // Simplified version of the constructor, intended for use in tests. |
129 static PageLoadExtraInfo CreateForTesting(const GURL& url, | 129 static PageLoadExtraInfo CreateForTesting(const GURL& url, |
130 bool started_in_foreground); | 130 bool started_in_foreground); |
131 | 131 |
132 PageLoadExtraInfo(const PageLoadExtraInfo& other); | 132 PageLoadExtraInfo(const PageLoadExtraInfo& other); |
133 | 133 |
134 ~PageLoadExtraInfo(); | 134 ~PageLoadExtraInfo(); |
135 | 135 |
136 // The time the navigation was initiated. | 136 // The time the navigation was initiated. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // * the render process hosting the page goes away | 187 // * the render process hosting the page goes away |
188 // * a new navigation which later commits is initiated in the same tab | 188 // * a new navigation which later commits is initiated in the same tab |
189 // This field will not be set if the page is still active and hasn't yet | 189 // This field will not be set if the page is still active and hasn't yet |
190 // finished. | 190 // finished. |
191 const base::Optional<base::TimeDelta> page_end_time; | 191 const base::Optional<base::TimeDelta> page_end_time; |
192 | 192 |
193 // Extra information supplied to the page load metrics system from the | 193 // Extra information supplied to the page load metrics system from the |
194 // renderer for the main frame. | 194 // renderer for the main frame. |
195 const PageLoadMetadata main_frame_metadata; | 195 const PageLoadMetadata main_frame_metadata; |
196 | 196 |
197 // PageLoadMetadata for child frames of the current page load. | 197 // PageLoadMetadata for subframes of the current page load. |
198 const PageLoadMetadata child_frame_metadata; | 198 const PageLoadMetadata subframe_metadata; |
199 }; | 199 }; |
200 | 200 |
201 // Container for various information about a completed request within a page | 201 // Container for various information about a completed request within a page |
202 // load. | 202 // load. |
203 struct ExtraRequestCompleteInfo { | 203 struct ExtraRequestCompleteInfo { |
204 ExtraRequestCompleteInfo( | 204 ExtraRequestCompleteInfo( |
205 const GURL& url, | 205 const GURL& url, |
206 int frame_tree_node_id, | 206 int frame_tree_node_id, |
207 bool was_cached, | 207 bool was_cached, |
208 int64_t raw_body_bytes, | 208 int64_t raw_body_bytes, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // callbacks to indicate whether the observer would like to continue observing | 263 // callbacks to indicate whether the observer would like to continue observing |
264 // metric callbacks. Observers that wish to continue observing metric | 264 // metric callbacks. Observers that wish to continue observing metric |
265 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop | 265 // callbacks should return CONTINUE_OBSERVING; observers that wish to stop |
266 // observing callbacks should return STOP_OBSERVING. Observers that return | 266 // observing callbacks should return STOP_OBSERVING. Observers that return |
267 // STOP_OBSERVING may be deleted. | 267 // STOP_OBSERVING may be deleted. |
268 enum ObservePolicy { | 268 enum ObservePolicy { |
269 CONTINUE_OBSERVING, | 269 CONTINUE_OBSERVING, |
270 STOP_OBSERVING, | 270 STOP_OBSERVING, |
271 }; | 271 }; |
272 | 272 |
| 273 using FrameTreeNodeId = int; |
| 274 |
273 virtual ~PageLoadMetricsObserver() {} | 275 virtual ~PageLoadMetricsObserver() {} |
274 | 276 |
275 // The page load started, with the given navigation handle. | 277 // The page load started, with the given navigation handle. |
276 // currently_committed_url contains the URL of the committed page load at the | 278 // currently_committed_url contains the URL of the committed page load at the |
277 // time the navigation for navigation_handle was initiated, or the empty URL | 279 // time the navigation for navigation_handle was initiated, or the empty URL |
278 // if there was no committed page load at the time the navigation was | 280 // if there was no committed page load at the time the navigation was |
279 // initiated. | 281 // initiated. |
280 virtual ObservePolicy OnStart(content::NavigationHandle* navigation_handle, | 282 virtual ObservePolicy OnStart(content::NavigationHandle* navigation_handle, |
281 const GURL& currently_committed_url, | 283 const GURL& currently_committed_url, |
282 bool started_in_foreground); | 284 bool started_in_foreground); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // callbacks below. | 330 // callbacks below. |
329 | 331 |
330 // OnTimingUpdate is triggered when an updated PageLoadTiming is | 332 // OnTimingUpdate is triggered when an updated PageLoadTiming is |
331 // available. This method may be called multiple times over the course of the | 333 // available. This method may be called multiple times over the course of the |
332 // page load. This method is currently only intended for use in testing. Most | 334 // page load. This method is currently only intended for use in testing. Most |
333 // implementers should implement one of the On* callbacks, such as | 335 // implementers should implement one of the On* callbacks, such as |
334 // OnFirstContentfulPaint or OnDomContentLoadedEventStart. Please email | 336 // OnFirstContentfulPaint or OnDomContentLoadedEventStart. Please email |
335 // loading-dev@chromium.org if you intend to override this method. | 337 // loading-dev@chromium.org if you intend to override this method. |
336 virtual void OnTimingUpdate(const PageLoadTiming& timing, | 338 virtual void OnTimingUpdate(const PageLoadTiming& timing, |
337 const PageLoadExtraInfo& extra_info) {} | 339 const PageLoadExtraInfo& extra_info) {} |
| 340 |
338 // OnUserInput is triggered when a new user input is passed in to | 341 // OnUserInput is triggered when a new user input is passed in to |
339 // web_contents. Contains a TimeDelta from navigation start. | 342 // web_contents. Contains a TimeDelta from navigation start. |
340 virtual void OnUserInput(const blink::WebInputEvent& event) {} | 343 virtual void OnUserInput(const blink::WebInputEvent& event) {} |
341 | 344 |
342 // The following methods are invoked at most once, when the timing for the | 345 // The following methods are invoked at most once, when the timing for the |
343 // associated event first becomes available. | 346 // associated event first becomes available. |
344 virtual void OnDomContentLoadedEventStart( | 347 virtual void OnDomContentLoadedEventStart( |
345 const PageLoadTiming& timing, | 348 const PageLoadTiming& timing, |
346 const PageLoadExtraInfo& extra_info) {} | 349 const PageLoadExtraInfo& extra_info) {} |
347 virtual void OnLoadEventStart(const PageLoadTiming& timing, | 350 virtual void OnLoadEventStart(const PageLoadTiming& timing, |
348 const PageLoadExtraInfo& extra_info) {} | 351 const PageLoadExtraInfo& extra_info) {} |
349 virtual void OnFirstLayout(const PageLoadTiming& timing, | 352 virtual void OnFirstLayout(const PageLoadTiming& timing, |
350 const PageLoadExtraInfo& extra_info) {} | 353 const PageLoadExtraInfo& extra_info) {} |
351 virtual void OnFirstPaint(const PageLoadTiming& timing, | |
352 const PageLoadExtraInfo& extra_info) {} | |
353 virtual void OnFirstTextPaint(const PageLoadTiming& timing, | |
354 const PageLoadExtraInfo& extra_info) {} | |
355 virtual void OnFirstImagePaint(const PageLoadTiming& timing, | |
356 const PageLoadExtraInfo& extra_info) {} | |
357 virtual void OnFirstContentfulPaint(const PageLoadTiming& timing, | |
358 const PageLoadExtraInfo& extra_info) {} | |
359 virtual void OnFirstMeaningfulPaint(const PageLoadTiming& timing, | |
360 const PageLoadExtraInfo& extra_info) {} | |
361 virtual void OnParseStart(const PageLoadTiming& timing, | 354 virtual void OnParseStart(const PageLoadTiming& timing, |
362 const PageLoadExtraInfo& extra_info) {} | 355 const PageLoadExtraInfo& extra_info) {} |
363 virtual void OnParseStop(const PageLoadTiming& timing, | 356 virtual void OnParseStop(const PageLoadTiming& timing, |
364 const PageLoadExtraInfo& extra_info) {} | 357 const PageLoadExtraInfo& extra_info) {} |
365 | 358 |
| 359 // On*PaintInPage(...) are invoked when the first relevant paint in the page, |
| 360 // across all frames, is observed. |
| 361 virtual void OnFirstPaintInPage(const PageLoadTiming& timing, |
| 362 const PageLoadExtraInfo& extra_info) {} |
| 363 virtual void OnFirstTextPaintInPage(const PageLoadTiming& timing, |
| 364 const PageLoadExtraInfo& extra_info) {} |
| 365 virtual void OnFirstImagePaintInPage(const PageLoadTiming& timing, |
| 366 const PageLoadExtraInfo& extra_info) {} |
| 367 virtual void OnFirstContentfulPaintInPage( |
| 368 const PageLoadTiming& timing, |
| 369 const PageLoadExtraInfo& extra_info) {} |
| 370 |
| 371 // Unlike other paint callbacks, OnFirstMeaningfulPaintInMainFrameDocument is |
| 372 // tracked per document, and is reported for the main frame document only. |
| 373 virtual void OnFirstMeaningfulPaintInMainFrameDocument( |
| 374 const PageLoadTiming& timing, |
| 375 const PageLoadExtraInfo& extra_info) {} |
| 376 |
366 // Invoked when there is a change in either the main_frame_metadata or the | 377 // Invoked when there is a change in either the main_frame_metadata or the |
367 // child_frame_metadata's loading behavior_flags. | 378 // subframe_metadata's loading behavior_flags. |
368 virtual void OnLoadingBehaviorObserved( | 379 virtual void OnLoadingBehaviorObserved( |
369 const page_load_metrics::PageLoadExtraInfo& extra_info) {} | 380 const page_load_metrics::PageLoadExtraInfo& extra_info) {} |
370 | 381 |
371 // Invoked when a media element starts playing. | 382 // Invoked when a media element starts playing. |
372 virtual void MediaStartedPlaying( | 383 virtual void MediaStartedPlaying( |
373 const content::WebContentsObserver::MediaPlayerInfo& video_type, | 384 const content::WebContentsObserver::MediaPlayerInfo& video_type, |
374 bool is_in_main_frame) {} | 385 bool is_in_main_frame) {} |
375 | 386 |
376 // Invoked on navigations where a navigation delay was added by the | 387 // Invoked on navigations where a navigation delay was added by the |
377 // DelayNavigationThrottle. This is a temporary method that will be removed | 388 // DelayNavigationThrottle. This is a temporary method that will be removed |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Called whenever a request is loaded for this page load. This comes | 437 // Called whenever a request is loaded for this page load. This comes |
427 // unfiltered from the ResourceDispatcherHost and may include blob requests | 438 // unfiltered from the ResourceDispatcherHost and may include blob requests |
428 // and data uris. | 439 // and data uris. |
429 virtual void OnLoadedResource( | 440 virtual void OnLoadedResource( |
430 const ExtraRequestCompleteInfo& extra_request_complete_info) {} | 441 const ExtraRequestCompleteInfo& extra_request_complete_info) {} |
431 }; | 442 }; |
432 | 443 |
433 } // namespace page_load_metrics | 444 } // namespace page_load_metrics |
434 | 445 |
435 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 446 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |