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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Information related to failed provisional loads. | 59 // Information related to failed provisional loads. |
60 struct FailedProvisionalLoadInfo { | 60 struct FailedProvisionalLoadInfo { |
61 FailedProvisionalLoadInfo(base::TimeDelta interval, net::Error error); | 61 FailedProvisionalLoadInfo(base::TimeDelta interval, net::Error error); |
62 ~FailedProvisionalLoadInfo(); | 62 ~FailedProvisionalLoadInfo(); |
63 | 63 |
64 base::TimeDelta time_to_failed_provisional_load; | 64 base::TimeDelta time_to_failed_provisional_load; |
65 net::Error error; | 65 net::Error error; |
66 }; | 66 }; |
67 | 67 |
| 68 // Information related to whether an associated action, such as a navigation or |
| 69 // an abort, was initiated by a user. Clicking a link or tapping on a UI |
| 70 // element are examples of user initiation actions. |
| 71 struct UserInitiatedInfo { |
| 72 static UserInitiatedInfo NotUserInitiated() { |
| 73 return UserInitiatedInfo(false, false, false); |
| 74 } |
| 75 |
| 76 static UserInitiatedInfo BrowserInitiated() { |
| 77 return UserInitiatedInfo(true, false, false); |
| 78 } |
| 79 |
| 80 static UserInitiatedInfo RenderInitiated(bool user_gesture, |
| 81 bool user_input_event) { |
| 82 return UserInitiatedInfo(false, user_gesture, user_input_event); |
| 83 } |
| 84 |
| 85 // Whether the associated action was initiated from the browser process, as |
| 86 // opposed to from the render process. We generally assume that all actions |
| 87 // initiated from the browser process are user initiated. |
| 88 bool browser_initiated; |
| 89 |
| 90 // Whether the associated action was initiated by a user, according to user |
| 91 // gesture tracking in content and Blink, as reported by NavigationHandle. |
| 92 bool user_gesture; |
| 93 |
| 94 // Whether the associated action was initiated by a user, based on our |
| 95 // heuristic-driven implementation that tests to see if there was an input |
| 96 // event that happened shortly before the given action. |
| 97 bool user_input_event; |
| 98 |
| 99 private: |
| 100 UserInitiatedInfo(bool browser_initiated, |
| 101 bool user_gesture, |
| 102 bool user_input_event) |
| 103 : browser_initiated(browser_initiated), |
| 104 user_gesture(user_gesture), |
| 105 user_input_event(user_input_event) {} |
| 106 }; |
| 107 |
68 struct PageLoadExtraInfo { | 108 struct PageLoadExtraInfo { |
69 PageLoadExtraInfo( | 109 PageLoadExtraInfo( |
70 const base::Optional<base::TimeDelta>& first_background_time, | 110 const base::Optional<base::TimeDelta>& first_background_time, |
71 const base::Optional<base::TimeDelta>& first_foreground_time, | 111 const base::Optional<base::TimeDelta>& first_foreground_time, |
72 bool started_in_foreground, | 112 bool started_in_foreground, |
73 bool user_initiated, | 113 UserInitiatedInfo user_initiated_info, |
74 const GURL& committed_url, | 114 const GURL& committed_url, |
75 const GURL& start_url, | 115 const GURL& start_url, |
76 UserAbortType abort_type, | 116 UserAbortType abort_type, |
77 bool abort_user_initiated, | 117 UserInitiatedInfo abort_user_initiated_info, |
78 const base::Optional<base::TimeDelta>& time_to_abort, | 118 const base::Optional<base::TimeDelta>& time_to_abort, |
79 int num_cache_requests, | 119 int num_cache_requests, |
80 int num_network_requests, | 120 int num_network_requests, |
81 const PageLoadMetadata& metadata); | 121 const PageLoadMetadata& metadata); |
82 | 122 |
83 PageLoadExtraInfo(const PageLoadExtraInfo& other); | 123 PageLoadExtraInfo(const PageLoadExtraInfo& other); |
84 | 124 |
85 ~PageLoadExtraInfo(); | 125 ~PageLoadExtraInfo(); |
86 | 126 |
87 // The first time that the page was backgrounded since the navigation started. | 127 // The first time that the page was backgrounded since the navigation started. |
88 const base::Optional<base::TimeDelta> first_background_time; | 128 const base::Optional<base::TimeDelta> first_background_time; |
89 | 129 |
90 // The first time that the page was foregrounded since the navigation started. | 130 // The first time that the page was foregrounded since the navigation started. |
91 const base::Optional<base::TimeDelta> first_foreground_time; | 131 const base::Optional<base::TimeDelta> first_foreground_time; |
92 | 132 |
93 // True if the page load started in the foreground. | 133 // True if the page load started in the foreground. |
94 const bool started_in_foreground; | 134 const bool started_in_foreground; |
95 | 135 |
96 // True if this is either a browser initiated navigation or the user_gesture | 136 // Whether the page load was initiated by a user. |
97 // bit is true in the renderer. | 137 const UserInitiatedInfo user_initiated_info; |
98 const bool user_initiated; | |
99 | 138 |
100 // Committed URL. If the page load did not commit, |committed_url| will be | 139 // Committed URL. If the page load did not commit, |committed_url| will be |
101 // empty. | 140 // empty. |
102 const GURL committed_url; | 141 const GURL committed_url; |
103 | 142 |
104 // The URL that started the navigation, before redirects. | 143 // The URL that started the navigation, before redirects. |
105 const GURL start_url; | 144 const GURL start_url; |
106 | 145 |
107 // The abort time and time to abort for this page load. If the page was not | 146 // The abort time and time to abort for this page load. If the page was not |
108 // aborted, |abort_type| will be |ABORT_NONE|. | 147 // aborted, |abort_type| will be |ABORT_NONE|. |
109 const UserAbortType abort_type; | 148 const UserAbortType abort_type; |
110 | 149 |
111 // Whether the abort for this page load was user initiated. For example, if | 150 // Whether the abort for this page load was user initiated. For example, if |
112 // this page load was aborted by a new navigation, this field tracks whether | 151 // this page load was aborted by a new navigation, this field tracks whether |
113 // that new navigation was user-initiated. This field is only useful if this | 152 // that new navigation was user-initiated. This field is only useful if this |
114 // page load's abort type is a value other than ABORT_NONE. Note that this | 153 // page load's abort type is a value other than ABORT_NONE. Note that this |
115 // value is currently experimental, and is subject to change. In particular, | 154 // value is currently experimental, and is subject to change. In particular, |
116 // this field is never set to true for some abort types, such as stop and | 155 // this field is not currently set for some abort types, such as stop and |
117 // close, since we don't yet have sufficient instrumentation to know if a stop | 156 // close, since we don't yet have sufficient instrumentation to know if a stop |
118 // or close was caused by a user action. | 157 // or close was caused by a user action. |
119 // | 158 // |
120 // TODO(csharrison): If more metadata for aborts is needed we should provide a | 159 // TODO(csharrison): If more metadata for aborts is needed we should provide a |
121 // better abstraction. Note that this is an approximation. | 160 // better abstraction. Note that this is an approximation. |
122 bool abort_user_initiated; | 161 UserInitiatedInfo abort_user_initiated_info; |
123 | 162 |
124 const base::Optional<base::TimeDelta> time_to_abort; | 163 const base::Optional<base::TimeDelta> time_to_abort; |
125 | 164 |
126 // Note: these are only approximations, based on WebContents attribution from | 165 // Note: these are only approximations, based on WebContents attribution from |
127 // ResourceRequestInfo objects while this is the currently committed load in | 166 // ResourceRequestInfo objects while this is the currently committed load in |
128 // the WebContents. | 167 // the WebContents. |
129 int num_cache_requests; | 168 int num_cache_requests; |
130 int num_network_requests; | 169 int num_network_requests; |
131 | 170 |
132 // Extra information supplied to the page load metrics system from the | 171 // Extra information supplied to the page load metrics system from the |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // OnFailedProvisionalLoad is invoked for tracked page loads that did not | 305 // OnFailedProvisionalLoad is invoked for tracked page loads that did not |
267 // commit, immediately before the observer is deleted. | 306 // commit, immediately before the observer is deleted. |
268 virtual void OnFailedProvisionalLoad( | 307 virtual void OnFailedProvisionalLoad( |
269 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 308 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
270 const PageLoadExtraInfo& extra_info) {} | 309 const PageLoadExtraInfo& extra_info) {} |
271 }; | 310 }; |
272 | 311 |
273 } // namespace page_load_metrics | 312 } // namespace page_load_metrics |
274 | 313 |
275 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 314 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |