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/chromeos/profiles/profile_helper.h" |
9 #include "chrome/browser/net/predictor.h" | 9 #include "chrome/browser/net/predictor.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return; | 41 return; |
42 if (predicted_from_pending_entry_) { | 42 if (predicted_from_pending_entry_) { |
43 predicted_from_pending_entry_ = false; | 43 predicted_from_pending_entry_ = false; |
44 return; | 44 return; |
45 } | 45 } |
46 PreconnectUrl(navigation_handle->GetURL()); | 46 PreconnectUrl(navigation_handle->GetURL()); |
47 } | 47 } |
48 | 48 |
49 void PredictorTabHelper::DidStartNavigationToPendingEntry( | 49 void PredictorTabHelper::DidStartNavigationToPendingEntry( |
50 const GURL& url, | 50 const GURL& url, |
51 content::NavigationController::ReloadType reload_type) { | 51 content::ReloadType reload_type) { |
52 // The standard way to preconnect based on navigation. | 52 // The standard way to preconnect based on navigation. |
53 PreconnectUrl(url); | 53 PreconnectUrl(url); |
54 predicted_from_pending_entry_ = true; | 54 predicted_from_pending_entry_ = true; |
55 } | 55 } |
56 | 56 |
57 void PredictorTabHelper::DocumentOnLoadCompletedInMainFrame() { | 57 void PredictorTabHelper::DocumentOnLoadCompletedInMainFrame() { |
58 Profile* profile = | 58 Profile* profile = |
59 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 59 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
60 Predictor* predictor = profile->GetNetworkPredictor(); | 60 Predictor* predictor = profile->GetNetworkPredictor(); |
61 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
62 if (chromeos::ProfileHelper::IsSigninProfile(profile)) | 62 if (chromeos::ProfileHelper::IsSigninProfile(profile)) |
63 return; | 63 return; |
64 #endif | 64 #endif |
65 if (predictor) | 65 if (predictor) |
66 predictor->SaveStateForNextStartup(); | 66 predictor->SaveStateForNextStartup(); |
67 } | 67 } |
68 | 68 |
69 void PredictorTabHelper::PreconnectUrl(const GURL& url) { | 69 void PredictorTabHelper::PreconnectUrl(const GURL& url) { |
70 Profile* profile = | 70 Profile* profile = |
71 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 71 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
72 Predictor* predictor(profile->GetNetworkPredictor()); | 72 Predictor* predictor(profile->GetNetworkPredictor()); |
73 if (predictor && url.SchemeIsHTTPOrHTTPS()) | 73 if (predictor && url.SchemeIsHTTPOrHTTPS()) |
74 predictor->PreconnectUrlAndSubresources(url, GURL()); | 74 predictor->PreconnectUrlAndSubresources(url, GURL()); |
75 } | 75 } |
76 | 76 |
77 } // namespace chrome_browser_net | 77 } // namespace chrome_browser_net |
OLD | NEW |