diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 01:01:31 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-23 01:01:31 +0000 |
commit | 102e27c64d9deae4c32f346214fd7c2bddaa9fb3 (patch) | |
tree | d7372b853f79764c4ec200f4cd6d26c9bb512d65 /net/http/http_stream_factory_impl.h | |
parent | d7f21d5584fb4962617644833fd2a80b6d0c7e8d (diff) | |
download | chromium_src-102e27c64d9deae4c32f346214fd7c2bddaa9fb3.zip chromium_src-102e27c64d9deae4c32f346214fd7c2bddaa9fb3.tar.gz chromium_src-102e27c64d9deae4c32f346214fd7c2bddaa9fb3.tar.bz2 |
Refactor HttpStreamFactory.
Rename StreamFactory and StreamRequest to HttpStreamFactory and HttpStreamRequest.
Rename HttpStreamFactory to HttpStreamFactoryImpl.
Create HttpStreamFactoryImpl::Request (inherits from HttpStreamRequest) and HttpStreamFactoryImpl::Job (most of the old HttpStreamRequest code, other than the interface, moved here).
Currently there is still a strong binding within HttpStreamFactoryImpl between requests and jobs. This will be removed in a future changelist.
Note that due to the preparation for late binding, information like HttpRequestInfo and SSLConfig and ProxyInfo are just copied. It's possible we can consider refcounting them to reduce copies, but I think it's not worth the effort / ugliness.
I also did some minor cleanups like moving SpdySettingsStorage into SpdySessionPool and some CloseIdleConnections() cleanup.
BUG=54371,42669
TEST=unit tests
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=75668
Review URL: http://codereview.chromium.org/6543004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream_factory_impl.h')
-rw-r--r-- | net/http/http_stream_factory_impl.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/net/http/http_stream_factory_impl.h b/net/http/http_stream_factory_impl.h new file mode 100644 index 0000000..d86a8fa --- /dev/null +++ b/net/http/http_stream_factory_impl.h @@ -0,0 +1,94 @@ +// 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_IMPL_H_ +#define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ + +#include <map> +#include <set> +#include <string> + +#include "net/http/http_stream_factory.h" + +namespace net { + +class HttpNetworkSession; + +class HttpStreamFactoryImpl : public HttpStreamFactory { + public: + explicit HttpStreamFactoryImpl(HttpNetworkSession* session); + virtual ~HttpStreamFactoryImpl(); + + // HttpStreamFactory Interface + virtual HttpStreamRequest* RequestStream( + const HttpRequestInfo& info, + const SSLConfig& ssl_config, + HttpStreamRequest::Delegate* delegate, + const BoundNetLog& net_log); + + virtual void PreconnectStreams(int num_streams, + const HttpRequestInfo& info, + const SSLConfig& ssl_config, + const BoundNetLog& net_log); + virtual void AddTLSIntolerantServer(const GURL& url); + virtual bool IsTLSIntolerantServer(const GURL& url) const; + + private: + class Request; + class Job; + + LoadState GetLoadState(const Request& request) const; + + void OnStreamReady(const Job* job, + const SSLConfig& ssl_config, + const ProxyInfo& proxy_info, + HttpStream* stream); + void OnStreamFailed(const Job* job, int result, const SSLConfig& ssl_config); + void OnCertificateError(const Job* job, + int result, + const SSLConfig& ssl_config, + const SSLInfo& ssl_info); + void OnNeedsProxyAuth(const Job* job, + const HttpResponseInfo& response_info, + const SSLConfig& ssl_config, + const ProxyInfo& proxy_info, + HttpAuthController* auth_controller); + void OnNeedsClientAuth(const Job* job, + const SSLConfig& ssl_config, + SSLCertRequestInfo* cert_info); + void OnHttpsProxyTunnelResponse(const Job* job, + const HttpResponseInfo& response_info, + const SSLConfig& ssl_config, + const ProxyInfo& proxy_info, + HttpStream* stream); + + void OnPreconnectsComplete(const Job* job); + + // Called when the Preconnect completes. Used for testing. + virtual void OnPreconnectsCompleteInternal() {} + + HttpNetworkSession* const session_; + + std::set<std::string> tls_intolerant_servers_; + + // All Requests are handed out to clients. By the time HttpStreamFactoryImpl + // is destroyed, all Requests should be deleted (which should remove them from + // |request_map_|. + // TODO(willchan): Change to a different key when we enable late binding. This + // is the key part that keeps things tightly bound. + // Note that currently the Request assumes ownership of the Job. We will break + // this with late binding, and the factory will own the Job. + std::map<const Job*, Request*> request_map_; + + // These jobs correspond to preconnect requests and have no associated Request + // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be + // deleted when the factory is destroyed. + std::set<const Job*> preconnect_job_set_; + + DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); +}; + +} // namespace net + +#endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |