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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/optional.h" | 12 #include "base/optional.h" |
13 #include "chrome/common/page_load_metrics/page_load_timing.h" | 13 #include "chrome/common/page_load_metrics/page_load_timing.h" |
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" |
15 #include "content/public/browser/navigation_handle.h" | 15 #include "content/public/browser/navigation_handle.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "content/public/common/resource_type.h" | |
17 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 18 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace page_load_metrics { | 21 namespace page_load_metrics { |
21 | 22 |
22 // This enum represents how a page load ends. If the action occurs before the | 23 // This enum represents how a page load ends. If the action occurs before the |
23 // page load finishes (or reaches some point like first paint), then we consider | 24 // page load finishes (or reaches some point like first paint), then we consider |
24 // the load to be aborted. | 25 // the load to be aborted. |
25 enum PageEndReason { | 26 enum PageEndReason { |
26 // Page lifetime has not yet ended (page is still active). | 27 // Page lifetime has not yet ended (page is still active). |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 // Extra information supplied to the page load metrics system from the | 193 // Extra information supplied to the page load metrics system from the |
193 // renderer for the main frame. | 194 // renderer for the main frame. |
194 const PageLoadMetadata main_frame_metadata; | 195 const PageLoadMetadata main_frame_metadata; |
195 | 196 |
196 // PageLoadMetadata for child frames of the current page load. | 197 // PageLoadMetadata for child frames of the current page load. |
197 const PageLoadMetadata child_frame_metadata; | 198 const PageLoadMetadata child_frame_metadata; |
198 }; | 199 }; |
199 | 200 |
200 // Container for various information about a request within a page load. | 201 // Container for various information about a request within a page load. |
201 struct ExtraRequestInfo { | 202 struct ExtraRequestInfo { |
202 ExtraRequestInfo(bool was_cached, | 203 ExtraRequestInfo(const GURL& url, |
204 int frame_tree_node_id, | |
205 bool was_cached, | |
203 int64_t raw_body_bytes, | 206 int64_t raw_body_bytes, |
204 int64_t original_network_content_length, | 207 int64_t original_network_content_length, |
205 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 208 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
206 data_reduction_proxy_data); | 209 data_reduction_proxy_data); |
207 | 210 |
208 ~ExtraRequestInfo(); | 211 ~ExtraRequestInfo(); |
209 | 212 |
213 // The URL for the request. | |
214 GURL url; | |
215 | |
216 // The frame tree node id that initiated the request. | |
217 int frame_tree_node_id; | |
218 | |
210 // True if the resource was loaded from cache. | 219 // True if the resource was loaded from cache. |
211 const bool was_cached; | 220 bool was_cached; |
Charlie Harrison
2017/04/24 19:18:26
Why do all these members need to be non-const now?
jkarlin
2017/04/25 15:56:51
Remnant from when earlier when I could copy the cl
| |
212 | 221 |
213 // The number of body (not header) prefilter bytes. | 222 // The number of body (not header) prefilter bytes. |
214 const int64_t raw_body_bytes; | 223 int64_t raw_body_bytes; |
215 | 224 |
216 // The number of body (not header) bytes that the data reduction proxy saw | 225 // The number of body (not header) bytes that the data reduction proxy saw |
217 // before it compressed the requests. | 226 // before it compressed the requests. |
218 const int64_t original_network_content_length; | 227 int64_t original_network_content_length; |
219 | 228 |
220 // Data related to data saver. | 229 // Data related to data saver. |
221 const std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 230 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
222 data_reduction_proxy_data; | 231 data_reduction_proxy_data; |
223 }; | 232 }; |
224 | 233 |
225 // Interface for PageLoadMetrics observers. All instances of this class are | 234 // Interface for PageLoadMetrics observers. All instances of this class are |
226 // owned by the PageLoadTracker tracking a page load. | 235 // owned by the PageLoadTracker tracking a page load. |
227 class PageLoadMetricsObserver { | 236 class PageLoadMetricsObserver { |
228 public: | 237 public: |
229 // ObservePolicy is used as a return value on some PageLoadMetricsObserver | 238 // ObservePolicy is used as a return value on some PageLoadMetricsObserver |
230 // callbacks to indicate whether the observer would like to continue observing | 239 // callbacks to indicate whether the observer would like to continue observing |
231 // metric callbacks. Observers that wish to continue observing metric | 240 // metric callbacks. Observers that wish to continue observing metric |
(...skipping 24 matching lines...) Expand all Loading... | |
256 content::NavigationHandle* navigation_handle); | 265 content::NavigationHandle* navigation_handle); |
257 | 266 |
258 // OnCommit is triggered when a page load commits, i.e. when we receive the | 267 // OnCommit is triggered when a page load commits, i.e. when we receive the |
259 // first data for the request. The navigation handle holds relevant data for | 268 // first data for the request. The navigation handle holds relevant data for |
260 // the navigation, but will be destroyed soon after this call. Don't hold a | 269 // the navigation, but will be destroyed soon after this call. Don't hold a |
261 // reference to it. | 270 // reference to it. |
262 // Observers that return STOP_OBSERVING will not receive any additional | 271 // Observers that return STOP_OBSERVING will not receive any additional |
263 // callbacks, and will be deleted after invocation of this method returns. | 272 // callbacks, and will be deleted after invocation of this method returns. |
264 virtual ObservePolicy OnCommit(content::NavigationHandle* navigation_handle); | 273 virtual ObservePolicy OnCommit(content::NavigationHandle* navigation_handle); |
265 | 274 |
275 // OnDidFinishSubFrameNavigation is triggered when a sub-frame of the | |
276 // committed page has finished navigating. It has either committed, aborted, | |
277 // was a same document navigation, or has been replaced. It is up to the | |
278 // observer to query the navigation_handle to determine which happened. The | |
Charlie Harrison
2017/04/24 19:18:26
Be consistent when referencing navigation_handle i
jkarlin
2017/04/25 15:56:51
Replaced with |navigation_handle|
| |
279 // navigation handle holds relevant data for the navigation, but will be | |
280 // destroyed soon after this call. Don't hold a reference to it. | |
281 virtual ObservePolicy OnDidFinishSubFrameNavigation( | |
282 content::NavigationHandle* navigation_handle); | |
283 | |
266 // OnHidden is triggered when a page leaves the foreground. It does not fire | 284 // OnHidden is triggered when a page leaves the foreground. It does not fire |
267 // when a foreground page is permanently closed; for that, listen to | 285 // when a foreground page is permanently closed; for that, listen to |
268 // OnComplete instead. | 286 // OnComplete instead. |
269 virtual ObservePolicy OnHidden(const PageLoadTiming& timing, | 287 virtual ObservePolicy OnHidden(const PageLoadTiming& timing, |
270 const PageLoadExtraInfo& extra_info); | 288 const PageLoadExtraInfo& extra_info); |
271 | 289 |
272 // OnShown is triggered when a page is brought to the foreground. It does not | 290 // OnShown is triggered when a page is brought to the foreground. It does not |
273 // fire when the page first loads; for that, listen for OnStart instead. | 291 // fire when the page first loads; for that, listen for OnStart instead. |
274 virtual ObservePolicy OnShown(); | 292 virtual ObservePolicy OnShown(); |
275 | 293 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 // frequently on Android). | 388 // frequently on Android). |
371 virtual void OnComplete(const PageLoadTiming& timing, | 389 virtual void OnComplete(const PageLoadTiming& timing, |
372 const PageLoadExtraInfo& extra_info) {} | 390 const PageLoadExtraInfo& extra_info) {} |
373 | 391 |
374 // OnFailedProvisionalLoad is invoked for tracked page loads that did not | 392 // OnFailedProvisionalLoad is invoked for tracked page loads that did not |
375 // commit, immediately before the observer is deleted. | 393 // commit, immediately before the observer is deleted. |
376 virtual void OnFailedProvisionalLoad( | 394 virtual void OnFailedProvisionalLoad( |
377 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 395 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
378 const PageLoadExtraInfo& extra_info) {} | 396 const PageLoadExtraInfo& extra_info) {} |
379 | 397 |
380 // Called whenever a request is loaded for this page load. | 398 // Called whenever a request is loaded for this page load. This comes |
399 // unfiltered from the ResourceDispatcherHost and may include blob requests | |
400 // and data uris. | |
381 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} | 401 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} |
382 }; | 402 }; |
383 | 403 |
384 } // namespace page_load_metrics | 404 } // namespace page_load_metrics |
385 | 405 |
386 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 406 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |