Chromium Code Reviews| 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_METRICS_WEB_CONTENTS_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); | 172 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); |
| 173 | 173 |
| 174 // If the user performs some abort-like action while we are tracking this page | 174 // If the user performs some abort-like action while we are tracking this page |
| 175 // load, notify the tracker. Note that we may not classify this as an abort if | 175 // load, notify the tracker. Note that we may not classify this as an abort if |
| 176 // we've already performed a first paint. | 176 // we've already performed a first paint. |
| 177 // is_certainly_browser_timestamp signifies if the timestamp passed is taken | 177 // is_certainly_browser_timestamp signifies if the timestamp passed is taken |
| 178 // in the | 178 // in the |
| 179 // browser process or not. We need this to possibly clamp browser timestamp on | 179 // browser process or not. We need this to possibly clamp browser timestamp on |
| 180 // a machine with inter process time tick skew. | 180 // a machine with inter process time tick skew. |
| 181 void NotifyAbort(UserAbortType abort_type, | 181 void NotifyAbort(UserAbortType abort_type, |
| 182 bool user_initiated, | |
| 182 base::TimeTicks timestamp, | 183 base::TimeTicks timestamp, |
| 183 bool is_certainly_browser_timestamp); | 184 bool is_certainly_browser_timestamp); |
| 184 void UpdateAbort(UserAbortType abort_type, | 185 void UpdateAbort(UserAbortType abort_type, |
| 186 bool user_initiated, | |
| 185 base::TimeTicks timestamp, | 187 base::TimeTicks timestamp, |
| 186 bool is_certainly_browser_timestamp); | 188 bool is_certainly_browser_timestamp); |
| 187 | 189 |
| 188 // This method returns true if this page load has been aborted with type of | 190 // This method returns true if this page load has been aborted with type of |
| 189 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close | 191 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close |
| 190 // delta to when it was aborted. Note that only provisional loads can be | 192 // delta to when it was aborted. Note that only provisional loads can be |
| 191 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better | 193 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better |
| 192 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. | 194 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. |
| 193 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time) const; | 195 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time) const; |
| 194 | 196 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 209 private: | 211 private: |
| 210 // This function converts a TimeTicks value taken in the browser process | 212 // This function converts a TimeTicks value taken in the browser process |
| 211 // to navigation_start_ if: | 213 // to navigation_start_ if: |
| 212 // - base::TimeTicks is not comparable across processes because the clock | 214 // - base::TimeTicks is not comparable across processes because the clock |
| 213 // is not system wide monotonic. | 215 // is not system wide monotonic. |
| 214 // - *event_time < navigation_start_ | 216 // - *event_time < navigation_start_ |
| 215 void ClampBrowserTimestampIfInterProcessTimeTickSkew( | 217 void ClampBrowserTimestampIfInterProcessTimeTickSkew( |
| 216 base::TimeTicks* event_time); | 218 base::TimeTicks* event_time); |
| 217 | 219 |
| 218 void UpdateAbortInternal(UserAbortType abort_type, | 220 void UpdateAbortInternal(UserAbortType abort_type, |
| 221 bool user_initiated, | |
| 219 base::TimeTicks timestamp, | 222 base::TimeTicks timestamp, |
| 220 bool is_certainly_browser_timestamp); | 223 bool is_certainly_browser_timestamp); |
| 221 | 224 |
| 222 // If |final_navigation| is null, then this is an "unparented" abort chain, | 225 // If |final_navigation| is null, then this is an "unparented" abort chain, |
| 223 // and represents a sequence of provisional aborts that never ends with a | 226 // and represents a sequence of provisional aborts that never ends with a |
| 224 // committed load. | 227 // committed load. |
| 225 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); | 228 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); |
| 226 | 229 |
| 227 // Whether we stopped tracking this navigation after it was initiated. We may | 230 // Whether we stopped tracking this navigation after it was initiated. We may |
| 228 // stop tracking a navigation if it doesn't meet the criteria for tracking | 231 // stop tracking a navigation if it doesn't meet the criteria for tracking |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 242 | 245 |
| 243 // The URL of this page load. This is the provisional url before commit | 246 // The URL of this page load. This is the provisional url before commit |
| 244 // (before redirects), and the committed url after commit. | 247 // (before redirects), and the committed url after commit. |
| 245 GURL url_; | 248 GURL url_; |
| 246 | 249 |
| 247 std::unique_ptr<FailedProvisionalLoadInfo> failed_provisional_load_info_; | 250 std::unique_ptr<FailedProvisionalLoadInfo> failed_provisional_load_info_; |
| 248 | 251 |
| 249 // Will be ABORT_NONE if we have not aborted this load yet. Otherwise will | 252 // Will be ABORT_NONE if we have not aborted this load yet. Otherwise will |
| 250 // be the first abort action the user performed. | 253 // be the first abort action the user performed. |
| 251 UserAbortType abort_type_; | 254 UserAbortType abort_type_; |
| 255 | |
| 256 // This boolean is only an approximation. As the aborts pipeline is updated, | |
| 257 // more abort types will have this set to true. | |
| 258 bool abort_user_initiated_; | |
|
shivanisha
2016/08/11 19:23:01
May be briefly explain in the comment on why this
Charlie Harrison
2016/08/12 17:51:30
Done.
| |
| 259 | |
| 252 base::TimeTicks abort_time_; | 260 base::TimeTicks abort_time_; |
| 253 | 261 |
| 254 // We record separate metrics for events that occur after a background, | 262 // We record separate metrics for events that occur after a background, |
| 255 // because metrics like layout/paint are delayed artificially | 263 // because metrics like layout/paint are delayed artificially |
| 256 // when they occur in the background. | 264 // when they occur in the background. |
| 257 base::TimeTicks background_time_; | 265 base::TimeTicks background_time_; |
| 258 base::TimeTicks foreground_time_; | 266 base::TimeTicks foreground_time_; |
| 259 bool started_in_foreground_; | 267 bool started_in_foreground_; |
| 260 | 268 |
| 261 PageLoadTiming timing_; | 269 PageLoadTiming timing_; |
| 262 PageLoadMetadata metadata_; | 270 PageLoadMetadata metadata_; |
| 263 | 271 |
| 264 ui::PageTransition page_transition_; | 272 ui::PageTransition page_transition_; |
| 265 | 273 |
| 274 // This is derived from the user gesture bit it in the renderer. For browser | |
| 275 // initiated navigations this will always be true. | |
| 276 bool user_gesture_; | |
|
shivanisha
2016/08/11 19:23:01
typo: bit it
Charlie Harrison
2016/08/12 17:51:30
Done.
| |
| 277 | |
| 266 // This is a subtle member. If a provisional load A gets aborted by | 278 // This is a subtle member. If a provisional load A gets aborted by |
| 267 // provisional load B, which gets aborted by C that eventually commits, then | 279 // provisional load B, which gets aborted by C that eventually commits, then |
| 268 // there exists an abort chain of length 2, starting at A's navigation_start. | 280 // there exists an abort chain of length 2, starting at A's navigation_start. |
| 269 // This is useful because it allows histograming abort chain lengths based on | 281 // This is useful because it allows histograming abort chain lengths based on |
| 270 // what the last load's transition type is. i.e. holding down F-5 to spam | 282 // what the last load's transition type is. i.e. holding down F-5 to spam |
| 271 // reload will produce a long chain with the RELOAD transition. | 283 // reload will produce a long chain with the RELOAD transition. |
| 272 const int aborted_chain_size_; | 284 const int aborted_chain_size_; |
| 273 | 285 |
| 274 // This member counts consecutive provisional aborts that share a url. It will | 286 // This member counts consecutive provisional aborts that share a url. It will |
| 275 // always be less than or equal to |aborted_chain_size_|. | 287 // always be less than or equal to |aborted_chain_size_|. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 void HandleFailedNavigationForTrackedLoad( | 345 void HandleFailedNavigationForTrackedLoad( |
| 334 content::NavigationHandle* navigation_handle, | 346 content::NavigationHandle* navigation_handle, |
| 335 std::unique_ptr<PageLoadTracker> tracker); | 347 std::unique_ptr<PageLoadTracker> tracker); |
| 336 | 348 |
| 337 void HandleCommittedNavigationForTrackedLoad( | 349 void HandleCommittedNavigationForTrackedLoad( |
| 338 content::NavigationHandle* navigation_handle, | 350 content::NavigationHandle* navigation_handle, |
| 339 std::unique_ptr<PageLoadTracker> tracker); | 351 std::unique_ptr<PageLoadTracker> tracker); |
| 340 | 352 |
| 341 // Notify all loads, provisional and committed, that we performed an action | 353 // Notify all loads, provisional and committed, that we performed an action |
| 342 // that might abort them. | 354 // that might abort them. |
| 343 void NotifyAbortAllLoads(UserAbortType abort_type); | 355 void NotifyAbortAllLoads(UserAbortType abort_type, bool user_initiated); |
| 344 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, | 356 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, |
| 357 bool user_initiated, | |
| 345 base::TimeTicks timestamp, | 358 base::TimeTicks timestamp, |
| 346 bool is_certainly_browser_timestamp); | 359 bool is_certainly_browser_timestamp); |
| 347 | 360 |
| 348 // Register / Unregister input event callback to given RenderViewHost | 361 // Register / Unregister input event callback to given RenderViewHost |
| 349 void RegisterInputEventObserver(content::RenderViewHost* host); | 362 void RegisterInputEventObserver(content::RenderViewHost* host); |
| 350 void UnregisterInputEventObserver(content::RenderViewHost* host); | 363 void UnregisterInputEventObserver(content::RenderViewHost* host); |
| 351 | 364 |
| 352 // Notify aborted provisional loads that a new navigation occurred. This is | 365 // Notify aborted provisional loads that a new navigation occurred. This is |
| 353 // used for more consistent attribution tracking for aborted provisional | 366 // used for more consistent attribution tracking for aborted provisional |
| 354 // loads. This method returns the provisional load that was likely aborted | 367 // loads. This method returns the provisional load that was likely aborted |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 | 401 |
| 389 // Has the MWCO observed at least one navigation? | 402 // Has the MWCO observed at least one navigation? |
| 390 bool has_navigated_; | 403 bool has_navigated_; |
| 391 | 404 |
| 392 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 405 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
| 393 }; | 406 }; |
| 394 | 407 |
| 395 } // namespace page_load_metrics | 408 } // namespace page_load_metrics |
| 396 | 409 |
| 397 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ | 410 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ |
| OLD | NEW |