| 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> | |
| 11 | 10 |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 15 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 16 #include "net/base/load_states.h" | 15 #include "net/base/load_states.h" |
| 17 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 18 #include "net/base/request_priority.h" | 17 #include "net/base/request_priority.h" |
| 19 #include "net/http/http_server_properties.h" | 18 #include "net/http/http_server_properties.h" |
| 20 #include "net/socket/ssl_client_socket.h" | |
| 21 // This file can be included from net/http even though | 19 // This file can be included from net/http even though |
| 22 // it is in net/websockets because it doesn't | 20 // it is in net/websockets because it doesn't |
| 23 // introduce any link dependency to net/websockets. | 21 // introduce any link dependency to net/websockets. |
| 24 #include "net/websockets/websocket_handshake_stream_base.h" | 22 #include "net/websockets/websocket_handshake_stream_base.h" |
| 25 | 23 |
| 26 class GURL; | 24 class GURL; |
| 27 | 25 |
| 28 namespace base { | 26 namespace base { |
| 29 class Value; | 27 class Value; |
| 30 } | 28 } |
| 31 | 29 |
| 32 namespace net { | 30 namespace net { |
| 33 | 31 |
| 34 class AuthCredentials; | 32 class AuthCredentials; |
| 35 class BoundNetLog; | 33 class BoundNetLog; |
| 36 class HostMappingRules; | 34 class HostMappingRules; |
| 37 class HostPortPair; | 35 class HostPortPair; |
| 38 class HttpAuthController; | 36 class HttpAuthController; |
| 37 class HttpNetworkSession; |
| 39 class HttpResponseInfo; | 38 class HttpResponseInfo; |
| 40 class HttpServerProperties; | 39 class HttpServerProperties; |
| 41 class HttpStreamBase; | 40 class HttpStreamBase; |
| 42 class ProxyInfo; | 41 class ProxyInfo; |
| 43 class SSLCertRequestInfo; | 42 class SSLCertRequestInfo; |
| 44 class SSLInfo; | 43 class SSLInfo; |
| 45 struct HttpRequestInfo; | 44 struct HttpRequestInfo; |
| 46 struct SSLConfig; | 45 struct SSLConfig; |
| 47 | 46 |
| 48 // The HttpStreamRequest is the client's handle to the worker object which | 47 // The HttpStreamRequest is the client's handle to the worker object which |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 }; | 173 }; |
| 175 | 174 |
| 176 // The HttpStreamFactory defines an interface for creating usable HttpStreams. | 175 // The HttpStreamFactory defines an interface for creating usable HttpStreams. |
| 177 class NET_EXPORT HttpStreamFactory { | 176 class NET_EXPORT HttpStreamFactory { |
| 178 public: | 177 public: |
| 179 virtual ~HttpStreamFactory(); | 178 virtual ~HttpStreamFactory(); |
| 180 | 179 |
| 181 void ProcessAlternateProtocol( | 180 void ProcessAlternateProtocol( |
| 182 const base::WeakPtr<HttpServerProperties>& http_server_properties, | 181 const base::WeakPtr<HttpServerProperties>& http_server_properties, |
| 183 const std::string& alternate_protocol_str, | 182 const std::string& alternate_protocol_str, |
| 184 const HostPortPair& http_host_port_pair); | 183 const HostPortPair& http_host_port_pair, |
| 184 const HttpNetworkSession& session); |
| 185 | 185 |
| 186 GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); | 186 GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); |
| 187 | 187 |
| 188 // Virtual interface methods. | 188 // Virtual interface methods. |
| 189 | 189 |
| 190 // Request a stream. | 190 // Request a stream. |
| 191 // Will call delegate->OnStreamReady on successful completion. | 191 // Will call delegate->OnStreamReady on successful completion. |
| 192 virtual HttpStreamRequest* RequestStream( | 192 virtual HttpStreamRequest* RequestStream( |
| 193 const HttpRequestInfo& info, | 193 const HttpRequestInfo& info, |
| 194 RequestPriority priority, | 194 RequestPriority priority, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 222 virtual base::Value* PipelineInfoToValue() const = 0; | 222 virtual base::Value* PipelineInfoToValue() const = 0; |
| 223 | 223 |
| 224 virtual const HostMappingRules* GetHostMappingRules() const = 0; | 224 virtual const HostMappingRules* GetHostMappingRules() const = 0; |
| 225 | 225 |
| 226 // Static settings | 226 // Static settings |
| 227 | 227 |
| 228 // Reset all static settings to initialized values. Used to init test suite. | 228 // Reset all static settings to initialized values. Used to init test suite. |
| 229 static void ResetStaticSettingsToInit(); | 229 static void ResetStaticSettingsToInit(); |
| 230 | 230 |
| 231 // Turns spdy on or off. | 231 // Turns spdy on or off. |
| 232 // TODO(mmenke): Figure out if this can be made a property of the |
| 233 // HttpNetworkSession. |
| 232 static void set_spdy_enabled(bool value) { | 234 static void set_spdy_enabled(bool value) { |
| 233 spdy_enabled_ = value; | 235 spdy_enabled_ = value; |
| 234 if (!spdy_enabled_) { | |
| 235 delete next_protos_; | |
| 236 next_protos_ = NULL; | |
| 237 } | |
| 238 } | 236 } |
| 239 static bool spdy_enabled() { return spdy_enabled_; } | 237 static bool spdy_enabled() { return spdy_enabled_; } |
| 240 | 238 |
| 241 // Controls whether or not we use the Alternate-Protocol header. | |
| 242 static void set_use_alternate_protocols(bool value) { | |
| 243 use_alternate_protocols_ = value; | |
| 244 } | |
| 245 static bool use_alternate_protocols() { return use_alternate_protocols_; } | |
| 246 | |
| 247 // Controls whether or not we use ssl when in spdy mode. | |
| 248 static void set_force_spdy_over_ssl(bool value) { | |
| 249 force_spdy_over_ssl_ = value; | |
| 250 } | |
| 251 static bool force_spdy_over_ssl() { | |
| 252 return force_spdy_over_ssl_; | |
| 253 } | |
| 254 | |
| 255 // Controls whether or not we use spdy without npn. | |
| 256 static void set_force_spdy_always(bool value) { | |
| 257 force_spdy_always_ = value; | |
| 258 } | |
| 259 static bool force_spdy_always() { return force_spdy_always_; } | |
| 260 | |
| 261 // Add a URL to exclude from forced SPDY. | |
| 262 static void add_forced_spdy_exclusion(const std::string& value); | |
| 263 // Check if a HostPortPair is excluded from using spdy. | |
| 264 static bool HasSpdyExclusion(const HostPortPair& endpoint); | |
| 265 | |
| 266 // Sets http/1.1 as the only protocol supported via NPN or Alternate-Protocol. | |
| 267 static void EnableNpnHttpOnly(); | |
| 268 | |
| 269 // Sets http/1.1, quic, and spdy/3 as the protocols supported via | |
| 270 // NPN or Alternate-Protocol. | |
| 271 static void EnableNpnSpdy3(); | |
| 272 | |
| 273 // Sets http/1.1, quic, spdy/3, and spdy/3.1 as the protocols | |
| 274 // supported via NPN or Alternate-Protocol. | |
| 275 static void EnableNpnSpdy31(); | |
| 276 | |
| 277 // Sets http/1.1, quic, spdy/2, spdy/3, and spdy/3.1 as the | |
| 278 // protocols supported via NPN or Alternate-Protocol. | |
| 279 static void EnableNpnSpdy31WithSpdy2(); | |
| 280 | |
| 281 // Sets http/1.1, quic, spdy/3, spdy/3.1, and spdy/4 (http/2) as the | |
| 282 // protocols supported via NPN or Alternate-Protocol. | |
| 283 static void EnableNpnSpdy4Http2(); | |
| 284 | |
| 285 // Sets the protocols supported by NPN (next protocol negotiation) during the | |
| 286 // SSL handshake as well as by HTTP Alternate-Protocol. | |
| 287 static void SetNextProtos(const std::vector<NextProto>& value); | |
| 288 static bool has_next_protos() { return next_protos_ != NULL; } | |
| 289 static const std::vector<std::string>& next_protos() { | |
| 290 return *next_protos_; | |
| 291 } | |
| 292 | |
| 293 protected: | 239 protected: |
| 294 HttpStreamFactory(); | 240 HttpStreamFactory(); |
| 295 | 241 |
| 296 private: | 242 private: |
| 297 // |protocol| must be a valid protocol value. | |
| 298 static bool IsProtocolEnabled(AlternateProtocol protocol); | |
| 299 static void SetProtocolEnabled(AlternateProtocol protocol); | |
| 300 static void ResetEnabledProtocols(); | |
| 301 | |
| 302 static std::vector<std::string>* next_protos_; | |
| 303 static bool enabled_protocols_[NUM_VALID_ALTERNATE_PROTOCOLS]; | |
| 304 static bool spdy_enabled_; | 243 static bool spdy_enabled_; |
| 305 static bool use_alternate_protocols_; | |
| 306 static bool force_spdy_over_ssl_; | |
| 307 static bool force_spdy_always_; | |
| 308 static std::list<HostPortPair>* forced_spdy_exclusions_; | |
| 309 | 244 |
| 310 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); | 245 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); |
| 311 }; | 246 }; |
| 312 | 247 |
| 313 } // namespace net | 248 } // namespace net |
| 314 | 249 |
| 315 #endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ | 250 #endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ |
| OLD | NEW |