OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/experiments/delay_navigation_throttle
.h" | 5 #include "chrome/browser/page_load_metrics/experiments/delay_navigation_throttle
.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/metrics/field_trial_params.h" | 8 #include "base/metrics/field_trial_params.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelaySpecified, navigation_delay_); | 112 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelaySpecified, navigation_delay_); |
113 delay_start_time_ = base::TimeTicks::Now(); | 113 delay_start_time_ = base::TimeTicks::Now(); |
114 task_runner_->PostDelayedTask( | 114 task_runner_->PostDelayedTask( |
115 FROM_HERE, | 115 FROM_HERE, |
116 base::BindOnce(&DelayNavigationThrottle::OnDelayComplete, | 116 base::BindOnce(&DelayNavigationThrottle::OnDelayComplete, |
117 weak_ptr_factory_.GetWeakPtr()), | 117 weak_ptr_factory_.GetWeakPtr()), |
118 navigation_delay_); | 118 navigation_delay_); |
119 return content::NavigationThrottle::DEFER; | 119 return content::NavigationThrottle::DEFER; |
120 } | 120 } |
121 | 121 |
| 122 const char* DelayNavigationThrottle::GetNameForLogging() { |
| 123 return "DelayNavigationThrottle"; |
| 124 } |
| 125 |
122 void DelayNavigationThrottle::OnDelayComplete() { | 126 void DelayNavigationThrottle::OnDelayComplete() { |
123 base::TimeDelta actual_delay = base::TimeTicks::Now() - delay_start_time_; | 127 base::TimeDelta actual_delay = base::TimeTicks::Now() - delay_start_time_; |
124 base::TimeDelta delay_delta = actual_delay - navigation_delay_; | 128 base::TimeDelta delay_delta = actual_delay - navigation_delay_; |
125 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayActual, actual_delay); | 129 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayActual, actual_delay); |
126 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayDelta, delay_delta.magnitude()); | 130 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayDelta, delay_delta.magnitude()); |
127 | 131 |
128 page_load_metrics::MetricsWebContentsObserver* observer = | 132 page_load_metrics::MetricsWebContentsObserver* observer = |
129 page_load_metrics::MetricsWebContentsObserver::FromWebContents( | 133 page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
130 navigation_handle()->GetWebContents()); | 134 navigation_handle()->GetWebContents()); |
131 if (observer) { | 135 if (observer) { |
132 observer->OnNavigationDelayComplete(navigation_handle(), navigation_delay_, | 136 observer->OnNavigationDelayComplete(navigation_handle(), navigation_delay_, |
133 actual_delay); | 137 actual_delay); |
134 } | 138 } |
135 | 139 |
136 navigation_handle()->Resume(); | 140 navigation_handle()->Resume(); |
137 } | 141 } |
OLD | NEW |