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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // ResourceRequestInfo objects while this is the currently committed load in | 117 // ResourceRequestInfo objects while this is the currently committed load in |
118 // the WebContents. | 118 // the WebContents. |
119 int num_cache_requests; | 119 int num_cache_requests; |
120 int num_network_requests; | 120 int num_network_requests; |
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 enum TrackingPolicy { |
| 128 TRACK, |
| 129 IGNORE, |
| 130 }; |
| 131 |
127 // Interface for PageLoadMetrics observers. All instances of this class are | 132 // Interface for PageLoadMetrics observers. All instances of this class are |
128 // owned by the PageLoadTracker tracking a page load. | 133 // owned by the PageLoadTracker tracking a page load. |
129 class PageLoadMetricsObserver { | 134 class PageLoadMetricsObserver { |
130 public: | 135 public: |
131 virtual ~PageLoadMetricsObserver() {} | 136 virtual ~PageLoadMetricsObserver() {} |
132 | 137 |
| 138 // Called before OnStart and OnCommit. If the method returns false, no further |
| 139 // callbacks will occur in the observer. |
| 140 virtual TrackingPolicy ShouldTrackLoad( |
| 141 content::NavigationHandle* navigation_handle); |
| 142 |
133 // The page load started, with the given navigation handle. Note that OnStart | 143 // 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 | 144 // 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 | 145 // to process non-same-page navigations should also check to see that the page |
136 // load committed via OnCommit or committed_url in | 146 // load committed via OnCommit or committed_url in |
137 // PageLoadExtraInfo. currently_committed_url contains the URL of the | 147 // PageLoadExtraInfo. currently_committed_url contains the URL of the |
138 // committed page load at the time the navigation for navigation_handle was | 148 // 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 | 149 // initiated, or the empty URL if there was no committed page load at the time |
140 // the navigation was initiated. | 150 // the navigation was initiated. |
141 virtual void OnStart(content::NavigationHandle* navigation_handle, | 151 virtual void OnStart(content::NavigationHandle* navigation_handle, |
142 const GURL& currently_committed_url, | 152 const GURL& currently_committed_url, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // loads that result in downloads or 204s are aborted by the system, and are | 239 // loads that result in downloads or 204s are aborted by the system, and are |
230 // also included as failed provisional loads. | 240 // also included as failed provisional loads. |
231 virtual void OnFailedProvisionalLoad( | 241 virtual void OnFailedProvisionalLoad( |
232 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 242 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
233 const PageLoadExtraInfo& extra_info) {} | 243 const PageLoadExtraInfo& extra_info) {} |
234 }; | 244 }; |
235 | 245 |
236 } // namespace page_load_metrics | 246 } // namespace page_load_metrics |
237 | 247 |
238 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 248 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |