| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_manager.h" | 10 #include "chrome/browser/prerender/prerender_manager.h" |
| 11 #include "chrome/browser/prerender/prerender_manager_factory.h" | 11 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 13 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 | 16 |
| 17 namespace prerender { | 17 namespace prerender { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const int kMinHoverThresholdsMs[] = { | 21 const int kMinHoverThresholdsMs[] = { |
| 22 250 | 22 250 |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 // Overview of hover-related histograms: | 25 // Overview of hover-related histograms: |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // The time & url of a new hover that does not meet the threshold for | 159 // The time & url of a new hover that does not meet the threshold for |
| 160 // prerendering and may replace the prerender currently being prerendered. | 160 // prerendering and may replace the prerender currently being prerendered. |
| 161 base::TimeTicks new_time_; | 161 base::TimeTicks new_time_; |
| 162 GURL new_url_; | 162 GURL new_url_; |
| 163 | 163 |
| 164 // The threshold for hovering. | 164 // The threshold for hovering. |
| 165 base::TimeDelta hover_threshold_; | 165 base::TimeDelta hover_threshold_; |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 PrerenderTabHelper::PrerenderTabHelper(TabContentsWrapper* tab) | 168 PrerenderTabHelper::PrerenderTabHelper(TabContentsWrapper* tab) |
| 169 : content::WebContentsObserver(tab->tab_contents()), | 169 : content::WebContentsObserver(tab->web_contents()), |
| 170 tab_(tab), | 170 tab_(tab), |
| 171 pplt_load_start_(), | 171 pplt_load_start_(), |
| 172 last_hovers_(new HoverData[kNumHoverThresholds]) { | 172 last_hovers_(new HoverData[kNumHoverThresholds]) { |
| 173 for (int i = 0; i < kNumHoverThresholds; i++) | 173 for (int i = 0; i < kNumHoverThresholds; i++) |
| 174 last_hovers_[i].SetHoverThreshold(kMinHoverThresholdsMs[i]); | 174 last_hovers_[i].SetHoverThreshold(kMinHoverThresholdsMs[i]); |
| 175 } | 175 } |
| 176 | 176 |
| 177 PrerenderTabHelper::~PrerenderTabHelper() { | 177 PrerenderTabHelper::~PrerenderTabHelper() { |
| 178 } | 178 } |
| 179 | 179 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 current_hover_url_ = GURL(); | 303 current_hover_url_ = GURL(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 bool PrerenderTabHelper::IsTopSite(const GURL& url) { | 306 bool PrerenderTabHelper::IsTopSite(const GURL& url) { |
| 307 PrerenderManager* pm = MaybeGetPrerenderManager(); | 307 PrerenderManager* pm = MaybeGetPrerenderManager(); |
| 308 return (pm && pm->IsTopSite(url)); | 308 return (pm && pm->IsTopSite(url)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace prerender | 311 } // namespace prerender |
| OLD | NEW |