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" |
11 | 11 |
12 namespace page_load_metrics { | 12 namespace page_load_metrics { |
13 | 13 |
| 14 class PageLoadMetricsObservable; |
| 15 |
| 16 // This enum represents how a page load ends. If the action occurs before the |
| 17 // page load finishes (or reaches some point like first paint), then we consider |
| 18 // the load to be aborted. |
| 19 enum UserAbortType { |
| 20 // Represents no abort. |
| 21 ABORT_NONE, |
| 22 |
| 23 // If the user presses reload or shift-reload. |
| 24 ABORT_RELOAD, |
| 25 |
| 26 // The user presses the back/forward button. |
| 27 ABORT_FORWARD_BACK, |
| 28 |
| 29 // If the navigation is replaced by a new navigation. This includes link |
| 30 // clicks, typing in the omnibox (not a reload), and form submissions. |
| 31 ABORT_NEW_NAVIGATION, |
| 32 |
| 33 // If the user presses the stop X button. |
| 34 ABORT_STOP, |
| 35 |
| 36 // If the navigation is aborted by closing the tab or browser. |
| 37 ABORT_CLOSE, |
| 38 |
| 39 // We don't know why the navigation aborted. This is the value we assign to an |
| 40 // aborted load if the only signal we get is a provisional load finishing |
| 41 // without committing, either without error or with net::ERR_ABORTED. |
| 42 ABORT_OTHER, |
| 43 |
| 44 // Add values before this final count. |
| 45 ABORT_LAST_ENTRY |
| 46 }; |
| 47 |
14 struct PageLoadExtraInfo { | 48 struct PageLoadExtraInfo { |
15 PageLoadExtraInfo(const base::TimeDelta& first_background_time, | 49 PageLoadExtraInfo(const base::TimeDelta& first_background_time, |
16 const base::TimeDelta& first_foreground_time, | 50 const base::TimeDelta& first_foreground_time, |
17 bool started_in_foreground, | 51 bool started_in_foreground, |
18 bool has_commit); | 52 bool has_commit, |
| 53 UserAbortType abort_type, |
| 54 const base::TimeDelta& time_to_abort); |
19 | 55 |
20 // Returns the time to first background if the page load started in the | 56 // Returns the time to first background if the page load started in the |
21 // foreground. If the page has not been backgrounded, or the page started in | 57 // foreground. If the page has not been backgrounded, or the page started in |
22 // the background, this will be base::TimeDelta(). | 58 // the background, this will be base::TimeDelta(). |
23 const base::TimeDelta first_background_time; | 59 const base::TimeDelta first_background_time; |
24 | 60 |
25 // Returns the time to first foreground if the page load started in the | 61 // Returns the time to first foreground if the page load started in the |
26 // background. If the page has not been foregrounded, or the page started in | 62 // background. If the page has not been foregrounded, or the page started in |
27 // the foreground, this will be base::TimeDelta(). | 63 // the foreground, this will be base::TimeDelta(). |
28 const base::TimeDelta first_foreground_time; | 64 const base::TimeDelta first_foreground_time; |
29 | 65 |
30 // True if the page load started in the foreground. | 66 // True if the page load started in the foreground. |
31 const bool started_in_foreground; | 67 const bool started_in_foreground; |
32 | 68 |
33 // True if the page load committed and received its first bytes of data. | 69 // True if the page load committed and received its first bytes of data. |
34 const bool has_commit; | 70 const bool has_commit; |
| 71 |
| 72 // The abort time and time to abort for this page load. If the page was not |
| 73 // aborted, |abort_type| will be |ABORT_NONE| and |time_to_abort| will be |
| 74 // |base::TimeDelta()|. |
| 75 const UserAbortType abort_type; |
| 76 const base::TimeDelta time_to_abort; |
35 }; | 77 }; |
36 | 78 |
37 // Interface for PageLoadMetrics observers. All instances of this class are | 79 // Interface for PageLoadMetrics observers. All instances of this class are |
38 // owned by the PageLoadTracker tracking a page load. They will be deleted after | 80 // owned by the PageLoadTracker tracking a page load. They will be deleted after |
39 // calling OnComplete. | 81 // calling OnComplete. |
40 class PageLoadMetricsObserver { | 82 class PageLoadMetricsObserver { |
41 public: | 83 public: |
42 virtual ~PageLoadMetricsObserver() {} | 84 virtual ~PageLoadMetricsObserver() {} |
43 | 85 |
44 // The page load started, with the given navigation handle. | 86 // The page load started, with the given navigation handle. |
(...skipping 17 matching lines...) Expand all Loading... |
62 // data collected over the course of the page load. If the load did not | 104 // data collected over the course of the page load. If the load did not |
63 // receive any timing information, |timing.IsEmpty()| will be true. | 105 // receive any timing information, |timing.IsEmpty()| will be true. |
64 // After this call, the object will be deleted. | 106 // After this call, the object will be deleted. |
65 virtual void OnComplete(const PageLoadTiming& timing, | 107 virtual void OnComplete(const PageLoadTiming& timing, |
66 const PageLoadExtraInfo& extra_info) {} | 108 const PageLoadExtraInfo& extra_info) {} |
67 }; | 109 }; |
68 | 110 |
69 } // namespace page_load_metrics | 111 } // namespace page_load_metrics |
70 | 112 |
71 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ | 113 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |