diff options
author | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 05:56:38 +0000 |
---|---|---|
committer | mbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-19 05:56:38 +0000 |
commit | 8e6441caa3adedf373b8ff80bb1fb48caff81556 (patch) | |
tree | 4a37d2fe5aaa3aad04b01171feb04e329c7e0383 /net/http/http_stream_factory.h | |
parent | 33f275a2e2e703c58f514af8efe963e2e29792f9 (diff) | |
download | chromium_src-8e6441caa3adedf373b8ff80bb1fb48caff81556.zip chromium_src-8e6441caa3adedf373b8ff80bb1fb48caff81556.tar.gz chromium_src-8e6441caa3adedf373b8ff80bb1fb48caff81556.tar.bz2 |
Extract connection logic from HttpNetworkTransaction into a new
HttpStreamFactory. The HttpNetworkTransaction now deals exclusively with
streams rather than connections directly. This cut the size of HTN roughly in
in half.
The HttpNetworkTransaction is still responsible for all proxy and server
authentication functions. This is because the streams may come and go - we
could create a stream, have the server declare auth is needed, and then the
next attempt would be on a different stream. So Auth belongs on the HNT.
The HNT no longer has direct access to the connection itself; instead, it
only knows of an HttpStream.
The StreamRequest, however, is responsible for determining whether the
connection needs to use a proxy, whether AlternateProtocols are available, and
whether the connection should be SPDY or HTTP.
Other changes:
- moved some static configuration methods from HNT to HttpStreamFactory.
- added some methods to the HttpStream.
BUG=none
TEST=all
Review URL: http://codereview.chromium.org/3171002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream_factory.h')
-rw-r--r-- | net/http/http_stream_factory.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/net/http/http_stream_factory.h b/net/http/http_stream_factory.h new file mode 100644 index 0000000..bddac83 --- /dev/null +++ b/net/http/http_stream_factory.h @@ -0,0 +1,113 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_HTTP_HTTP_STREAM_FACTORY_H_ +#define NET_HTTP_HTTP_STREAM_FACTORY_H_ + +#include <set> +#include <string> + + +#include "base/scoped_ptr.h" +#include "net/base/completion_callback.h" +#include "net/base/host_mapping_rules.h" +#include "net/base/ssl_config_service.h" +#include "net/http/http_auth.h" +#include "net/http/http_auth_controller.h" +#include "net/http/stream_factory.h" +#include "net/proxy/proxy_service.h" +#include "net/socket/client_socket_handle.h" + + +namespace net { + +class ClientSocketHandle; +class HttpAuthController; +class HttpNetworkSession; +class HttpStreamRequest; + +class HttpStreamFactory : public StreamFactory, + public base::RefCounted<HttpStreamFactory> { + public: + HttpStreamFactory(); + virtual ~HttpStreamFactory(); + + // StreamFactory Interface + virtual void RequestStream(const HttpRequestInfo* info, + SSLConfig* ssl_config, + ProxyInfo* proxy_info, + StreamRequestDelegate* delegate, + const BoundNetLog& net_log, + const scoped_refptr<HttpNetworkSession>& session, + scoped_refptr<StreamRequestJob>* stream); + + // TLS Intolerant Server API + void AddTLSIntolerantServer(const GURL& url); + bool IsTLSIntolerantServer(const GURL& url); + + // Alternate Protocol API + void ProcessAlternateProtocol(HttpAlternateProtocols* alternate_protocols, + const std::string& alternate_protocol_str, + const HostPortPair& http_host_port_pair); + + // Host Mapping Rules API + GURL ApplyHostMappingRules(const GURL& url, HostPortPair* endpoint); + + // Static settings + + // Controls whether or not we use the Alternate-Protocol header. + static void set_use_alternate_protocols(bool value) { + use_alternate_protocols_ = value; + } + static bool use_alternate_protocols() { return use_alternate_protocols_; } + + // Controls whether or not we use ssl when in spdy mode. + static void set_force_spdy_over_ssl(bool value) { + force_spdy_over_ssl_ = value; + } + static bool force_spdy_over_ssl() { + return force_spdy_over_ssl_; + } + + // Controls whether or not we use spdy without npn. + static void set_force_spdy_always(bool value) { + force_spdy_always_ = value; + } + static bool force_spdy_always() { return force_spdy_always_; } + + // Sets the next protocol negotiation value used during the SSL handshake. + static void set_next_protos(const std::string& value) { + delete next_protos_; + next_protos_ = new std::string(value); + } + static const std::string* next_protos() { return next_protos_; } + + // Sets the HttpStreamFactory into a mode where it can ignore certificate + // errors. This is for testing. + static void set_ignore_certificate_errors(bool value) { + ignore_certificate_errors_ = value; + } + static bool ignore_certificate_errors() { + return ignore_certificate_errors_; + } + + static void SetHostMappingRules(const std::string& rules); + + private: + std::set<std::string> tls_intolerant_servers_; + + static const HostMappingRules* host_mapping_rules_; + static const std::string* next_protos_; + static bool use_alternate_protocols_; + static bool force_spdy_over_ssl_; + static bool force_spdy_always_; + static bool ignore_certificate_errors_; + + DISALLOW_COPY_AND_ASSIGN(HttpStreamFactory); +}; + +} // namespace net + +#endif // NET_HTTP_HTTP_STREAM_FACTORY_H_ + |