Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: chrome/browser/net/prediction_options.cc

Issue 443413002: Enable TCP preconnect and DNS preresolve on cellular. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698