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 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(base::Optional<base::TimeDelta> first_background_time, |
|
Bryan McQuade
2016/03/29 18:33:43
given that base::Optional is bigger than a pointer
shivanisha
2016/03/29 18:54:24
Makes sense. will do
| |
| 55 base::TimeDelta first_foreground_time, | 56 base::Optional<base::TimeDelta> first_foreground_time, |
| 56 bool started_in_foreground, | 57 bool started_in_foreground, |
| 57 const GURL& committed_url, | 58 const GURL& committed_url, |
| 58 base::TimeDelta time_to_commit, | 59 base::Optional<base::TimeDelta> time_to_commit, |
| 59 UserAbortType abort_type, | 60 UserAbortType abort_type, |
| 60 base::TimeDelta time_to_abort); | 61 base::Optional<base::TimeDelta> time_to_abort); |
| 62 | |
| 63 ~PageLoadExtraInfo(); | |
| 61 | 64 |
| 62 // The first time that the page was backgrounded since the navigation started. | 65 // 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(). | 66 const base::Optional<base::TimeDelta> first_background_time; |
| 64 const base::TimeDelta first_background_time; | |
| 65 | 67 |
| 66 // The first time that the page was foregrounded since the navigation started. | 68 // 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(). | 69 const base::Optional<base::TimeDelta> first_foreground_time; |
| 68 const base::TimeDelta first_foreground_time; | |
| 69 | 70 |
| 70 // True if the page load started in the foreground. | 71 // True if the page load started in the foreground. |
| 71 const bool started_in_foreground; | 72 const bool started_in_foreground; |
| 72 | 73 |
| 73 // Committed URL. If the page load did not commit, |committed_url| will be | 74 // Committed URL. If the page load did not commit, |committed_url| will be |
| 74 // empty. | 75 // empty. |
| 75 const GURL committed_url; | 76 const GURL committed_url; |
| 76 | 77 |
| 77 // Time from navigation start until commit. If the page load did not commit, | 78 // Time from navigation start until commit. |
| 78 // |time_to_commit| will be zero. | 79 const base::Optional<base::TimeDelta> time_to_commit; |
| 79 const base::TimeDelta time_to_commit; | |
| 80 | 80 |
| 81 // The abort time and time to abort for this page load. If the page was not | 81 // 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 | 82 // aborted, |abort_type| will be |ABORT_NONE| |
| 83 // |base::TimeDelta()|. | |
| 84 const UserAbortType abort_type; | 83 const UserAbortType abort_type; |
| 85 const base::TimeDelta time_to_abort; | 84 const base::Optional<base::TimeDelta> time_to_abort; |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 // Interface for PageLoadMetrics observers. All instances of this class are | 87 // Interface for PageLoadMetrics observers. All instances of this class are |
| 89 // owned by the PageLoadTracker tracking a page load. They will be deleted after | 88 // owned by the PageLoadTracker tracking a page load. They will be deleted after |
| 90 // calling OnComplete. | 89 // calling OnComplete. |
| 91 class PageLoadMetricsObserver { | 90 class PageLoadMetricsObserver { |
| 92 public: | 91 public: |
| 93 virtual ~PageLoadMetricsObserver() {} | 92 virtual ~PageLoadMetricsObserver() {} |
| 94 | 93 |
| 95 // The page load started, with the given navigation handle. | 94 // 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 | 119 // data collected over the course of the page load. If the load did not |
| 121 // receive any timing information, |timing.IsEmpty()| will be true. | 120 // receive any timing information, |timing.IsEmpty()| will be true. |
| 122 // After this call, the object will be deleted. | 121 // After this call, the object will be deleted. |
| 123 virtual void OnComplete(const PageLoadTiming& timing, | 122 virtual void OnComplete(const PageLoadTiming& timing, |
| 124 const PageLoadExtraInfo& extra_info) {} | 123 const PageLoadExtraInfo& extra_info) {} |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 } // namespace page_load_metrics | 126 } // namespace page_load_metrics |
| 128 | 127 |
| 129 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ | 128 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ |
| OLD | NEW |