OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/prerender/prerender_tab_helper.h" | 5 #include "chrome/browser/prerender/prerender_tab_helper.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/prerender/prerender_histograms.h" | 10 #include "chrome/browser/prerender/prerender_histograms.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 return; | 161 return; |
162 url_ = validated_url; | 162 url_ = validated_url; |
163 PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); | 163 PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); |
164 if (!prerender_manager) | 164 if (!prerender_manager) |
165 return; | 165 return; |
166 if (prerender_manager->IsWebContentsPrerendering(web_contents())) | 166 if (prerender_manager->IsWebContentsPrerendering(web_contents())) |
167 return; | 167 return; |
168 prerender_manager->RecordNavigation(validated_url); | 168 prerender_manager->RecordNavigation(validated_url); |
169 } | 169 } |
170 | 170 |
171 void PrerenderTabHelper::DidStopLoading() { | 171 void PrerenderTabHelper::DidStopLoading( |
| 172 content::RenderViewHost* render_view_host) { |
172 // Compute the PPLT metric and report it in a histogram, if needed. | 173 // Compute the PPLT metric and report it in a histogram, if needed. |
173 // We include pages that are still prerendering and have just finished | 174 // We include pages that are still prerendering and have just finished |
174 // loading -- PrerenderManager will sort this out and handle it correctly | 175 // loading -- PrerenderManager will sort this out and handle it correctly |
175 // (putting those times into a separate histogram). | 176 // (putting those times into a separate histogram). |
176 if (!pplt_load_start_.is_null()) { | 177 if (!pplt_load_start_.is_null()) { |
177 double fraction_elapsed_at_swapin = -1.0; | 178 double fraction_elapsed_at_swapin = -1.0; |
178 base::TimeTicks now = base::TimeTicks::Now(); | 179 base::TimeTicks now = base::TimeTicks::Now(); |
179 if (!actual_load_start_.is_null()) { | 180 if (!actual_load_start_.is_null()) { |
180 double plt = (now - actual_load_start_).InMillisecondsF(); | 181 double plt = (now - actual_load_start_).InMillisecondsF(); |
181 if (plt > 0.0) { | 182 if (plt > 0.0) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // If we have not finished loading yet, record the actual load start, and | 246 // If we have not finished loading yet, record the actual load start, and |
246 // rebase the start time to now. | 247 // rebase the start time to now. |
247 actual_load_start_ = pplt_load_start_; | 248 actual_load_start_ = pplt_load_start_; |
248 pplt_load_start_ = base::TimeTicks::Now(); | 249 pplt_load_start_ = base::TimeTicks::Now(); |
249 if (pixel_stats_.get()) | 250 if (pixel_stats_.get()) |
250 pixel_stats_->GetBitmap(PixelStats::BITMAP_SWAP_IN, web_contents()); | 251 pixel_stats_->GetBitmap(PixelStats::BITMAP_SWAP_IN, web_contents()); |
251 } | 252 } |
252 } | 253 } |
253 | 254 |
254 } // namespace prerender | 255 } // namespace prerender |
OLD | NEW |