| 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 #include "chrome/browser/page_load_metrics/page_load_tracker.h" | 5 #include "chrome/browser/page_load_metrics/page_load_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 background_time_ = base::TimeTicks::Now(); | 406 background_time_ = base::TimeTicks::Now(); |
| 407 ClampBrowserTimestampIfInterProcessTimeTickSkew(&background_time_); | 407 ClampBrowserTimestampIfInterProcessTimeTickSkew(&background_time_); |
| 408 // Though most cases where a tab is backgrounded are user initiated, we | 408 // Though most cases where a tab is backgrounded are user initiated, we |
| 409 // can't be certain that we were backgrounded due to a user action. For | 409 // can't be certain that we were backgrounded due to a user action. For |
| 410 // example, on Android, the screen times out after a period of inactivity, | 410 // example, on Android, the screen times out after a period of inactivity, |
| 411 // resulting in a non-user-initiated backgrounding. | 411 // resulting in a non-user-initiated backgrounding. |
| 412 const bool abort_is_user_initiated = false; | 412 const bool abort_is_user_initiated = false; |
| 413 NotifyAbort(ABORT_BACKGROUND, abort_is_user_initiated, background_time_, | 413 NotifyAbort(ABORT_BACKGROUND, abort_is_user_initiated, background_time_, |
| 414 true); | 414 true); |
| 415 } | 415 } |
| 416 | 416 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); |
| 417 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnHidden); | 417 INVOKE_AND_PRUNE_OBSERVERS(observers_, OnHidden, timing_, info); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void PageLoadTracker::WebContentsShown() { | 420 void PageLoadTracker::WebContentsShown() { |
| 421 // Only log the first time we foreground in a given page load. | 421 // Only log the first time we foreground in a given page load. |
| 422 if (foreground_time_.is_null()) { | 422 if (foreground_time_.is_null()) { |
| 423 // Make sure we either started in the background and haven't been | 423 // Make sure we either started in the background and haven't been |
| 424 // backgrounded yet, or started in the foreground and have already been | 424 // backgrounded yet, or started in the foreground and have already been |
| 425 // backgrounded. | 425 // backgrounded. |
| 426 DCHECK_NE(started_in_foreground_, background_time_.is_null()); | 426 DCHECK_NE(started_in_foreground_, background_time_.is_null()); |
| 427 foreground_time_ = base::TimeTicks::Now(); | 427 foreground_time_ = base::TimeTicks::Now(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 abort_type_ = abort_type; | 665 abort_type_ = abort_type; |
| 666 abort_time_ = timestamp; | 666 abort_time_ = timestamp; |
| 667 abort_user_initiated_ = user_initiated && abort_type != ABORT_CLIENT_REDIRECT; | 667 abort_user_initiated_ = user_initiated && abort_type != ABORT_CLIENT_REDIRECT; |
| 668 | 668 |
| 669 if (is_certainly_browser_timestamp) { | 669 if (is_certainly_browser_timestamp) { |
| 670 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); | 670 ClampBrowserTimestampIfInterProcessTimeTickSkew(&abort_time_); |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 | 673 |
| 674 } // namespace page_load_metrics | 674 } // namespace page_load_metrics |
| OLD | NEW |