Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/page_load_metrics/experiments/delay_navigation_throttle.cc

Issue 2828663002: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/{i,l,m,n,p,r}* (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 weak_ptr_factory_(this) {} 106 weak_ptr_factory_(this) {}
107 107
108 DelayNavigationThrottle::~DelayNavigationThrottle() {} 108 DelayNavigationThrottle::~DelayNavigationThrottle() {}
109 109
110 content::NavigationThrottle::ThrottleCheckResult 110 content::NavigationThrottle::ThrottleCheckResult
111 DelayNavigationThrottle::WillStartRequest() { 111 DelayNavigationThrottle::WillStartRequest() {
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::Bind(&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 void DelayNavigationThrottle::OnDelayComplete() { 122 void DelayNavigationThrottle::OnDelayComplete() {
123 base::TimeDelta actual_delay = base::TimeTicks::Now() - delay_start_time_; 123 base::TimeDelta actual_delay = base::TimeTicks::Now() - delay_start_time_;
124 base::TimeDelta delay_delta = actual_delay - navigation_delay_; 124 base::TimeDelta delay_delta = actual_delay - navigation_delay_;
125 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayActual, actual_delay); 125 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayActual, actual_delay);
126 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayDelta, delay_delta.magnitude()); 126 UMA_HISTOGRAM_TIMES(kHistogramNavigationDelayDelta, delay_delta.magnitude());
127 127
128 page_load_metrics::MetricsWebContentsObserver* observer = 128 page_load_metrics::MetricsWebContentsObserver* observer =
129 page_load_metrics::MetricsWebContentsObserver::FromWebContents( 129 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
130 navigation_handle()->GetWebContents()); 130 navigation_handle()->GetWebContents());
131 if (observer) { 131 if (observer) {
132 observer->OnNavigationDelayComplete(navigation_handle(), navigation_delay_, 132 observer->OnNavigationDelayComplete(navigation_handle(), navigation_delay_,
133 actual_delay); 133 actual_delay);
134 } 134 }
135 135
136 navigation_handle()->Resume(); 136 navigation_handle()->Resume();
137 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698