[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| 6 | #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | #include <set> |
| 10 | #include <string> |
| 11 | |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 12 | #include "base/ref_counted.h" |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 13 | #include "net/http/http_stream_factory.h" |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 14 | #include "net/proxy/proxy_server.h" |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 15 | |
| 16 | namespace net { |
| 17 | |
| 18 | class HttpNetworkSession; |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 19 | class SpdySession; |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 20 | |
| 21 | class HttpStreamFactoryImpl : public HttpStreamFactory { |
| 22 | public: |
| 23 | explicit HttpStreamFactoryImpl(HttpNetworkSession* session); |
| 24 | virtual ~HttpStreamFactoryImpl(); |
| 25 | |
| 26 | // HttpStreamFactory Interface |
| 27 | virtual HttpStreamRequest* RequestStream( |
| 28 | const HttpRequestInfo& info, |
| 29 | const SSLConfig& ssl_config, |
| 30 | HttpStreamRequest::Delegate* delegate, |
| 31 | const BoundNetLog& net_log); |
| 32 | |
| 33 | virtual void PreconnectStreams(int num_streams, |
| 34 | const HttpRequestInfo& info, |
| 35 | const SSLConfig& ssl_config, |
| 36 | const BoundNetLog& net_log); |
| 37 | virtual void AddTLSIntolerantServer(const GURL& url); |
| 38 | virtual bool IsTLSIntolerantServer(const GURL& url) const; |
| 39 | |
| 40 | private: |
| 41 | class Request; |
| 42 | class Job; |
| 43 | |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 44 | typedef std::set<Request*> RequestSet; |
| 45 | typedef std::map<HostPortProxyPair, RequestSet> SpdySessionRequestMap; |
| 46 | |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 47 | LoadState GetLoadState(const Request& request) const; |
| 48 | |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 49 | // Called when a SpdySession is ready. It will find appropriate Requests and |
| 50 | // fulfill them. |direct| indicates whether or not |spdy_session| uses a |
| 51 | // proxy. |
| 52 | void OnSpdySessionReady(const Job* job, |
| 53 | scoped_refptr<SpdySession> spdy_session, |
| 54 | bool direct); |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 55 | |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 56 | // Called when the Job detects that the endpoint indicated by the |
| 57 | // Alternate-Protocol does not work. Lets the factory update |
| 58 | // HttpAlternateProtocols with the failure and resets the SPDY session key. |
| 59 | void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); |
| 60 | |
| 61 | // Invoked when the Job finishes preconnecting sockets. |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 62 | void OnPreconnectsComplete(const Job* job); |
| 63 | |
| 64 | // Called when the Preconnect completes. Used for testing. |
| 65 | virtual void OnPreconnectsCompleteInternal() {} |
| 66 | |
| 67 | HttpNetworkSession* const session_; |
| 68 | |
| 69 | std::set<std::string> tls_intolerant_servers_; |
| 70 | |
| 71 | // All Requests are handed out to clients. By the time HttpStreamFactoryImpl |
| 72 | // is destroyed, all Requests should be deleted (which should remove them from |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 73 | // |request_map_|. The Requests will delete the corresponding job. |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 74 | std::map<const Job*, Request*> request_map_; |
| 75 | |
[email protected] | 7f28a8df | 2011-02-25 22:26:03 | [diff] [blame^] | 76 | SpdySessionRequestMap spdy_session_request_map_; |
| 77 | |
[email protected] | 102e27c | 2011-02-23 01:01:31 | [diff] [blame] | 78 | // These jobs correspond to preconnect requests and have no associated Request |
| 79 | // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be |
| 80 | // deleted when the factory is destroyed. |
| 81 | std::set<const Job*> preconnect_job_set_; |
| 82 | |
| 83 | DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
| 84 | }; |
| 85 | |
| 86 | } // namespace net |
| 87 | |
| 88 | #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |