| 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 "components/page_load_metrics/common/page_load_timing.h" | 9 #include "components/page_load_metrics/common/page_load_timing.h" |
| 10 #include "content/public/browser/navigation_handle.h" | 10 #include "content/public/browser/navigation_handle.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 const PageLoadMetadata metadata; | 90 const PageLoadMetadata metadata; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 // Interface for PageLoadMetrics observers. All instances of this class are | 93 // Interface for PageLoadMetrics observers. All instances of this class are |
| 94 // owned by the PageLoadTracker tracking a page load. They will be deleted after | 94 // owned by the PageLoadTracker tracking a page load. They will be deleted after |
| 95 // calling OnComplete. | 95 // calling OnComplete. |
| 96 class PageLoadMetricsObserver { | 96 class PageLoadMetricsObserver { |
| 97 public: | 97 public: |
| 98 virtual ~PageLoadMetricsObserver() {} | 98 virtual ~PageLoadMetricsObserver() {} |
| 99 | 99 |
| 100 // The page load started, with the given navigation handle. | 100 // The page load started, with the given navigation handle. Note that OnStart |
| 101 virtual void OnStart(content::NavigationHandle* navigation_handle) {} | 101 // is called for same-page navigations. Implementers of OnStart that only want |
| 102 // to process non-same-page navigations should also check to see that the page |
| 103 // load committed via OnCommit or committed_url in |
| 104 // PageLoadExtraInfo. currently_committed_url contains the URL of the |
| 105 // committed page load at the time the navigation for navigation_handle was |
| 106 // initiated, or the empty URL if there was no committed page load at the time |
| 107 // the navigation was initiated. |
| 108 virtual void OnStart(content::NavigationHandle* navigation_handle, |
| 109 const GURL& currently_committed_url) {} |
| 102 | 110 |
| 103 // OnRedirect is triggered when a page load redirects to another URL. | 111 // OnRedirect is triggered when a page load redirects to another URL. |
| 104 // The navigation handle holds relevant data for the navigation, but will | 112 // The navigation handle holds relevant data for the navigation, but will |
| 105 // be destroyed soon after this call. Don't hold a reference to it. This can | 113 // be destroyed soon after this call. Don't hold a reference to it. This can |
| 106 // be called multiple times. | 114 // be called multiple times. |
| 107 virtual void OnRedirect(content::NavigationHandle* navigation_handle) {} | 115 virtual void OnRedirect(content::NavigationHandle* navigation_handle) {} |
| 108 | 116 |
| 109 // OnCommit is triggered when a page load commits, i.e. when we receive the | 117 // OnCommit is triggered when a page load commits, i.e. when we receive the |
| 110 // first data for the request. The navigation handle holds relevant data for | 118 // first data for the request. The navigation handle holds relevant data for |
| 111 // the navigation, but will be destroyed soon after this call. Don't hold a | 119 // the navigation, but will be destroyed soon after this call. Don't hold a |
| (...skipping 13 matching lines...) Expand all Loading... |
| 125 // data collected over the course of the page load. If the load did not | 133 // data collected over the course of the page load. If the load did not |
| 126 // receive any timing information, |timing.IsEmpty()| will be true. | 134 // receive any timing information, |timing.IsEmpty()| will be true. |
| 127 // After this call, the object will be deleted. | 135 // After this call, the object will be deleted. |
| 128 virtual void OnComplete(const PageLoadTiming& timing, | 136 virtual void OnComplete(const PageLoadTiming& timing, |
| 129 const PageLoadExtraInfo& extra_info) {} | 137 const PageLoadExtraInfo& extra_info) {} |
| 130 }; | 138 }; |
| 131 | 139 |
| 132 } // namespace page_load_metrics | 140 } // namespace page_load_metrics |
| 133 | 141 |
| 134 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ | 142 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ |
| OLD | NEW |