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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/optional.h" | 9 #include "base/optional.h" |
10 #include "chrome/common/page_load_metrics/page_load_timing.h" | 10 #include "chrome/common/page_load_metrics/page_load_timing.h" |
11 #include "content/public/browser/navigation_handle.h" | 11 #include "content/public/browser/navigation_handle.h" |
12 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 12 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace page_load_metrics { | 15 namespace page_load_metrics { |
16 | 16 |
17 // This enum represents how a page load ends. If the action occurs before the | 17 // 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 | 18 // page load finishes (or reaches some point like first paint), then we consider |
19 // the load to be aborted. | 19 // the load to be aborted. |
20 enum UserAbortType { | 20 enum PageEndReason { |
21 // Represents no abort. | 21 // Page lifetime has not yet ended (page is still active). |
22 ABORT_NONE, | 22 END_NONE, |
23 | 23 |
24 // If the user presses reload or shift-reload. | 24 // The page was reloaded, possibly by the user. |
25 ABORT_RELOAD, | 25 END_RELOAD, |
26 | 26 |
27 // The user presses the back/forward button. | 27 // The page was navigated away from, via a back or forward navigation. |
28 ABORT_FORWARD_BACK, | 28 END_FORWARD_BACK, |
29 | 29 |
30 // The navigation is replaced with a navigation with the qualifier | 30 // The navigation is replaced with a navigation with the qualifier |
31 // ui::PAGE_TRANSITION_CLIENT_REDIRECT, which is caused by Javascript, or the | 31 // ui::PAGE_TRANSITION_CLIENT_REDIRECT, which is caused by Javascript, or the |
32 // meta refresh tag. | 32 // meta refresh tag. |
33 ABORT_CLIENT_REDIRECT, | 33 END_CLIENT_REDIRECT, |
34 | 34 |
35 // If the page load is replaced by a new navigation. This includes link | 35 // If the page load is replaced by a new navigation. This includes link |
36 // clicks, typing in the omnibox (not a reload), and form submissions. | 36 // clicks, typing in the omnibox (not a reload), and form submissions. |
37 ABORT_NEW_NAVIGATION, | 37 END_NEW_NAVIGATION, |
38 | 38 |
39 // If the user presses the stop X button. | 39 // The page load was stopped (e.g. the user presses the stop X button). |
40 ABORT_STOP, | 40 END_STOP, |
41 | 41 |
42 // If the page load is aborted by closing the tab or browser. | 42 // Page load ended due to closing the tab or browser. |
43 ABORT_CLOSE, | 43 END_CLOSE, |
44 | 44 |
45 // The page load was backgrounded, e.g. the browser was minimized or the user | 45 // The provisional load for this page load failed before committing. |
46 // switched tabs. Note that the same page may be foregrounded in the future, | 46 END_PROVISIONAL_LOAD_FAILED, |
47 // so this is not a 'terminal' abort type. | |
48 ABORT_BACKGROUND, | |
49 | 47 |
50 // We don't know why the page load aborted. This is the value we assign to an | 48 // The render process hosting the page terminated unexpectedly. |
51 // aborted load if the only signal we get is a provisional load finishing | 49 END_RENDER_PROCESS_GONE, |
| 50 |
| 51 // We don't know why the page load ended. This is the value we assign to a |
| 52 // terminated provisional load if the only signal we get is the load finished |
52 // without committing, either without error or with net::ERR_ABORTED. | 53 // without committing, either without error or with net::ERR_ABORTED. |
53 ABORT_OTHER, | 54 END_OTHER |
54 | |
55 // Add values before this final count. | |
56 ABORT_LAST_ENTRY | |
57 }; | 55 }; |
58 | 56 |
59 // Information related to failed provisional loads. | 57 // Information related to failed provisional loads. |
60 struct FailedProvisionalLoadInfo { | 58 struct FailedProvisionalLoadInfo { |
61 FailedProvisionalLoadInfo(base::TimeDelta interval, net::Error error); | 59 FailedProvisionalLoadInfo(base::TimeDelta interval, net::Error error); |
62 ~FailedProvisionalLoadInfo(); | 60 ~FailedProvisionalLoadInfo(); |
63 | 61 |
64 base::TimeDelta time_to_failed_provisional_load; | 62 base::TimeDelta time_to_failed_provisional_load; |
65 net::Error error; | 63 net::Error error; |
66 }; | 64 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 105 |
108 struct PageLoadExtraInfo { | 106 struct PageLoadExtraInfo { |
109 PageLoadExtraInfo( | 107 PageLoadExtraInfo( |
110 const base::Optional<base::TimeDelta>& first_background_time, | 108 const base::Optional<base::TimeDelta>& first_background_time, |
111 const base::Optional<base::TimeDelta>& first_foreground_time, | 109 const base::Optional<base::TimeDelta>& first_foreground_time, |
112 bool started_in_foreground, | 110 bool started_in_foreground, |
113 UserInitiatedInfo user_initiated_info, | 111 UserInitiatedInfo user_initiated_info, |
114 const GURL& url, | 112 const GURL& url, |
115 const GURL& start_url, | 113 const GURL& start_url, |
116 bool did_commit, | 114 bool did_commit, |
117 UserAbortType abort_type, | 115 PageEndReason page_end_reason, |
118 UserInitiatedInfo abort_user_initiated_info, | 116 UserInitiatedInfo page_end_user_initiated_info, |
119 const base::Optional<base::TimeDelta>& time_to_abort, | 117 const base::Optional<base::TimeDelta>& page_end_time, |
120 const PageLoadMetadata& metadata); | 118 const PageLoadMetadata& metadata); |
121 | 119 |
122 PageLoadExtraInfo(const PageLoadExtraInfo& other); | 120 PageLoadExtraInfo(const PageLoadExtraInfo& other); |
123 | 121 |
124 ~PageLoadExtraInfo(); | 122 ~PageLoadExtraInfo(); |
125 | 123 |
126 // The first time that the page was backgrounded since the navigation started. | 124 // The first time that the page was backgrounded since the navigation started. |
127 const base::Optional<base::TimeDelta> first_background_time; | 125 const base::Optional<base::TimeDelta> first_background_time; |
128 | 126 |
129 // The first time that the page was foregrounded since the navigation started. | 127 // The first time that the page was foregrounded since the navigation started. |
130 const base::Optional<base::TimeDelta> first_foreground_time; | 128 const base::Optional<base::TimeDelta> first_foreground_time; |
131 | 129 |
132 // True if the page load started in the foreground. | 130 // True if the page load started in the foreground. |
133 const bool started_in_foreground; | 131 const bool started_in_foreground; |
134 | 132 |
135 // Whether the page load was initiated by a user. | 133 // Whether the page load was initiated by a user. |
136 const UserInitiatedInfo user_initiated_info; | 134 const UserInitiatedInfo user_initiated_info; |
137 | 135 |
138 // Most recent URL for this page. Can be updated at navigation start, upon | 136 // Most recent URL for this page. Can be updated at navigation start, upon |
139 // redirection, and at commit time. | 137 // redirection, and at commit time. |
140 const GURL url; | 138 const GURL url; |
141 | 139 |
142 // The URL that started the navigation, before redirects. | 140 // The URL that started the navigation, before redirects. |
143 const GURL start_url; | 141 const GURL start_url; |
144 | 142 |
145 // Whether the navigation for this page load committed. | 143 // Whether the navigation for this page load committed. |
146 const bool did_commit; | 144 const bool did_commit; |
147 | 145 |
148 // The abort time and time to abort for this page load. If the page was not | 146 // The reason the page load ended. If the page is still active, |
149 // aborted, |abort_type| will be |ABORT_NONE|. | 147 // |page_end_reason| will be |END_NONE|. |page_end_time| contains the duration |
150 const UserAbortType abort_type; | 148 // of time until the cause of the page end reason was encountered. |
| 149 const PageEndReason page_end_reason; |
151 | 150 |
152 // Whether the abort for this page load was user initiated. For example, if | 151 // Whether the end reason for this page load was user initiated. For example, |
153 // this page load was aborted by a new navigation, this field tracks whether | 152 // if |
| 153 // this page load was ended due to a new navigation, this field tracks whether |
154 // that new navigation was user-initiated. This field is only useful if this | 154 // that new navigation was user-initiated. This field is only useful if this |
155 // page load's abort type is a value other than ABORT_NONE. Note that this | 155 // page load's end reason is a value other than END_NONE. Note that this |
156 // value is currently experimental, and is subject to change. In particular, | 156 // value is currently experimental, and is subject to change. In particular, |
157 // this field is not currently set for some abort types, such as stop and | 157 // this field is not currently set for some end reasons, such as stop and |
158 // close, since we don't yet have sufficient instrumentation to know if a stop | 158 // close, since we don't yet have sufficient instrumentation to know if a stop |
159 // or close was caused by a user action. | 159 // or close was caused by a user action. |
160 // | 160 // |
161 // TODO(csharrison): If more metadata for aborts is needed we should provide a | 161 // TODO(csharrison): If more metadata for end reasons is needed we should |
| 162 // provide a |
162 // better abstraction. Note that this is an approximation. | 163 // better abstraction. Note that this is an approximation. |
163 UserInitiatedInfo abort_user_initiated_info; | 164 UserInitiatedInfo page_end_user_initiated_info; |
164 | 165 |
165 const base::Optional<base::TimeDelta> time_to_abort; | 166 // Total lifetime of the page from the user standoint, starting at navigation |
| 167 // start. The page lifetime ends when the first of the following events |
| 168 // happen: |
| 169 // * the load of the main resource fails |
| 170 // * the page load is stopped |
| 171 // * the tab hosting the page is closed |
| 172 // * the render process hosting the page goes away |
| 173 // * a new navigation which later commits is initiated in the same tab |
| 174 // This field will not be set if the page is still active and hasn't yet |
| 175 // finished. |
| 176 const base::Optional<base::TimeDelta> page_end_time; |
166 | 177 |
167 // Extra information supplied to the page load metrics system from the | 178 // Extra information supplied to the page load metrics system from the |
168 // renderer. | 179 // renderer. |
169 const PageLoadMetadata metadata; | 180 const PageLoadMetadata metadata; |
170 }; | 181 }; |
171 | 182 |
172 // Container for various information about a request within a page load. | 183 // Container for various information about a request within a page load. |
173 struct ExtraRequestInfo { | 184 struct ExtraRequestInfo { |
174 ExtraRequestInfo(bool was_cached, | 185 ExtraRequestInfo(bool was_cached, |
175 int64_t raw_body_bytes, | 186 int64_t raw_body_bytes, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 341 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
331 const PageLoadExtraInfo& extra_info) {} | 342 const PageLoadExtraInfo& extra_info) {} |
332 | 343 |
333 // Called whenever a request is loaded for this page load. | 344 // Called whenever a request is loaded for this page load. |
334 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} | 345 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} |
335 }; | 346 }; |
336 | 347 |
337 } // namespace page_load_metrics | 348 } // namespace page_load_metrics |
338 | 349 |
339 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 350 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |