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_stream_factory.h" | 5 #include "net/http/http_stream_factory.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/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 set_use_alternate_protocols(true); | 173 set_use_alternate_protocols(true); |
174 std::vector<std::string> next_protos; | 174 std::vector<std::string> next_protos; |
175 next_protos.push_back("http/1.1"); | 175 next_protos.push_back("http/1.1"); |
176 next_protos.push_back("spdy/2"); | 176 next_protos.push_back("spdy/2"); |
177 next_protos.push_back("spdy/3"); | 177 next_protos.push_back("spdy/3"); |
178 next_protos.push_back("spdy/3.1"); | 178 next_protos.push_back("spdy/3.1"); |
179 SetNextProtos(next_protos); | 179 SetNextProtos(next_protos); |
180 } | 180 } |
181 | 181 |
182 // static | 182 // static |
| 183 void HttpStreamFactory::EnableNpnSpdy4a1() { |
| 184 set_use_alternate_protocols(true); |
| 185 std::vector<std::string> next_protos; |
| 186 next_protos.push_back("http/1.1"); |
| 187 next_protos.push_back("spdy/2"); |
| 188 next_protos.push_back("spdy/3"); |
| 189 next_protos.push_back("spdy/3.1"); |
| 190 next_protos.push_back("spdy/4a1"); |
| 191 SetNextProtos(next_protos); |
| 192 } |
| 193 |
| 194 // static |
183 void HttpStreamFactory::SetNextProtos(const std::vector<std::string>& value) { | 195 void HttpStreamFactory::SetNextProtos(const std::vector<std::string>& value) { |
184 if (!next_protos_) | 196 if (!next_protos_) |
185 next_protos_ = new std::vector<std::string>; | 197 next_protos_ = new std::vector<std::string>; |
186 | 198 |
187 *next_protos_ = value; | 199 *next_protos_ = value; |
188 | 200 |
189 for (uint32 i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i) | 201 for (uint32 i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i) |
190 enabled_protocols_[i] = false; | 202 enabled_protocols_[i] = false; |
191 | 203 |
192 // TODO(rtenneti): bug 116575 - consider using same strings/enums for SPDY | 204 // TODO(rtenneti): bug 116575 - consider using same strings/enums for SPDY |
193 // versions in next_protos and kAlternateProtocolStrings. | 205 // versions in next_protos and kAlternateProtocolStrings. |
194 for (uint32 i = 0; i < value.size(); ++i) { | 206 for (uint32 i = 0; i < value.size(); ++i) { |
195 if (value[i] == "spdy/1") { | 207 if (value[i] == "spdy/1") { |
196 enabled_protocols_[NPN_SPDY_1] = true; | 208 enabled_protocols_[NPN_SPDY_1] = true; |
197 } else if (value[i] == "spdy/2") { | 209 } else if (value[i] == "spdy/2") { |
198 enabled_protocols_[NPN_SPDY_2] = true; | 210 enabled_protocols_[NPN_SPDY_2] = true; |
199 } else if (value[i] == "spdy/3") { | 211 } else if (value[i] == "spdy/3") { |
200 enabled_protocols_[NPN_SPDY_3] = true; | 212 enabled_protocols_[NPN_SPDY_3] = true; |
201 } else if (value[i] == "spdy/3.1") { | 213 } else if (value[i] == "spdy/3.1") { |
202 enabled_protocols_[NPN_SPDY_3_1] = true; | 214 enabled_protocols_[NPN_SPDY_3_1] = true; |
| 215 } else if (value[i] == "spdy/4a1") { |
| 216 enabled_protocols_[NPN_SPDY_4a1] = true; |
203 } else if (value[i] == "quic") { | 217 } else if (value[i] == "quic") { |
204 enabled_protocols_[QUIC] = true; | 218 enabled_protocols_[QUIC] = true; |
205 } | 219 } |
206 } | 220 } |
207 // TODO(rch): Remove all support for spdy/1. | 221 // TODO(rch): Remove all support for spdy/1. |
208 enabled_protocols_[NPN_SPDY_1] = false; | 222 enabled_protocols_[NPN_SPDY_1] = false; |
209 } | 223 } |
210 | 224 |
211 HttpStreamFactory::HttpStreamFactory() {} | 225 HttpStreamFactory::HttpStreamFactory() {} |
212 | 226 |
213 } // namespace net | 227 } // namespace net |
OLD | NEW |