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/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 8 #include "chrome/browser/net/predictor.h" | 9 #include "chrome/browser/net/predictor.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 11 #include "content/public/browser/navigation_handle.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 namespace { | 18 namespace { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 46 } | 47 } |
| 47 | 48 |
| 48 void PredictorTabHelper::DidStartNavigationToPendingEntry( | 49 void PredictorTabHelper::DidStartNavigationToPendingEntry( |
| 49 const GURL& url, | 50 const GURL& url, |
| 50 content::NavigationController::ReloadType reload_type) { | 51 content::NavigationController::ReloadType reload_type) { |
| 51 // The standard way to preconnect based on navigation. | 52 // The standard way to preconnect based on navigation. |
| 52 PreconnectUrl(url); | 53 PreconnectUrl(url); |
| 53 predicted_from_pending_entry_ = true; | 54 predicted_from_pending_entry_ = true; |
| 54 } | 55 } |
| 55 | 56 |
| 57 void PredictorTabHelper::DocumentOnLoadCompletedInMainFrame() { | |
| 58 Profile* profile = | |
| 59 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | |
| 60 Predictor* predictor(profile->GetNetworkPredictor()); | |
|
Bernhard Bauer
2016/07/29 11:07:53
Nit: I would use assignment here to initialize |pr
Charlie Harrison
2016/07/29 13:42:13
Done.
| |
| 61 #if defined(OS_CHROMEOS) | |
| 62 if (chromeos::ProfileHelper::IsSigninProfile(profile)) | |
| 63 return; | |
| 64 #endif | |
| 65 if (predictor) | |
| 66 predictor->SaveStateForNextStartup(); | |
| 67 } | |
| 68 | |
| 56 void PredictorTabHelper::PreconnectUrl(const GURL& url) { | 69 void PredictorTabHelper::PreconnectUrl(const GURL& url) { |
| 57 Profile* profile = | 70 Profile* profile = |
| 58 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 71 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 59 chrome_browser_net::Predictor* predictor = profile->GetNetworkPredictor(); | 72 Predictor* predictor(profile->GetNetworkPredictor()); |
| 60 if (predictor && url.SchemeIsHTTPOrHTTPS()) | 73 if (predictor && url.SchemeIsHTTPOrHTTPS()) |
| 61 predictor->PreconnectUrlAndSubresources(url, GURL()); | 74 predictor->PreconnectUrlAndSubresources(url, GURL()); |
| 62 } | 75 } |
| 63 | 76 |
| 64 } // namespace chrome_browser_net | 77 } // namespace chrome_browser_net |
| OLD | NEW |