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 #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 #include <vector> |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // The HttpStreamFactory defines an interface for creating usable HttpStreams. | 156 // The HttpStreamFactory defines an interface for creating usable HttpStreams. |
157 class NET_EXPORT HttpStreamFactory { | 157 class NET_EXPORT HttpStreamFactory { |
158 public: | 158 public: |
159 virtual ~HttpStreamFactory(); | 159 virtual ~HttpStreamFactory(); |
160 | 160 |
161 void ProcessAlternateProtocol( | 161 void ProcessAlternateProtocol( |
162 HttpServerProperties* http_server_properties, | 162 HttpServerProperties* http_server_properties, |
163 const std::string& alternate_protocol_str, | 163 const std::string& alternate_protocol_str, |
164 const HostPortPair& http_host_port_pair); | 164 const HostPortPair& http_host_port_pair); |
165 | 165 |
| 166 GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); |
| 167 |
166 // Virtual interface methods. | 168 // Virtual interface methods. |
167 | 169 |
168 // Request a stream. | 170 // Request a stream. |
169 // Will callback to the HttpStreamRequestDelegate upon completion. | 171 // Will callback to the HttpStreamRequestDelegate upon completion. |
170 virtual HttpStreamRequest* RequestStream( | 172 virtual HttpStreamRequest* RequestStream( |
171 const HttpRequestInfo& info, | 173 const HttpRequestInfo& info, |
172 const SSLConfig& server_ssl_config, | 174 const SSLConfig& server_ssl_config, |
173 const SSLConfig& proxy_ssl_config, | 175 const SSLConfig& proxy_ssl_config, |
174 HttpStreamRequest::Delegate* delegate, | 176 HttpStreamRequest::Delegate* delegate, |
175 const BoundNetLog& net_log) = 0; | 177 const BoundNetLog& net_log) = 0; |
176 | 178 |
177 // Requests that enough connections for |num_streams| be opened. | 179 // Requests that enough connections for |num_streams| be opened. |
178 virtual void PreconnectStreams(int num_streams, | 180 virtual void PreconnectStreams(int num_streams, |
179 const HttpRequestInfo& info, | 181 const HttpRequestInfo& info, |
180 const SSLConfig& server_ssl_config, | 182 const SSLConfig& server_ssl_config, |
181 const SSLConfig& proxy_ssl_config) = 0; | 183 const SSLConfig& proxy_ssl_config) = 0; |
182 | 184 |
183 // If pipelining is supported, creates a Value summary of the currently active | 185 // If pipelining is supported, creates a Value summary of the currently active |
184 // pipelines. Caller assumes ownership of the returned value. Otherwise, | 186 // pipelines. Caller assumes ownership of the returned value. Otherwise, |
185 // returns an empty Value. | 187 // returns an empty Value. |
186 virtual base::Value* PipelineInfoToValue() const = 0; | 188 virtual base::Value* PipelineInfoToValue() const = 0; |
187 | 189 |
| 190 virtual const HostMappingRules* GetHostMappingRules() const = 0; |
| 191 |
188 // Static settings | 192 // Static settings |
189 | 193 |
190 // Reset all static settings to initialized values. Used to init test suite. | 194 // Reset all static settings to initialized values. Used to init test suite. |
191 static void ResetStaticSettingsToInit(); | 195 static void ResetStaticSettingsToInit(); |
192 | 196 |
193 static GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); | |
194 | |
195 // Turns spdy on or off. | 197 // Turns spdy on or off. |
196 static void set_spdy_enabled(bool value) { | 198 static void set_spdy_enabled(bool value) { |
197 spdy_enabled_ = value; | 199 spdy_enabled_ = value; |
198 if (!spdy_enabled_) { | 200 if (!spdy_enabled_) { |
199 delete next_protos_; | 201 delete next_protos_; |
200 next_protos_ = NULL; | 202 next_protos_ = NULL; |
201 } | 203 } |
202 } | 204 } |
203 static bool spdy_enabled() { return spdy_enabled_; } | 205 static bool spdy_enabled() { return spdy_enabled_; } |
204 | 206 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 static void EnableNpnSpdy3(); | 240 static void EnableNpnSpdy3(); |
239 | 241 |
240 // Sets the protocols supported by NPN (next protocol negotiation) during the | 242 // Sets the protocols supported by NPN (next protocol negotiation) during the |
241 // SSL handshake as well as by HTTP Alternate-Protocol. | 243 // SSL handshake as well as by HTTP Alternate-Protocol. |
242 static void SetNextProtos(const std::vector<std::string>& value); | 244 static void SetNextProtos(const std::vector<std::string>& value); |
243 static bool has_next_protos() { return next_protos_ != NULL; } | 245 static bool has_next_protos() { return next_protos_ != NULL; } |
244 static const std::vector<std::string>& next_protos() { | 246 static const std::vector<std::string>& next_protos() { |
245 return *next_protos_; | 247 return *next_protos_; |
246 } | 248 } |
247 | 249 |
248 // Sets the HttpStreamFactoryImpl into a mode where it can ignore certificate | |
249 // errors. This is for testing. | |
250 static void set_ignore_certificate_errors(bool value) { | |
251 ignore_certificate_errors_ = value; | |
252 } | |
253 static bool ignore_certificate_errors() { | |
254 return ignore_certificate_errors_; | |
255 } | |
256 | |
257 static void SetHostMappingRules(const std::string& rules); | |
258 | |
259 static void set_http_pipelining_enabled(bool value) { | |
260 http_pipelining_enabled_ = value; | |
261 } | |
262 static bool http_pipelining_enabled() { return http_pipelining_enabled_; } | |
263 | |
264 static void set_testing_fixed_http_port(int port) { | |
265 testing_fixed_http_port_ = port; | |
266 } | |
267 static uint16 testing_fixed_http_port() { return testing_fixed_http_port_; } | |
268 | |
269 static void set_testing_fixed_https_port(int port) { | |
270 testing_fixed_https_port_ = port; | |
271 } | |
272 static uint16 testing_fixed_https_port() { return testing_fixed_https_port_; } | |
273 | |
274 protected: | 250 protected: |
275 HttpStreamFactory(); | 251 HttpStreamFactory(); |
276 | 252 |
277 private: | 253 private: |
278 static const HostMappingRules& host_mapping_rules(); | |
279 | |
280 static const HostMappingRules* host_mapping_rules_; | |
281 static std::vector<std::string>* next_protos_; | 254 static std::vector<std::string>* next_protos_; |
282 static bool enabled_protocols_[NUM_ALTERNATE_PROTOCOLS]; | 255 static bool enabled_protocols_[NUM_ALTERNATE_PROTOCOLS]; |
283 static bool spdy_enabled_; | 256 static bool spdy_enabled_; |
284 static bool use_alternate_protocols_; | 257 static bool use_alternate_protocols_; |
285 static bool force_spdy_over_ssl_; | 258 static bool force_spdy_over_ssl_; |
286 static bool force_spdy_always_; | 259 static bool force_spdy_always_; |
287 static std::list<HostPortPair>* forced_spdy_exclusions_; | 260 static std::list<HostPortPair>* forced_spdy_exclusions_; |
288 static bool ignore_certificate_errors_; | |
289 static bool http_pipelining_enabled_; | |
290 static uint16 testing_fixed_http_port_; | |
291 static uint16 testing_fixed_https_port_; | |
292 | 261 |
293 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); | 262 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); |
294 }; | 263 }; |
295 | 264 |
296 } // namespace net | 265 } // namespace net |
297 | 266 |
298 #endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ | 267 #endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ |
OLD | NEW |