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 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_H_ |
6 #define NET_HTTP_HTTP_STREAM_FACTORY_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/string16.h" | 13 #include "base/string16.h" |
13 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
14 #include "net/base/load_states.h" | 15 #include "net/base/load_states.h" |
15 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
16 | 17 |
17 class GURL; | 18 class GURL; |
18 | 19 |
19 namespace net { | 20 namespace net { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 174 |
174 virtual void AddTLSIntolerantServer(const HostPortPair& server) = 0; | 175 virtual void AddTLSIntolerantServer(const HostPortPair& server) = 0; |
175 virtual bool IsTLSIntolerantServer(const HostPortPair& server) const = 0; | 176 virtual bool IsTLSIntolerantServer(const HostPortPair& server) const = 0; |
176 | 177 |
177 // Static settings | 178 // Static settings |
178 static GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); | 179 static GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); |
179 | 180 |
180 // Turns spdy on or off. | 181 // Turns spdy on or off. |
181 static void set_spdy_enabled(bool value) { | 182 static void set_spdy_enabled(bool value) { |
182 spdy_enabled_ = value; | 183 spdy_enabled_ = value; |
183 if (value == false) | 184 if (!spdy_enabled_) { |
184 set_next_protos(""); | 185 delete next_protos_; |
| 186 next_protos_ = NULL; |
| 187 } |
185 } | 188 } |
186 static bool spdy_enabled() { return spdy_enabled_; } | 189 static bool spdy_enabled() { return spdy_enabled_; } |
187 | 190 |
188 // Controls whether or not we use the Alternate-Protocol header. | 191 // Controls whether or not we use the Alternate-Protocol header. |
189 static void set_use_alternate_protocols(bool value) { | 192 static void set_use_alternate_protocols(bool value) { |
190 use_alternate_protocols_ = value; | 193 use_alternate_protocols_ = value; |
191 } | 194 } |
192 static bool use_alternate_protocols() { return use_alternate_protocols_; } | 195 static bool use_alternate_protocols() { return use_alternate_protocols_; } |
193 | 196 |
194 // Controls whether or not we use ssl when in spdy mode. | 197 // Controls whether or not we use ssl when in spdy mode. |
195 static void set_force_spdy_over_ssl(bool value) { | 198 static void set_force_spdy_over_ssl(bool value) { |
196 force_spdy_over_ssl_ = value; | 199 force_spdy_over_ssl_ = value; |
197 } | 200 } |
198 static bool force_spdy_over_ssl() { | 201 static bool force_spdy_over_ssl() { |
199 return force_spdy_over_ssl_; | 202 return force_spdy_over_ssl_; |
200 } | 203 } |
201 | 204 |
202 // Controls whether or not we use spdy without npn. | 205 // Controls whether or not we use spdy without npn. |
203 static void set_force_spdy_always(bool value) { | 206 static void set_force_spdy_always(bool value) { |
204 force_spdy_always_ = value; | 207 force_spdy_always_ = value; |
205 } | 208 } |
206 static bool force_spdy_always() { return force_spdy_always_; } | 209 static bool force_spdy_always() { return force_spdy_always_; } |
207 | 210 |
208 // Add a URL to exclude from forced SPDY. | 211 // Add a URL to exclude from forced SPDY. |
209 static void add_forced_spdy_exclusion(const std::string& value); | 212 static void add_forced_spdy_exclusion(const std::string& value); |
210 // Check if a HostPortPair is excluded from using spdy. | 213 // Check if a HostPortPair is excluded from using spdy. |
211 static bool HasSpdyExclusion(const HostPortPair& endpoint); | 214 static bool HasSpdyExclusion(const HostPortPair& endpoint); |
212 | 215 |
213 // Sets the next protocol negotiation value used during the SSL handshake. | 216 // Sets the next protocol negotiation value used during the SSL handshake. |
214 static void set_next_protos(const std::string& value) { | 217 static void set_next_protos(const std::vector<std::string>& value) { |
215 delete next_protos_; | 218 if (!next_protos_) |
216 next_protos_ = new std::string(value); | 219 next_protos_ = new std::vector<std::string>; |
| 220 *next_protos_ = value; |
217 } | 221 } |
218 static const std::string* next_protos() { return next_protos_; } | 222 static bool has_next_protos() { return next_protos_ != NULL; } |
| 223 static const std::vector<std::string>& next_protos() { |
| 224 return *next_protos_; |
| 225 } |
219 | 226 |
220 // Sets the HttpStreamFactoryImpl into a mode where it can ignore certificate | 227 // Sets the HttpStreamFactoryImpl into a mode where it can ignore certificate |
221 // errors. This is for testing. | 228 // errors. This is for testing. |
222 static void set_ignore_certificate_errors(bool value) { | 229 static void set_ignore_certificate_errors(bool value) { |
223 ignore_certificate_errors_ = value; | 230 ignore_certificate_errors_ = value; |
224 } | 231 } |
225 static bool ignore_certificate_errors() { | 232 static bool ignore_certificate_errors() { |
226 return ignore_certificate_errors_; | 233 return ignore_certificate_errors_; |
227 } | 234 } |
228 | 235 |
229 static void SetHostMappingRules(const std::string& rules); | 236 static void SetHostMappingRules(const std::string& rules); |
230 | 237 |
231 protected: | 238 protected: |
232 HttpStreamFactory(); | 239 HttpStreamFactory(); |
233 | 240 |
234 private: | 241 private: |
235 static const HostMappingRules& host_mapping_rules(); | 242 static const HostMappingRules& host_mapping_rules(); |
236 | 243 |
237 static const HostMappingRules* host_mapping_rules_; | 244 static const HostMappingRules* host_mapping_rules_; |
238 static const std::string* next_protos_; | 245 static std::vector<std::string>* next_protos_; |
239 static bool spdy_enabled_; | 246 static bool spdy_enabled_; |
240 static bool use_alternate_protocols_; | 247 static bool use_alternate_protocols_; |
241 static bool force_spdy_over_ssl_; | 248 static bool force_spdy_over_ssl_; |
242 static bool force_spdy_always_; | 249 static bool force_spdy_always_; |
243 static std::list<HostPortPair>* forced_spdy_exclusions_; | 250 static std::list<HostPortPair>* forced_spdy_exclusions_; |
244 static bool ignore_certificate_errors_; | 251 static bool ignore_certificate_errors_; |
245 | 252 |
246 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); | 253 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); |
247 }; | 254 }; |
248 | 255 |
249 } // namespace net | 256 } // namespace net |
250 | 257 |
251 #endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ | 258 #endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ |
OLD | NEW |