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 | |
195 void HttpStreamFactory::SetNextProtos(const std::vector<std::string>& value) { | 183 void HttpStreamFactory::SetNextProtos(const std::vector<std::string>& value) { |
196 if (!next_protos_) | 184 if (!next_protos_) |
197 next_protos_ = new std::vector<std::string>; | 185 next_protos_ = new std::vector<std::string>; |
198 | 186 |
199 *next_protos_ = value; | 187 *next_protos_ = value; |
200 | 188 |
201 for (uint32 i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i) | 189 for (uint32 i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i) |
202 enabled_protocols_[i] = false; | 190 enabled_protocols_[i] = false; |
203 | 191 |
204 // TODO(rtenneti): bug 116575 - consider using same strings/enums for SPDY | 192 // TODO(rtenneti): bug 116575 - consider using same strings/enums for SPDY |
205 // versions in next_protos and kAlternateProtocolStrings. | 193 // versions in next_protos and kAlternateProtocolStrings. |
206 for (uint32 i = 0; i < value.size(); ++i) { | 194 for (uint32 i = 0; i < value.size(); ++i) { |
207 if (value[i] == "spdy/1") { | 195 if (value[i] == "spdy/1") { |
208 enabled_protocols_[NPN_SPDY_1] = true; | 196 enabled_protocols_[NPN_SPDY_1] = true; |
209 } else if (value[i] == "spdy/2") { | 197 } else if (value[i] == "spdy/2") { |
210 enabled_protocols_[NPN_SPDY_2] = true; | 198 enabled_protocols_[NPN_SPDY_2] = true; |
211 } else if (value[i] == "spdy/3") { | 199 } else if (value[i] == "spdy/3") { |
212 enabled_protocols_[NPN_SPDY_3] = true; | 200 enabled_protocols_[NPN_SPDY_3] = true; |
213 } else if (value[i] == "spdy/3.1") { | 201 } else if (value[i] == "spdy/3.1") { |
214 enabled_protocols_[NPN_SPDY_3_1] = true; | 202 enabled_protocols_[NPN_SPDY_3_1] = true; |
215 } else if (value[i] == "spdy/4a1") { | 203 } else if (value[i] == "spdy/4a2") { |
216 enabled_protocols_[NPN_SPDY_4a1] = true; | 204 enabled_protocols_[NPN_SPDY_4A2] = true; |
217 } else if (value[i] == "quic") { | 205 } else if (value[i] == "quic") { |
218 enabled_protocols_[QUIC] = true; | 206 enabled_protocols_[QUIC] = true; |
219 } | 207 } |
220 } | 208 } |
221 // TODO(rch): Remove all support for spdy/1. | 209 // TODO(rch): Remove all support for spdy/1. |
222 enabled_protocols_[NPN_SPDY_1] = false; | 210 enabled_protocols_[NPN_SPDY_1] = false; |
223 } | 211 } |
224 | 212 |
225 HttpStreamFactory::HttpStreamFactory() {} | 213 HttpStreamFactory::HttpStreamFactory() {} |
226 | 214 |
227 } // namespace net | 215 } // namespace net |
OLD | NEW |