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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/optional.h" | 11 #include "base/optional.h" |
12 #include "chrome/common/page_load_metrics/page_load_timing.h" | 12 #include "chrome/common/page_load_metrics/page_load_timing.h" |
13 #include "content/public/browser/navigation_handle.h" | 13 #include "content/public/browser/navigation_handle.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 #include "content/public/common/resource_type.h" | |
15 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 16 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace page_load_metrics { | 19 namespace page_load_metrics { |
19 | 20 |
20 // This enum represents how a page load ends. If the action occurs before the | 21 // This enum represents how a page load ends. If the action occurs before the |
21 // page load finishes (or reaches some point like first paint), then we consider | 22 // page load finishes (or reaches some point like first paint), then we consider |
22 // the load to be aborted. | 23 // the load to be aborted. |
23 enum PageEndReason { | 24 enum PageEndReason { |
24 // Page lifetime has not yet ended (page is still active). | 25 // Page lifetime has not yet ended (page is still active). |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 // Extra information supplied to the page load metrics system from the | 191 // Extra information supplied to the page load metrics system from the |
191 // renderer for the main frame. | 192 // renderer for the main frame. |
192 const PageLoadMetadata main_frame_metadata; | 193 const PageLoadMetadata main_frame_metadata; |
193 | 194 |
194 // PageLoadMetadata for child frames of the current page load. | 195 // PageLoadMetadata for child frames of the current page load. |
195 const PageLoadMetadata child_frame_metadata; | 196 const PageLoadMetadata child_frame_metadata; |
196 }; | 197 }; |
197 | 198 |
198 // Container for various information about a request within a page load. | 199 // Container for various information about a request within a page load. |
199 struct ExtraRequestInfo { | 200 struct ExtraRequestInfo { |
200 ExtraRequestInfo(bool was_cached, | 201 ExtraRequestInfo(const GURL& url, |
202 int frame_tree_node_id, | |
203 bool was_cached, | |
201 int64_t raw_body_bytes, | 204 int64_t raw_body_bytes, |
202 bool data_reduction_proxy_used, | 205 bool data_reduction_proxy_used, |
203 int64_t original_network_content_length); | 206 int64_t original_network_content_length); |
204 | 207 |
205 ExtraRequestInfo(const ExtraRequestInfo& other); | 208 ExtraRequestInfo(const ExtraRequestInfo& other); |
206 | 209 |
207 ~ExtraRequestInfo(); | 210 ~ExtraRequestInfo(); |
208 | 211 |
212 // The URL for the request. | |
213 GURL url; | |
214 | |
215 // The frame tree node id that initiated the request. | |
216 int frame_tree_node_id; | |
217 | |
209 // True if the resource was loaded from cache. | 218 // True if the resource was loaded from cache. |
210 const bool was_cached; | 219 const bool was_cached; |
211 | 220 |
212 // The number of body (not header) prefilter bytes. | 221 // The number of body (not header) prefilter bytes. |
213 const int64_t raw_body_bytes; | 222 const int64_t raw_body_bytes; |
214 | 223 |
215 // Whether this request used Data Reduction Proxy. | 224 // Whether this request used Data Reduction Proxy. |
216 const bool data_reduction_proxy_used; | 225 const bool data_reduction_proxy_used; |
217 | 226 |
218 // The number of body (not header) bytes that the data reduction proxy saw | 227 // The number of body (not header) bytes that the data reduction proxy saw |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 content::NavigationHandle* navigation_handle); | 263 content::NavigationHandle* navigation_handle); |
255 | 264 |
256 // OnCommit is triggered when a page load commits, i.e. when we receive the | 265 // OnCommit is triggered when a page load commits, i.e. when we receive the |
257 // first data for the request. The navigation handle holds relevant data for | 266 // first data for the request. The navigation handle holds relevant data for |
258 // the navigation, but will be destroyed soon after this call. Don't hold a | 267 // the navigation, but will be destroyed soon after this call. Don't hold a |
259 // reference to it. | 268 // reference to it. |
260 // Observers that return STOP_OBSERVING will not receive any additional | 269 // Observers that return STOP_OBSERVING will not receive any additional |
261 // callbacks, and will be deleted after invocation of this method returns. | 270 // callbacks, and will be deleted after invocation of this method returns. |
262 virtual ObservePolicy OnCommit(content::NavigationHandle* navigation_handle); | 271 virtual ObservePolicy OnCommit(content::NavigationHandle* navigation_handle); |
263 | 272 |
273 // OnCommitSubFrame is triggered when the a sub-frame of the committed page | |
274 // is committed. The navigation handle holds relevant data for the | |
275 // navigation, but will be destroyed soon after this call. Don't hold a | |
276 // reference to it. | |
277 // Unlike the main frame, OnCommitSubFrame does not filter by | |
278 // PageTrackDecider::ShouldTrack. This means that data URIs, network error | |
279 // pages, and non-html documents will result in OnCommitSubFrame being | |
280 // called. | |
281 virtual ObservePolicy OnCommitSubFrame( | |
Bryan McQuade
2017/04/13 19:21:27
i dont see a strong reason that observers might wa
Bryan McQuade
2017/04/14 19:19:23
looks like this comment might've gotten lost (or i
jkarlin
2017/04/24 17:27:58
Sorry, I did miss it. Thanks for pointing it out a
| |
282 content::NavigationHandle* navigation_handle); | |
283 | |
264 // OnHidden is triggered when a page leaves the foreground. It does not fire | 284 // OnHidden is triggered when a page leaves the foreground. It does not fire |
265 // when a foreground page is permanently closed; for that, listen to | 285 // when a foreground page is permanently closed; for that, listen to |
266 // OnComplete instead. | 286 // OnComplete instead. |
267 virtual ObservePolicy OnHidden(const PageLoadTiming& timing, | 287 virtual ObservePolicy OnHidden(const PageLoadTiming& timing, |
268 const PageLoadExtraInfo& extra_info); | 288 const PageLoadExtraInfo& extra_info); |
269 | 289 |
270 // OnShown is triggered when a page is brought to the foreground. It does not | 290 // OnShown is triggered when a page is brought to the foreground. It does not |
271 // fire when the page first loads; for that, listen for OnStart instead. | 291 // fire when the page first loads; for that, listen for OnStart instead. |
272 virtual ObservePolicy OnShown(); | 292 virtual ObservePolicy OnShown(); |
273 | 293 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 const FailedProvisionalLoadInfo& failed_provisional_load_info, | 389 const FailedProvisionalLoadInfo& failed_provisional_load_info, |
370 const PageLoadExtraInfo& extra_info) {} | 390 const PageLoadExtraInfo& extra_info) {} |
371 | 391 |
372 // Called whenever a request is loaded for this page load. | 392 // Called whenever a request is loaded for this page load. |
373 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} | 393 virtual void OnLoadedResource(const ExtraRequestInfo& extra_request_info) {} |
374 }; | 394 }; |
375 | 395 |
376 } // namespace page_load_metrics | 396 } // namespace page_load_metrics |
377 | 397 |
378 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ | 398 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_OBSERVER_H_ |
OLD | NEW |