| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/http/http_network_layer.h" | 5 #include "net/http/http_network_layer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 void HttpNetworkLayer::EnableSpdy(const std::string& mode) { | 41 void HttpNetworkLayer::EnableSpdy(const std::string& mode) { |
| 42 static const char kOff[] = "off"; | 42 static const char kOff[] = "off"; |
| 43 static const char kSSL[] = "ssl"; | 43 static const char kSSL[] = "ssl"; |
| 44 static const char kDisableSSL[] = "no-ssl"; | 44 static const char kDisableSSL[] = "no-ssl"; |
| 45 static const char kDisablePing[] = "no-ping"; | 45 static const char kDisablePing[] = "no-ping"; |
| 46 static const char kExclude[] = "exclude"; // Hosts to exclude | 46 static const char kExclude[] = "exclude"; // Hosts to exclude |
| 47 static const char kDisableCompression[] = "no-compress"; | 47 static const char kDisableCompression[] = "no-compress"; |
| 48 static const char kDisableAltProtocols[] = "no-alt-protocols"; | 48 static const char kDisableAltProtocols[] = "no-alt-protocols"; |
| 49 static const char kEnableVersionOne[] = "v1"; | 49 static const char kEnableVersionThree[] = "v3"; |
| 50 static const char kForceAltProtocols[] = "force-alt-protocols"; | 50 static const char kForceAltProtocols[] = "force-alt-protocols"; |
| 51 static const char kSingleDomain[] = "single-domain"; | 51 static const char kSingleDomain[] = "single-domain"; |
| 52 | 52 |
| 53 // If flow-control is enabled, received WINDOW_UPDATE and SETTINGS | 53 // If flow-control is enabled, received WINDOW_UPDATE and SETTINGS |
| 54 // messages are processed and outstanding window size is actually obeyed | 54 // messages are processed and outstanding window size is actually obeyed |
| 55 // when sending data frames, and WINDOW_UPDATE messages are generated | 55 // when sending data frames, and WINDOW_UPDATE messages are generated |
| 56 // when data is consumed. | 56 // when data is consumed. |
| 57 static const char kEnableFlowControl[] = "flow-control"; | 57 static const char kEnableFlowControl[] = "flow-control"; |
| 58 | 58 |
| 59 // We want an A/B experiment between SPDY enabled and SPDY disabled, | 59 // We want an A/B experiment between SPDY enabled and SPDY disabled, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 77 it != spdy_options.end(); ++it) { | 77 it != spdy_options.end(); ++it) { |
| 78 const std::string& element = *it; | 78 const std::string& element = *it; |
| 79 std::vector<std::string> name_value; | 79 std::vector<std::string> name_value; |
| 80 base::SplitString(element, '=', &name_value); | 80 base::SplitString(element, '=', &name_value); |
| 81 const std::string& option = name_value[0]; | 81 const std::string& option = name_value[0]; |
| 82 const std::string value = name_value.size() > 1 ? name_value[1] : ""; | 82 const std::string value = name_value.size() > 1 ? name_value[1] : ""; |
| 83 | 83 |
| 84 if (option == kOff) { | 84 if (option == kOff) { |
| 85 HttpStreamFactory::set_spdy_enabled(false); | 85 HttpStreamFactory::set_spdy_enabled(false); |
| 86 } else if (option == kDisableSSL) { | 86 } else if (option == kDisableSSL) { |
| 87 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); |
| 87 SpdySession::SetSSLMode(false); // Disable SSL | 88 SpdySession::SetSSLMode(false); // Disable SSL |
| 88 HttpStreamFactory::set_force_spdy_over_ssl(false); | 89 HttpStreamFactory::set_force_spdy_over_ssl(false); |
| 89 HttpStreamFactory::set_force_spdy_always(true); | 90 HttpStreamFactory::set_force_spdy_always(true); |
| 90 } else if (option == kSSL) { | 91 } else if (option == kSSL) { |
| 92 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); |
| 91 HttpStreamFactory::set_force_spdy_over_ssl(true); | 93 HttpStreamFactory::set_force_spdy_over_ssl(true); |
| 92 HttpStreamFactory::set_force_spdy_always(true); | 94 HttpStreamFactory::set_force_spdy_always(true); |
| 93 } else if (option == kDisablePing) { | 95 } else if (option == kDisablePing) { |
| 94 SpdySession::set_enable_ping_based_connection_checking(false); | 96 SpdySession::set_enable_ping_based_connection_checking(false); |
| 95 } else if (option == kExclude) { | 97 } else if (option == kExclude) { |
| 96 HttpStreamFactory::add_forced_spdy_exclusion(value); | 98 HttpStreamFactory::add_forced_spdy_exclusion(value); |
| 97 } else if (option == kDisableCompression) { | 99 } else if (option == kDisableCompression) { |
| 98 spdy::SpdyFramer::set_enable_compression_default(false); | 100 spdy::SpdyFramer::set_enable_compression_default(false); |
| 99 } else if (option == kEnableNPN) { | 101 } else if (option == kEnableNPN) { |
| 100 HttpStreamFactory::set_use_alternate_protocols(use_alt_protocols); | 102 HttpStreamFactory::set_use_alternate_protocols(use_alt_protocols); |
| 101 std::vector<std::string> next_protos; | 103 std::vector<std::string> next_protos; |
| 102 next_protos.push_back("http/1.1"); | 104 next_protos.push_back("http/1.1"); |
| 103 next_protos.push_back("spdy/2"); | 105 next_protos.push_back("spdy/2"); |
| 104 HttpStreamFactory::SetNextProtos(next_protos); | 106 HttpStreamFactory::SetNextProtos(next_protos); |
| 107 } else if (option == kEnableVersionThree) { |
| 108 std::vector<std::string> next_protos; |
| 109 next_protos.push_back("http/1.1"); |
| 110 next_protos.push_back("spdy/2"); |
| 111 next_protos.push_back("spdy/2.1"); |
| 112 next_protos.push_back("spdy/3"); |
| 113 HttpStreamFactory::SetNextProtos(next_protos); |
| 105 } else if (option == kEnableNpnHttpOnly) { | 114 } else if (option == kEnableNpnHttpOnly) { |
| 106 // Avoid alternate protocol in this case. Otherwise, browser will try SSL | 115 // Avoid alternate protocol in this case. Otherwise, browser will try SSL |
| 107 // and then fallback to http. This introduces extra load. | 116 // and then fallback to http. This introduces extra load. |
| 108 HttpStreamFactory::set_use_alternate_protocols(false); | 117 HttpStreamFactory::set_use_alternate_protocols(false); |
| 109 std::vector<std::string> next_protos; | 118 std::vector<std::string> next_protos; |
| 110 next_protos.push_back("http/1.1"); | 119 next_protos.push_back("http/1.1"); |
| 111 next_protos.push_back("http1.1"); | 120 next_protos.push_back("http1.1"); |
| 112 HttpStreamFactory::SetNextProtos(next_protos); | 121 HttpStreamFactory::SetNextProtos(next_protos); |
| 113 } else if (option == kEnableVersionOne) { | |
| 114 spdy::SpdyFramer::set_protocol_version(1); | |
| 115 std::vector<std::string> next_protos; | |
| 116 // This is a temporary hack to pretend we support version 1. | |
| 117 next_protos.push_back("http/1.1"); | |
| 118 next_protos.push_back("spdy/1"); | |
| 119 HttpStreamFactory::SetNextProtos(next_protos); | |
| 120 } else if (option == kDisableAltProtocols) { | 122 } else if (option == kDisableAltProtocols) { |
| 121 use_alt_protocols = false; | 123 use_alt_protocols = false; |
| 122 HttpStreamFactory::set_use_alternate_protocols(false); | 124 HttpStreamFactory::set_use_alternate_protocols(false); |
| 123 } else if (option == kEnableFlowControl) { | 125 } else if (option == kEnableFlowControl) { |
| 124 std::vector<std::string> next_protos; | 126 std::vector<std::string> next_protos; |
| 125 next_protos.push_back("http/1.1"); | 127 next_protos.push_back("http/1.1"); |
| 126 next_protos.push_back("spdy/2"); | 128 next_protos.push_back("spdy/2"); |
| 127 next_protos.push_back("spdy/2.1"); | 129 next_protos.push_back("spdy/2.1"); |
| 128 HttpStreamFactory::SetNextProtos(next_protos); | 130 HttpStreamFactory::SetNextProtos(next_protos); |
| 129 } else if (option == kForceAltProtocols) { | 131 } else if (option == kForceAltProtocols) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 171 |
| 170 if (session_) | 172 if (session_) |
| 171 session_->CloseIdleConnections(); | 173 session_->CloseIdleConnections(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void HttpNetworkLayer::OnResume() { | 176 void HttpNetworkLayer::OnResume() { |
| 175 suspended_ = false; | 177 suspended_ = false; |
| 176 } | 178 } |
| 177 | 179 |
| 178 } // namespace net | 180 } // namespace net |
| OLD | NEW |