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 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 // aborted, |abort_type| will be |ABORT_NONE|. | 85 // aborted, |abort_type| will be |ABORT_NONE|. |
| 86 const UserAbortType abort_type; | 86 const UserAbortType abort_type; |
| 87 const base::Optional<base::TimeDelta> time_to_abort; | 87 const base::Optional<base::TimeDelta> time_to_abort; |
| 88 | 88 |
| 89 // Extra information supplied to the page load metrics system from the | 89 // Extra information supplied to the page load metrics system from the |
| 90 // renderer. | 90 // renderer. |
| 91 const PageLoadMetadata metadata; | 91 const PageLoadMetadata metadata; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // Interface for PageLoadMetrics observers. All instances of this class are | 94 // Interface for PageLoadMetrics observers. All instances of this class are |
| 95 // owned by the PageLoadTracker tracking a page load. They will be deleted after | 95 // owned by the PageLoadTracker tracking a page load. |
| 96 // calling OnComplete. | |
| 97 class PageLoadMetricsObserver { | 96 class PageLoadMetricsObserver { |
| 98 public: | 97 public: |
| 99 virtual ~PageLoadMetricsObserver() {} | 98 virtual ~PageLoadMetricsObserver() {} |
| 100 | 99 |
| 101 // The page load started, with the given navigation handle. Note that OnStart | 100 // The page load started, with the given navigation handle. Note that OnStart |
| 102 // is called for same-page navigations. Implementers of OnStart that only want | 101 // is called for same-page navigations. Implementers of OnStart that only want |
| 103 // to process non-same-page navigations should also check to see that the page | 102 // to process non-same-page navigations should also check to see that the page |
| 104 // load committed via OnCommit or committed_url in | 103 // load committed via OnCommit or committed_url in |
| 105 // PageLoadExtraInfo. currently_committed_url contains the URL of the | 104 // PageLoadExtraInfo. currently_committed_url contains the URL of the |
| 106 // committed page load at the time the navigation for navigation_handle was | 105 // committed page load at the time the navigation for navigation_handle was |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 122 // reference to it. | 121 // reference to it. |
| 123 // Note that this does not get called for same page navigations. | 122 // Note that this does not get called for same page navigations. |
| 124 virtual void OnCommit(content::NavigationHandle* navigation_handle) {} | 123 virtual void OnCommit(content::NavigationHandle* navigation_handle) {} |
| 125 | 124 |
| 126 // OnFailedProvisionalLoad is triggered when a provisional load failed and did | 125 // OnFailedProvisionalLoad is triggered when a provisional load failed and did |
| 127 // not commit. Note that provisional loads that result in downloads or 204s | 126 // not commit. Note that provisional loads that result in downloads or 204s |
| 128 // are aborted by the system, and thus considered failed provisional loads. | 127 // are aborted by the system, and thus considered failed provisional loads. |
| 129 virtual void OnFailedProvisionalLoad( | 128 virtual void OnFailedProvisionalLoad( |
| 130 content::NavigationHandle* navigation_handle) {} | 129 content::NavigationHandle* navigation_handle) {} |
| 131 | 130 |
| 132 // OnTimingUpdate is triggered when an updated PageLoadTiming is | 131 // OnTimingUpdate is triggered when an updated PageLoadTiming is |
|
Charlie Harrison
2016/07/15 13:01:17
Can you include a comment that none of the On* cal
Bryan McQuade
2016/07/15 14:14:43
Good point, yes, I re-ordered the callbacks and ad
| |
| 133 // available. This method may be called multiple times over the course of the | 132 // available. This method may be called multiple times over the course of the |
| 134 // page load. Note that this is currently an experimental API which may be | 133 // page load. This method is currently only intended for use in testing. Most |
| 135 // removed in the future. Please email loading-dev@chromium.org if you intend | 134 // implementers should implement one of the On* callbacks, such as |
| 136 // to override this method. | 135 // OnFirstContentfulPaint or OnDomContentLoadedEventStart. Please email |
| 136 // loading-dev@chromium.org if you intend to override this method. | |
| 137 virtual void OnTimingUpdate(const PageLoadTiming& timing, | 137 virtual void OnTimingUpdate(const PageLoadTiming& timing, |
| 138 const PageLoadExtraInfo& extra_info) {} | 138 const PageLoadExtraInfo& extra_info) {} |
| 139 | 139 |
| 140 // OnHidden is triggered when a page leaves the foreground. It does not fire | 140 // OnHidden is triggered when a page leaves the foreground. It does not fire |
| 141 // when a foreground page is permanently closed; for that, listen to | 141 // when a foreground page is permanently closed; for that, listen to |
| 142 // OnComplete instead. | 142 // OnComplete instead. |
| 143 virtual void OnHidden() {} | 143 virtual void OnHidden() {} |
| 144 | 144 |
| 145 // OnShown is triggered when a page is brought to the foreground. It does not | 145 // OnShown is triggered when a page is brought to the foreground. It does not |
| 146 // fire when the page first loads; for that, listen for OnStart instead. | 146 // fire when the page first loads; for that, listen for OnStart instead. |
| 147 virtual void OnShown() {} | 147 virtual void OnShown() {} |
| 148 | 148 |
| 149 // OnComplete is triggered when we are ready to record metrics for this page | 149 // OnComplete is triggered when we are ready to record metrics for this page |
| 150 // load. This will happen some time after commit. The PageLoadTiming struct | 150 // load. This will happen some time after commit. The PageLoadTiming struct |
| 151 // contains timing data and the PageLoadExtraInfo struct contains other useful | 151 // contains timing data and the PageLoadExtraInfo struct contains other useful |
| 152 // data collected over the course of the page load. If the load did not | 152 // data collected over the course of the page load. OnComplete will not be |
| 153 // receive any timing information, |timing.IsEmpty()| will be true. | 153 // called for page loads that did not meet the criteria for tracking metrics |
| 154 // After this call, the object will be deleted. | 154 // at the time the navigation committed. After this call, the object will be |
| 155 // deleted. | |
| 155 virtual void OnComplete(const PageLoadTiming& timing, | 156 virtual void OnComplete(const PageLoadTiming& timing, |
| 156 const PageLoadExtraInfo& extra_info) {} | 157 const PageLoadExtraInfo& extra_info) {} |
| 157 | 158 |
| 158 // OnUserInput is triggered when a new user input is passed in to | 159 // OnUserInput is triggered when a new user input is passed in to |
| 159 // web_contents. Contains a TimeDelta from navigation start. | 160 // web_contents. Contains a TimeDelta from navigation start. |
| 160 virtual void OnUserInput(const blink::WebInputEvent& event) {} | 161 virtual void OnUserInput(const blink::WebInputEvent& event) {} |
| 161 | 162 |
| 162 // The following methods are invoked at most once, when the timing for the | 163 // The following methods are invoked at most once, when the timing for the |
| 163 // associated event first becomes available. | 164 // associated event first becomes available. |
| 164 virtual void OnDomContentLoadedEventStart( | 165 virtual void OnDomContentLoadedEventStart( |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 183 | 184 |
| 184 // Observer method to be invoked when there is a change in PageLoadMetadata's | 185 // Observer method to be invoked when there is a change in PageLoadMetadata's |
| 185 // behavior_flags. | 186 // behavior_flags. |
| 186 virtual void OnLoadingBehaviorObserved( | 187 virtual void OnLoadingBehaviorObserved( |
| 187 const page_load_metrics::PageLoadExtraInfo& extra_info) {} | 188 const page_load_metrics::PageLoadExtraInfo& extra_info) {} |
| 188 }; | 189 }; |
| 189 | 190 |
| 190 } // namespace page_load_metrics | 191 } // namespace page_load_metrics |
| 191 | 192 |
| 192 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ | 193 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ |
| OLD | NEW |