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 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); |
| 210 ~ExtraRequestInfo(); | |
| 207 | 211 |
| 208 ~ExtraRequestInfo(); | 212 // The URL for the request. |
| 213 const GURL url; | |
| 214 | |
| 215 // The frame tree node id that initiated the request. | |
| 216 const int frame_tree_node_id; | |
| 209 | 217 |
| 210 // True if the resource was loaded from cache. | 218 // True if the resource was loaded from cache. |
| 211 const bool was_cached; | 219 const bool was_cached; |
| 212 | 220 |
| 213 // The number of body (not header) prefilter bytes. | 221 // The number of body (not header) prefilter bytes. |
| 214 const int64_t raw_body_bytes; | 222 const int64_t raw_body_bytes; |
| 215 | 223 |
| 216 // The number of body (not header) bytes that the data reduction proxy saw | 224 // The number of body (not header) bytes that the data reduction proxy saw |
| 217 // before it compressed the requests. | 225 // before it compressed the requests. |
| 218 const int64_t original_network_content_length; | 226 const int64_t original_network_content_length; |
| 219 | 227 |
| 220 // Data related to data saver. | 228 // Data related to data saver. |
| 221 const std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 229 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
|
Bryan McQuade
2017/04/25 16:36:44
why the change to make this non-const?
jkarlin
2017/04/25 16:42:51
oversight, thanks!
| |
| 222 data_reduction_proxy_data; | 230 data_reduction_proxy_data; |
| 223 }; | 231 }; |
| 224 | 232 |
| 225 // Interface for PageLoadMetrics observers. All instances of this class are | 233 // Interface for PageLoadMetrics observers. All instances of this class are |
| 226 // owned by the PageLoadTracker tracking a page load. | 234 // owned by the PageLoadTracker tracking a page load. |
| 227 class PageLoadMetricsObserver { | 235 class PageLoadMetricsObserver { |
| 228 public: | 236 public: |
| 229 // ObservePolicy is used as a return value on some PageLoadMetricsObserver | 237 // ObservePolicy is used as a return value on some PageLoadMetricsObserver |
| 230 // callbacks to indicate whether the observer would like to continue observing | 238 // callbacks to indicate whether the observer would like to continue observing |
| 231 // metric callbacks. Observers that wish to continue observing metric | 239 // metric callbacks. Observers that wish to continue observing metric |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 256 content::NavigationHandle* navigation_handle); | 264 content::NavigationHandle* navigation_handle); |
| 257 | 265 |
| 258 // OnCommit is triggered when a page load commits, i.e. when we receive the | 266 // 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 | 267 // 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 | 268 // the navigation, but will be destroyed soon after this call. Don't hold a |
| 261 // reference to it. | 269 // reference to it. |
| 262 // Observers that return STOP_OBSERVING will not receive any additional | 270 // Observers that return STOP_OBSERVING will not receive any additional |
| 263 // callbacks, and will be deleted after invocation of this method returns. | 271 // callbacks, and will be deleted after invocation of this method returns. |
| 264 virtual ObservePolicy OnCommit(content::NavigationHandle* navigation_handle); | 272 virtual ObservePolicy OnCommit(content::NavigationHandle* navigation_handle); |
| 265 | 273 |
| 274 // OnDidFinishSubFrameNavigation is triggered when a sub-frame of the | |
| 275 // committed page has finished navigating. It has either committed, aborted, | |
| 276 // was a same document navigation, or has been replaced. It is up to the | |
| 277 // observer to query |navigation_handle| to determine which happened. Note | |
| 278 // that |navigation_handle| will be destroyed soon after this call. Don't | |
| 279 // hold a reference to it. | |
| 280 virtual ObservePolicy OnDidFinishSubFrameNavigation( | |
| 281 content::NavigationHandle* navigation_handle); | |
| 282 | |
| 266 // OnHidden is triggered when a page leaves the foreground. It does not fire | 283 // 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 | 284 // when a foreground page is permanently closed; for that, listen to |
| 268 // OnComplete instead. | 285 // OnComplete instead. |
| 269 virtual ObservePolicy OnHidden(const PageLoadTiming& timing, | 286 virtual ObservePolicy OnHidden(const PageLoadTiming& timing, |
| 270 const PageLoadExtraInfo& extra_info); | 287 const PageLoadExtraInfo& extra_info); |
| 271 | 288 |
| 272 // OnShown is triggered when a page is brought to the foreground. It does not | 289 // 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. | 290 // fire when the page first loads; for that, listen for OnStart instead. |
| 274 virtual ObservePolicy OnShown(); | 291 virtual ObservePolicy OnShown(); |
| 275 | 292 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 // frequently on Android). | 387 // frequently on Android). |
| 371 virtual void OnComplete(const PageLoadTiming& timing, | 388 virtual void OnComplete(const PageLoadTiming& timing, |
| 372 const PageLoadExtraInfo& extra_info) {} | 389 const PageLoadExtraInfo& extra_info) {} |
| 373 | 390 |
| 374 // OnFailedProvisionalLoad is invoked for tracked page loads that did not | 391 // OnFailedProvisionalLoad is invoked for tracked page loads that did not |
| 375 // commit, immediately before the observer is deleted. | 392 // commit, immediately before the observer is deleted. |
| 376 virtual void OnFailedProvisionalLoad( | 393 virtual void OnFailedProvisionalLoad( |
| 377 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 394 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
| 378 const PageLoadExtraInfo& extra_info) {} | 395 const PageLoadExtraInfo& extra_info) {} |
| 379 | 396 |
| 380 // Called whenever a request is loaded for this page load. | 397 // Called whenever a request is loaded for this page load. This comes |
| 398 // unfiltered from the ResourceDispatcherHost and may include blob requests | |
| 399 // and data uris. | |
| 381 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} | 400 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} |
| 382 }; | 401 }; |
| 383 | 402 |
| 384 } // namespace page_load_metrics | 403 } // namespace page_load_metrics |
| 385 | 404 |
| 386 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 405 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
| OLD | NEW |