| 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 "components/page_load_metrics/common/page_load_timing.h" | 10 #include "components/page_load_metrics/common/page_load_timing.h" |
| 10 #include "content/public/browser/navigation_handle.h" | 11 #include "content/public/browser/navigation_handle.h" |
| 11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 12 | 13 |
| 13 namespace page_load_metrics { | 14 namespace page_load_metrics { |
| 14 | 15 |
| 15 class PageLoadMetricsObservable; | 16 class PageLoadMetricsObservable; |
| 16 | 17 |
| 17 // This enum represents how a page load ends. If the action occurs before the | 18 // This enum represents how a page load ends. If the action occurs before the |
| 18 // page load finishes (or reaches some point like first paint), then we consider | 19 // page load finishes (or reaches some point like first paint), then we consider |
| (...skipping 25 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 // The load aborted due to another navigation, but it isn't clear what type of | 46 // The load aborted due to another navigation, but it isn't clear what type of |
| 46 // navigation it was. | 47 // navigation it was. |
| 47 ABORT_UNKNOWN_NAVIGATION, | 48 ABORT_UNKNOWN_NAVIGATION, |
| 48 | 49 |
| 49 // Add values before this final count. | 50 // Add values before this final count. |
| 50 ABORT_LAST_ENTRY | 51 ABORT_LAST_ENTRY |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 struct PageLoadExtraInfo { | 54 struct PageLoadExtraInfo { |
| 54 PageLoadExtraInfo(base::TimeDelta first_background_time, | 55 PageLoadExtraInfo( |
| 55 base::TimeDelta first_foreground_time, | 56 const base::Optional<base::TimeDelta>& first_background_time, |
| 56 bool started_in_foreground, | 57 const base::Optional<base::TimeDelta>& first_foreground_time, |
| 57 const GURL& committed_url, | 58 bool started_in_foreground, |
| 58 base::TimeDelta time_to_commit, | 59 const GURL& committed_url, |
| 59 UserAbortType abort_type, | 60 const base::Optional<base::TimeDelta>& time_to_commit, |
| 60 base::TimeDelta time_to_abort); | 61 UserAbortType abort_type, |
| 62 const base::Optional<base::TimeDelta>& time_to_abort); |
| 63 |
| 64 ~PageLoadExtraInfo(); |
| 61 | 65 |
| 62 // The first time that the page was backgrounded since the navigation started. | 66 // The first time that the page was backgrounded since the navigation started. |
| 63 // If the page has not been backgrounded this will be base::TimeDelta(). | 67 const base::Optional<base::TimeDelta> first_background_time; |
| 64 const base::TimeDelta first_background_time; | |
| 65 | 68 |
| 66 // The first time that the page was foregrounded since the navigation started. | 69 // The first time that the page was foregrounded since the navigation started. |
| 67 // If the page has not been foregrounded this will be base::TimeDelta(). | 70 const base::Optional<base::TimeDelta> first_foreground_time; |
| 68 const base::TimeDelta first_foreground_time; | |
| 69 | 71 |
| 70 // True if the page load started in the foreground. | 72 // True if the page load started in the foreground. |
| 71 const bool started_in_foreground; | 73 const bool started_in_foreground; |
| 72 | 74 |
| 73 // Committed URL. If the page load did not commit, |committed_url| will be | 75 // Committed URL. If the page load did not commit, |committed_url| will be |
| 74 // empty. | 76 // empty. |
| 75 const GURL committed_url; | 77 const GURL committed_url; |
| 76 | 78 |
| 77 // Time from navigation start until commit. If the page load did not commit, | 79 // Time from navigation start until commit. |
| 78 // |time_to_commit| will be zero. | 80 const base::Optional<base::TimeDelta> time_to_commit; |
| 79 const base::TimeDelta time_to_commit; | |
| 80 | 81 |
| 81 // The abort time and time to abort for this page load. If the page was not | 82 // The abort time and time to abort for this page load. If the page was not |
| 82 // aborted, |abort_type| will be |ABORT_NONE| and |time_to_abort| will be | 83 // aborted, |abort_type| will be |ABORT_NONE| |
| 83 // |base::TimeDelta()|. | |
| 84 const UserAbortType abort_type; | 84 const UserAbortType abort_type; |
| 85 const base::TimeDelta time_to_abort; | 85 const base::Optional<base::TimeDelta> time_to_abort; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // Interface for PageLoadMetrics observers. All instances of this class are | 88 // Interface for PageLoadMetrics observers. All instances of this class are |
| 89 // owned by the PageLoadTracker tracking a page load. They will be deleted after | 89 // owned by the PageLoadTracker tracking a page load. They will be deleted after |
| 90 // calling OnComplete. | 90 // calling OnComplete. |
| 91 class PageLoadMetricsObserver { | 91 class PageLoadMetricsObserver { |
| 92 public: | 92 public: |
| 93 virtual ~PageLoadMetricsObserver() {} | 93 virtual ~PageLoadMetricsObserver() {} |
| 94 | 94 |
| 95 // The page load started, with the given navigation handle. | 95 // The page load started, with the given navigation handle. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 120 // data collected over the course of the page load. If the load did not | 120 // data collected over the course of the page load. If the load did not |
| 121 // receive any timing information, |timing.IsEmpty()| will be true. | 121 // receive any timing information, |timing.IsEmpty()| will be true. |
| 122 // After this call, the object will be deleted. | 122 // After this call, the object will be deleted. |
| 123 virtual void OnComplete(const PageLoadTiming& timing, | 123 virtual void OnComplete(const PageLoadTiming& timing, |
| 124 const PageLoadExtraInfo& extra_info) {} | 124 const PageLoadExtraInfo& extra_info) {} |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 } // namespace page_load_metrics | 127 } // namespace page_load_metrics |
| 128 | 128 |
| 129 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ | 129 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ |
| OLD | NEW |