Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/optional.h" | |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" | 14 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
| 14 #include "chrome/browser/page_load_metrics/user_input_tracker.h" | 15 #include "chrome/browser/page_load_metrics/user_input_tracker.h" |
| 15 #include "chrome/common/page_load_metrics/page_load_timing.h" | 16 #include "chrome/common/page_load_metrics/page_load_timing.h" |
| 17 #include "content/public/browser/global_request_id.h" | |
| 16 #include "ui/base/page_transition_types.h" | 18 #include "ui/base/page_transition_types.h" |
| 17 | 19 |
| 18 class GURL; | 20 class GURL; |
| 19 | 21 |
| 20 namespace blink { | 22 namespace blink { |
| 21 class WebInputEvent; | 23 class WebInputEvent; |
| 22 } // namespace blink | 24 } // namespace blink |
| 23 | 25 |
| 24 namespace content { | 26 namespace content { |
| 25 class NavigationHandle; | 27 class NavigationHandle; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 // the constructor. | 128 // the constructor. |
| 127 PageLoadTracker(bool in_foreground, | 129 PageLoadTracker(bool in_foreground, |
| 128 PageLoadMetricsEmbedderInterface* embedder_interface, | 130 PageLoadMetricsEmbedderInterface* embedder_interface, |
| 129 const GURL& currently_committed_url, | 131 const GURL& currently_committed_url, |
| 130 content::NavigationHandle* navigation_handle, | 132 content::NavigationHandle* navigation_handle, |
| 131 UserInitiatedInfo user_initiated_info, | 133 UserInitiatedInfo user_initiated_info, |
| 132 int aborted_chain_size, | 134 int aborted_chain_size, |
| 133 int aborted_chain_size_same_url); | 135 int aborted_chain_size_same_url); |
| 134 ~PageLoadTracker(); | 136 ~PageLoadTracker(); |
| 135 void Redirect(content::NavigationHandle* navigation_handle); | 137 void Redirect(content::NavigationHandle* navigation_handle); |
| 138 void WillProcessNavigationResponse( | |
| 139 content::NavigationHandle* navigation_handle); | |
| 136 void Commit(content::NavigationHandle* navigation_handle); | 140 void Commit(content::NavigationHandle* navigation_handle); |
| 137 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); | 141 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); |
| 138 void WebContentsHidden(); | 142 void WebContentsHidden(); |
| 139 void WebContentsShown(); | 143 void WebContentsShown(); |
| 140 | 144 |
| 141 void OnInputEvent(const blink::WebInputEvent& event); | 145 void OnInputEvent(const blink::WebInputEvent& event); |
| 142 | 146 |
| 143 // Flush any buffered metrics, as part of the metrics subsystem persisting | 147 // Flush any buffered metrics, as part of the metrics subsystem persisting |
| 144 // metrics as the application goes into the background. The application may be | 148 // metrics as the application goes into the background. The application may be |
| 145 // killed at any time after this method is invoked without further | 149 // killed at any time after this method is invoked without further |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 base::TimeTicks navigation_start() const { return navigation_start_; } | 207 base::TimeTicks navigation_start() const { return navigation_start_; } |
| 204 | 208 |
| 205 PageLoadExtraInfo ComputePageLoadExtraInfo(); | 209 PageLoadExtraInfo ComputePageLoadExtraInfo(); |
| 206 | 210 |
| 207 ui::PageTransition page_transition() const { return page_transition_; } | 211 ui::PageTransition page_transition() const { return page_transition_; } |
| 208 | 212 |
| 209 UserInitiatedInfo user_initiated_info() const { return user_initiated_info_; } | 213 UserInitiatedInfo user_initiated_info() const { return user_initiated_info_; } |
| 210 | 214 |
| 211 UserInputTracker* input_tracker() { return &input_tracker_; } | 215 UserInputTracker* input_tracker() { return &input_tracker_; } |
| 212 | 216 |
| 217 // Whether this PageLoadTracker has a navigation GlobalRequestID that matches | |
| 218 // the given request_id. This method will return false before ReadyToCommit | |
|
RyanSturm
2017/01/17 17:54:37
nit: s/ReadyToCommit/WillProcessResponse/ twice in
Bryan McQuade
2017/01/17 19:18:12
Thanks! Fixed.
| |
| 219 // has been invoked, as PageLoadTracker doesn't know its GlobalRequestID until | |
| 220 // ReadyToCommit has been invoked. | |
| 221 bool HasMatchingNavigationRequestID( | |
| 222 const content::GlobalRequestID& request_id) const; | |
| 223 | |
| 213 private: | 224 private: |
| 214 // This function converts a TimeTicks value taken in the browser process | 225 // This function converts a TimeTicks value taken in the browser process |
| 215 // to navigation_start_ if: | 226 // to navigation_start_ if: |
| 216 // - base::TimeTicks is not comparable across processes because the clock | 227 // - base::TimeTicks is not comparable across processes because the clock |
| 217 // is not system wide monotonic. | 228 // is not system wide monotonic. |
| 218 // - *event_time < navigation_start_ | 229 // - *event_time < navigation_start_ |
| 219 void ClampBrowserTimestampIfInterProcessTimeTickSkew( | 230 void ClampBrowserTimestampIfInterProcessTimeTickSkew( |
| 220 base::TimeTicks* event_time); | 231 base::TimeTicks* event_time); |
| 221 | 232 |
| 222 void UpdateAbortInternal(UserAbortType abort_type, | 233 void UpdateAbortInternal(UserAbortType abort_type, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 // when they occur in the background. | 283 // when they occur in the background. |
| 273 base::TimeTicks background_time_; | 284 base::TimeTicks background_time_; |
| 274 base::TimeTicks foreground_time_; | 285 base::TimeTicks foreground_time_; |
| 275 bool started_in_foreground_; | 286 bool started_in_foreground_; |
| 276 | 287 |
| 277 PageLoadTiming timing_; | 288 PageLoadTiming timing_; |
| 278 PageLoadMetadata metadata_; | 289 PageLoadMetadata metadata_; |
| 279 | 290 |
| 280 ui::PageTransition page_transition_; | 291 ui::PageTransition page_transition_; |
| 281 | 292 |
| 293 base::Optional<content::GlobalRequestID> navigation_request_id_; | |
| 294 | |
| 282 // Whether this page load was user initiated. | 295 // Whether this page load was user initiated. |
| 283 UserInitiatedInfo user_initiated_info_; | 296 UserInitiatedInfo user_initiated_info_; |
| 284 | 297 |
| 285 // This is a subtle member. If a provisional load A gets aborted by | 298 // This is a subtle member. If a provisional load A gets aborted by |
| 286 // provisional load B, which gets aborted by C that eventually commits, then | 299 // provisional load B, which gets aborted by C that eventually commits, then |
| 287 // there exists an abort chain of length 2, starting at A's navigation_start. | 300 // there exists an abort chain of length 2, starting at A's navigation_start. |
| 288 // This is useful because it allows histograming abort chain lengths based on | 301 // This is useful because it allows histograming abort chain lengths based on |
| 289 // what the last load's transition type is. i.e. holding down F-5 to spam | 302 // what the last load's transition type is. i.e. holding down F-5 to spam |
| 290 // reload will produce a long chain with the RELOAD transition. | 303 // reload will produce a long chain with the RELOAD transition. |
| 291 const int aborted_chain_size_; | 304 const int aborted_chain_size_; |
| 292 | 305 |
| 293 // This member counts consecutive provisional aborts that share a url. It will | 306 // This member counts consecutive provisional aborts that share a url. It will |
| 294 // always be less than or equal to |aborted_chain_size_|. | 307 // always be less than or equal to |aborted_chain_size_|. |
| 295 const int aborted_chain_size_same_url_; | 308 const int aborted_chain_size_same_url_; |
| 296 | 309 |
| 297 // Interface to chrome features. Must outlive the class. | 310 // Interface to chrome features. Must outlive the class. |
| 298 PageLoadMetricsEmbedderInterface* const embedder_interface_; | 311 PageLoadMetricsEmbedderInterface* const embedder_interface_; |
| 299 | 312 |
| 300 std::vector<std::unique_ptr<PageLoadMetricsObserver>> observers_; | 313 std::vector<std::unique_ptr<PageLoadMetricsObserver>> observers_; |
| 301 | 314 |
| 302 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); | 315 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
| 303 }; | 316 }; |
| 304 | 317 |
| 305 } // namespace page_load_metrics | 318 } // namespace page_load_metrics |
| 306 | 319 |
| 307 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ | 320 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ |
| OLD | NEW |