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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 void PredictorTabHelper::DidStartNavigationToPendingEntry( | 44 void PredictorTabHelper::DidStartNavigationToPendingEntry( |
45 const GURL& url, | 45 const GURL& url, |
46 content::NavigationController::ReloadType reload_type) { | 46 content::NavigationController::ReloadType reload_type) { |
47 Profile* profile = | 47 Profile* profile = |
48 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 48 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
49 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor(); | 49 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor(); |
50 if (!predictor) | 50 if (!predictor) |
51 return; | 51 return; |
52 if (url.SchemeIs(content::kHttpScheme) || url.SchemeIs(content::kHttpsScheme)) | 52 if (url.SchemeIs(url::kHttpScheme) || url.SchemeIs(url::kHttpsScheme)) |
53 predictor->PreconnectUrlAndSubresources(url, GURL()); | 53 predictor->PreconnectUrlAndSubresources(url, GURL()); |
54 } | 54 } |
55 | 55 |
56 void PredictorTabHelper::DidNavigateMainFrame( | 56 void PredictorTabHelper::DidNavigateMainFrame( |
57 const content::LoadCommittedDetails& details, | 57 const content::LoadCommittedDetails& details, |
58 const content::FrameNavigateParams& params) { | 58 const content::FrameNavigateParams& params) { |
59 if (!IsUserLinkNavigationRequest(params.transition) || | 59 if (!IsUserLinkNavigationRequest(params.transition) || |
60 !(params.url.SchemeIsHTTPOrHTTPS())) | 60 !(params.url.SchemeIsHTTPOrHTTPS())) |
61 return; | 61 return; |
62 | 62 |
63 Profile* profile = Profile::FromBrowserContext( | 63 Profile* profile = Profile::FromBrowserContext( |
64 web_contents()->GetBrowserContext()); | 64 web_contents()->GetBrowserContext()); |
65 Predictor* predictor = profile->GetNetworkPredictor(); | 65 Predictor* predictor = profile->GetNetworkPredictor(); |
66 if (predictor) { | 66 if (predictor) { |
67 BrowserThread::PostTask( | 67 BrowserThread::PostTask( |
68 BrowserThread::IO, | 68 BrowserThread::IO, |
69 FROM_HERE, | 69 FROM_HERE, |
70 base::Bind(&Predictor::RecordLinkNavigation, | 70 base::Bind(&Predictor::RecordLinkNavigation, |
71 base::Unretained(predictor), | 71 base::Unretained(predictor), |
72 params.url)); | 72 params.url)); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 } // namespace chrome_browser_net | 76 } // namespace chrome_browser_net |
OLD | NEW |