Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 24 matching lines...) Expand all Loading... | |
| 35 DCHECK(session); | 35 DCHECK(session); |
| 36 | 36 |
| 37 return new HttpNetworkLayer(session); | 37 return new HttpNetworkLayer(session); |
| 38 } | 38 } |
| 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 kExclude[] = "exclude"; // Hosts to exclude | 46 static const char kExclude[] = "exclude"; // Hosts to exclude |
| 46 static const char kDisableCompression[] = "no-compress"; | 47 static const char kDisableCompression[] = "no-compress"; |
| 47 static const char kDisableAltProtocols[] = "no-alt-protocols"; | 48 static const char kDisableAltProtocols[] = "no-alt-protocols"; |
| 48 static const char kEnableVersionOne[] = "v1"; | 49 static const char kEnableVersionOne[] = "v1"; |
| 49 static const char kForceAltProtocols[] = "force-alt-protocols"; | 50 static const char kForceAltProtocols[] = "force-alt-protocols"; |
| 50 static const char kSingleDomain[] = "single-domain"; | 51 static const char kSingleDomain[] = "single-domain"; |
| 51 | 52 |
| 52 // If flow-control is enabled, received WINDOW_UPDATE and SETTINGS | 53 // If flow-control is enabled, received WINDOW_UPDATE and SETTINGS |
| 53 // messages are processed and outstanding window size is actually obeyed | 54 // messages are processed and outstanding window size is actually obeyed |
| 54 // when sending data frames, and WINDOW_UPDATE messages are generated | 55 // when sending data frames, and WINDOW_UPDATE messages are generated |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 77 // No spdy specified. | 78 // No spdy specified. |
| 78 static const char kNpnProtosHttpOnly[] = "\x08http/1.1\x07http1.1"; | 79 static const char kNpnProtosHttpOnly[] = "\x08http/1.1\x07http1.1"; |
| 79 | 80 |
| 80 static const char kInitialMaxConcurrentStreams[] = "init-max-streams"; | 81 static const char kInitialMaxConcurrentStreams[] = "init-max-streams"; |
| 81 | 82 |
| 82 std::vector<std::string> spdy_options; | 83 std::vector<std::string> spdy_options; |
| 83 base::SplitString(mode, ',', &spdy_options); | 84 base::SplitString(mode, ',', &spdy_options); |
| 84 | 85 |
| 85 bool use_alt_protocols = true; | 86 bool use_alt_protocols = true; |
| 86 | 87 |
| 88 // Enable sending PING unless it is disabled by the options. | |
| 89 SpdySession::set_send_ping_for_every_request(true); | |
|
jar (doing other things)
2011/10/14 19:59:07
As per discussion... I think you should disable th
ramant (doing other things)
2011/10/14 23:42:45
Done.
| |
| 90 | |
| 87 for (std::vector<std::string>::iterator it = spdy_options.begin(); | 91 for (std::vector<std::string>::iterator it = spdy_options.begin(); |
| 88 it != spdy_options.end(); ++it) { | 92 it != spdy_options.end(); ++it) { |
| 89 const std::string& element = *it; | 93 const std::string& element = *it; |
| 90 std::vector<std::string> name_value; | 94 std::vector<std::string> name_value; |
| 91 base::SplitString(element, '=', &name_value); | 95 base::SplitString(element, '=', &name_value); |
| 92 const std::string& option = name_value[0]; | 96 const std::string& option = name_value[0]; |
| 93 const std::string value = name_value.size() > 1 ? name_value[1] : ""; | 97 const std::string value = name_value.size() > 1 ? name_value[1] : ""; |
| 94 | 98 |
| 95 if (option == kOff) { | 99 if (option == kOff) { |
| 96 HttpStreamFactory::set_spdy_enabled(false); | 100 HttpStreamFactory::set_spdy_enabled(false); |
| 97 } else if (option == kDisableSSL) { | 101 } else if (option == kDisableSSL) { |
| 98 SpdySession::SetSSLMode(false); // Disable SSL | 102 SpdySession::SetSSLMode(false); // Disable SSL |
| 99 HttpStreamFactory::set_force_spdy_over_ssl(false); | 103 HttpStreamFactory::set_force_spdy_over_ssl(false); |
| 100 HttpStreamFactory::set_force_spdy_always(true); | 104 HttpStreamFactory::set_force_spdy_always(true); |
| 101 } else if (option == kSSL) { | 105 } else if (option == kSSL) { |
| 102 HttpStreamFactory::set_force_spdy_over_ssl(true); | 106 HttpStreamFactory::set_force_spdy_over_ssl(true); |
| 103 HttpStreamFactory::set_force_spdy_always(true); | 107 HttpStreamFactory::set_force_spdy_always(true); |
| 108 } else if (option == kDisablePing) { | |
| 109 SpdySession::set_send_ping_for_every_request(false); | |
| 104 } else if (option == kExclude) { | 110 } else if (option == kExclude) { |
| 105 HttpStreamFactory::add_forced_spdy_exclusion(value); | 111 HttpStreamFactory::add_forced_spdy_exclusion(value); |
| 106 } else if (option == kDisableCompression) { | 112 } else if (option == kDisableCompression) { |
| 107 spdy::SpdyFramer::set_enable_compression_default(false); | 113 spdy::SpdyFramer::set_enable_compression_default(false); |
| 108 } else if (option == kEnableNPN) { | 114 } else if (option == kEnableNPN) { |
| 109 HttpStreamFactory::set_use_alternate_protocols(use_alt_protocols); | 115 HttpStreamFactory::set_use_alternate_protocols(use_alt_protocols); |
| 110 HttpStreamFactory::set_next_protos(kNpnProtosFull); | 116 HttpStreamFactory::set_next_protos(kNpnProtosFull); |
| 111 } else if (option == kEnableNpnHttpOnly) { | 117 } else if (option == kEnableNpnHttpOnly) { |
| 112 // Avoid alternate protocol in this case. Otherwise, browser will try SSL | 118 // Avoid alternate protocol in this case. Otherwise, browser will try SSL |
| 113 // and then fallback to http. This introduces extra load. | 119 // and then fallback to http. This introduces extra load. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 170 |
| 165 if (session_) | 171 if (session_) |
| 166 session_->CloseIdleConnections(); | 172 session_->CloseIdleConnections(); |
| 167 } | 173 } |
| 168 | 174 |
| 169 void HttpNetworkLayer::OnResume() { | 175 void HttpNetworkLayer::OnResume() { |
| 170 suspended_ = false; | 176 suspended_ = false; |
| 171 } | 177 } |
| 172 | 178 |
| 173 } // namespace net | 179 } // namespace net |
| OLD | NEW |