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

Unified Diff: chrome/browser/io_thread.cc

Issue 11416205: Move EnableSpdy from HttpNetworkLayer to IOThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/io_thread.cc
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 5848745497b86deb7545d83ac6853a8a9364837e..0b1ec5828559f739e2819a01587d1aa1d63d2dee 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -651,7 +651,7 @@ void IOThread::InitializeNetworkOptions(
if (parsed_command_line.HasSwitch(switches::kUseSpdy)) {
std::string spdy_mode =
parsed_command_line.GetSwitchValueASCII(switches::kUseSpdy);
- net::HttpNetworkLayer::EnableSpdy(spdy_mode);
+ EnableSpdy(spdy_mode);
used_spdy_switch = true;
}
if (parsed_command_line.HasSwitch(switches::kEnableSpdy3)) {
@@ -669,6 +669,68 @@ void IOThread::InitializeNetworkOptions(
}
}
+void IOThread::EnableSpdy(const std::string& mode) {
+ static const char kOff[] = "off";
+ static const char kSSL[] = "ssl";
+ static const char kDisableSSL[] = "no-ssl";
+ static const char kDisablePing[] = "no-ping";
+ static const char kExclude[] = "exclude"; // Hosts to exclude
+ static const char kDisableCompression[] = "no-compress";
+ static const char kDisableAltProtocols[] = "no-alt-protocols";
+ static const char kForceAltProtocols[] = "force-alt-protocols";
+ static const char kSingleDomain[] = "single-domain";
Ryan Sleevi 2012/11/27 20:06:38 You have many more options documented here than in
Ryan Hamilton 2012/11/27 20:52:53 No idea what the history here is. I've updated th
+
+ static const char kInitialMaxConcurrentStreams[] = "init-max-streams";
+
+ std::vector<std::string> spdy_options;
+ base::SplitString(mode, ',', &spdy_options);
+
+ for (std::vector<std::string>::iterator it = spdy_options.begin();
+ it != spdy_options.end(); ++it) {
+ const std::string& element = *it;
+ std::vector<std::string> name_value;
+ base::SplitString(element, '=', &name_value);
+ const std::string& option = name_value[0];
+ const std::string value = name_value.size() > 1 ? name_value[1] : "";
+
+ if (option == kOff) {
+ net::HttpStreamFactory::set_spdy_enabled(false);
+ } else if (option == kDisableSSL) {
+ net::SpdySession::set_default_protocol(net::kProtoSPDY2);
+ net::HttpStreamFactory::set_force_spdy_over_ssl(false);
+ net::HttpStreamFactory::set_force_spdy_always(true);
+ } else if (option == kSSL) {
+ net::SpdySession::set_default_protocol(net::kProtoSPDY2);
+ net::HttpStreamFactory::set_force_spdy_over_ssl(true);
+ net::HttpStreamFactory::set_force_spdy_always(true);
+ } else if (option == kDisablePing) {
+ net::SpdySession::set_enable_ping_based_connection_checking(false);
+ } else if (option == kExclude) {
+ net::HttpStreamFactory::add_forced_spdy_exclusion(value);
+ } else if (option == kDisableCompression) {
+ net::BufferedSpdyFramer::set_enable_compression_default(false);
+ } else if (option == kDisableAltProtocols) {
+ net::HttpStreamFactory::set_use_alternate_protocols(false);
+ } else if (option == kForceAltProtocols) {
+ net::PortAlternateProtocolPair pair;
+ pair.port = 443;
+ pair.protocol = net::NPN_SPDY_2;
+ net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
+ } else if (option == kSingleDomain) {
+ net::SpdySessionPool::ForceSingleDomain();
+ LOG(ERROR) << "FORCING SINGLE DOMAIN";
Ryan Sleevi 2012/11/27 20:06:38 Does this *really* need to be a LOG(ERROR)?
Ryan Hamilton 2012/11/27 20:52:53 Changed to DLOG(INFO).
+ } else if (option == kInitialMaxConcurrentStreams) {
+ int streams;
+ if (base::StringToInt(value, &streams) && streams > 0)
+ net::SpdySession::set_init_max_concurrent_streams(streams);
+ } else if (option.empty() && it == spdy_options.begin()) {
+ continue;
Ryan Sleevi 2012/11/27 20:06:38 So ",foo" is a valid option string?
Ryan Hamilton 2012/11/27 20:52:53 Actually that appears to crash. I've fixed a bug
+ } else {
+ LOG(DFATAL) << "Unrecognized spdy option: " << option;
Ryan Sleevi 2012/11/27 20:06:38 Should you just rewrite this as LOG(ERROR)? Trying
Ryan Hamilton 2012/11/27 20:52:53 I'm happy to change this, but in my experience wit
+ }
Ryan Sleevi 2012/11/27 20:06:38 It strikes me as odd that "off,ssl,no-ssl" is a pe
Ryan Hamilton 2012/11/27 20:52:53 Yes, this is a very strange piece of code.
+ }
+}
+
// static
void IOThread::RegisterPrefs(PrefService* local_state) {
local_state->RegisterStringPref(prefs::kAuthSchemes,

Powered by Google App Engine
This is Rietveld 408576698