Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/net/predictor_tab_helper.h" | 5 #include "chrome/browser/net/predictor_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/net/predictor.h" | 8 #include "chrome/browser/net/predictor.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "content/public/browser/navigation_handle.h" | |
| 12 | 13 |
| 13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper); | 14 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper); |
| 14 | 15 |
| 15 namespace chrome_browser_net { | 16 namespace chrome_browser_net { |
| 16 | 17 |
| 17 PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents) | 18 PredictorTabHelper::PredictorTabHelper(content::WebContents* web_contents) |
| 18 : content::WebContentsObserver(web_contents) { | 19 : content::WebContentsObserver(web_contents) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 PredictorTabHelper::~PredictorTabHelper() { | 22 PredictorTabHelper::~PredictorTabHelper() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 void PredictorTabHelper::DidStartNavigationToPendingEntry( | 25 void PredictorTabHelper::DidStartNavigation( |
| 25 const GURL& url, | 26 content::NavigationHandle* navigation_handle) { |
| 26 content::NavigationController::ReloadType reload_type) { | |
| 27 Profile* profile = | 27 Profile* profile = |
| 28 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 28 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 29 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor(); | 29 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor(); |
| 30 if (!predictor) | 30 if (!predictor) |
| 31 return; | 31 return; |
| 32 | |
| 33 const GURL& url = navigation_handle->GetURL(); | |
| 32 if (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme)) | 34 if (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme)) |
|
mmenke
2016/03/17 18:52:15
While we're here, maybe get rid of url local, and
Charlie Harrison
2016/03/17 21:22:41
ACK
| |
| 33 predictor->PreconnectUrlAndSubresources(url, GURL()); | 35 predictor->PreconnectUrlAndSubresources(url, GURL()); |
| 34 } | 36 } |
| 35 | 37 |
| 36 } // namespace chrome_browser_net | 38 } // namespace chrome_browser_net |
| OLD | NEW |