Chromium Code Reviews| Index: chrome/browser/net/prediction_options.cc |
| diff --git a/chrome/browser/net/prediction_options.cc b/chrome/browser/net/prediction_options.cc |
| index 34fc98894e72e5c40f5ac2b8b2482c13378d0883..9666ccc4d36834816f39068a19ad65823185b547 100644 |
| --- a/chrome/browser/net/prediction_options.cc |
| +++ b/chrome/browser/net/prediction_options.cc |
| @@ -34,6 +34,25 @@ bool CanPredictNetworkActions(int NetworkPredictionOptions, |
| } |
| } |
| +bool CanPreconnect(int NetworkPredictionOptions, |
| + bool NetworkPredictionEnabled) { |
|
mmenke
2014/08/08 16:05:42
These should be named network_prediction_options a
Bence
2014/08/08 20:10:03
Done.
|
| + switch (NetworkPredictionOptions) { |
| + case chrome_browser_net::NETWORK_PREDICTION_ALWAYS: |
| + return true; |
| + // We allow TCP preconnect and DNS preresolution even on cellular networks |
| + // if the user setting is WIFI_ONLY. |
|
mmenke
2014/08/08 16:05:42
nit: Shouldn't use we in comments, since it's amb
Bence
2014/08/08 20:10:03
Done.
|
| + case chrome_browser_net::NETWORK_PREDICTION_WIFI_ONLY: |
| + return true; |
| + case chrome_browser_net::NETWORK_PREDICTION_NEVER: |
| + return false; |
| + case chrome_browser_net::NETWORK_PREDICTION_UNSET: |
| + return NetworkPredictionEnabled; |
| + default: |
| + NOTREACHED() << "Unknown kNetworkPredictionOptions value."; |
| + return false; |
| + } |
| +} |
| + |
| } // namespace |
| namespace chrome_browser_net { |
| @@ -63,4 +82,20 @@ bool CanPredictNetworkActionsUI(PrefService* prefs) { |
| prefs->GetBoolean(prefs::kNetworkPredictionEnabled)); |
| } |
| +bool CanPreconnectIO(ProfileIOData* profile_io_data) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| + DCHECK(profile_io_data); |
| + |
|
mmenke
2014/08/08 16:05:42
optional nit: The two IO thread functions have bl
Bence
2014/08/08 20:10:03
Done.
|
| + return CanPreconnect( |
| + profile_io_data->network_prediction_options()->GetValue(), |
| + profile_io_data->network_prediction_enabled()->GetValue()); |
| +} |
| + |
| +bool CanPreconnectUI(PrefService* prefs) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| + DCHECK(prefs); |
| + return CanPreconnect(prefs->GetInteger(prefs::kNetworkPredictionOptions), |
| + prefs->GetBoolean(prefs::kNetworkPredictionEnabled)); |
| +} |
| + |
| } // namespace chrome_browser_net |