| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_IMPL_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "net/base/host_port_pair.h" | 12 #include "net/base/host_port_pair.h" |
| 13 #include "net/base/net_log.h" |
| 13 #include "net/http/http_stream_factory.h" | 14 #include "net/http/http_stream_factory.h" |
| 14 #include "net/base/net_log.h" | |
| 15 #include "net/proxy/proxy_server.h" | 15 #include "net/proxy/proxy_server.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 class HttpNetworkSession; | 19 class HttpNetworkSession; |
| 20 class HttpPipelinedHost; |
| 20 class SpdySession; | 21 class SpdySession; |
| 21 | 22 |
| 22 class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { | 23 class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : public HttpStreamFactory { |
| 23 public: | 24 public: |
| 24 explicit HttpStreamFactoryImpl(HttpNetworkSession* session); | 25 explicit HttpStreamFactoryImpl(HttpNetworkSession* session); |
| 25 virtual ~HttpStreamFactoryImpl(); | 26 virtual ~HttpStreamFactoryImpl(); |
| 26 | 27 |
| 27 // HttpStreamFactory Interface | 28 // HttpStreamFactory Interface |
| 28 virtual HttpStreamRequest* RequestStream( | 29 virtual HttpStreamRequest* RequestStream( |
| 29 const HttpRequestInfo& info, | 30 const HttpRequestInfo& info, |
| 30 const SSLConfig& ssl_config, | 31 const SSLConfig& ssl_config, |
| 31 HttpStreamRequest::Delegate* delegate, | 32 HttpStreamRequest::Delegate* delegate, |
| 32 const BoundNetLog& net_log); | 33 const BoundNetLog& net_log); |
| 33 | 34 |
| 34 virtual void PreconnectStreams(int num_streams, | 35 virtual void PreconnectStreams(int num_streams, |
| 35 const HttpRequestInfo& info, | 36 const HttpRequestInfo& info, |
| 36 const SSLConfig& ssl_config, | 37 const SSLConfig& ssl_config, |
| 37 const BoundNetLog& net_log); | 38 const BoundNetLog& net_log); |
| 38 virtual void AddTLSIntolerantServer(const HostPortPair& server); | 39 virtual void AddTLSIntolerantServer(const HostPortPair& server); |
| 39 virtual bool IsTLSIntolerantServer(const HostPortPair& server) const; | 40 virtual bool IsTLSIntolerantServer(const HostPortPair& server) const; |
| 40 | 41 |
| 42 virtual void OnHttpPipelinedHostHasAdditionalCapacity( |
| 43 HttpPipelinedHost* host); |
| 44 |
| 41 private: | 45 private: |
| 42 class Request; | 46 class Request; |
| 43 class Job; | 47 class Job; |
| 44 | 48 |
| 45 typedef std::set<Request*> RequestSet; | 49 typedef std::set<Request*> RequestSet; |
| 46 typedef std::map<HostPortProxyPair, RequestSet> SpdySessionRequestMap; | 50 typedef std::map<HostPortProxyPair, RequestSet> SpdySessionRequestMap; |
| 51 typedef std::map<HostPortPair, RequestSet> HttpPipeliningRequestMap; |
| 47 | 52 |
| 48 bool GetAlternateProtocolRequestFor(const GURL& original_url, | 53 bool GetAlternateProtocolRequestFor(const GURL& original_url, |
| 49 GURL* alternate_url) const; | 54 GURL* alternate_url) const; |
| 50 | 55 |
| 51 // Detaches |job| from |request|. | 56 // Detaches |job| from |request|. |
| 52 void OrphanJob(Job* job, const Request* request); | 57 void OrphanJob(Job* job, const Request* request); |
| 53 | 58 |
| 54 // Called when a SpdySession is ready. It will find appropriate Requests and | 59 // Called when a SpdySession is ready. It will find appropriate Requests and |
| 55 // fulfill them. |direct| indicates whether or not |spdy_session| uses a | 60 // fulfill them. |direct| indicates whether or not |spdy_session| uses a |
| 56 // proxy. | 61 // proxy. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 79 HttpNetworkSession* const session_; | 84 HttpNetworkSession* const session_; |
| 80 | 85 |
| 81 std::set<HostPortPair> tls_intolerant_servers_; | 86 std::set<HostPortPair> tls_intolerant_servers_; |
| 82 | 87 |
| 83 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl | 88 // All Requests are handed out to clients. By the time HttpStreamFactoryImpl |
| 84 // is destroyed, all Requests should be deleted (which should remove them from | 89 // is destroyed, all Requests should be deleted (which should remove them from |
| 85 // |request_map_|. The Requests will delete the corresponding job. | 90 // |request_map_|. The Requests will delete the corresponding job. |
| 86 std::map<const Job*, Request*> request_map_; | 91 std::map<const Job*, Request*> request_map_; |
| 87 | 92 |
| 88 SpdySessionRequestMap spdy_session_request_map_; | 93 SpdySessionRequestMap spdy_session_request_map_; |
| 94 HttpPipeliningRequestMap http_pipelining_request_map_; |
| 89 | 95 |
| 90 // These jobs correspond to jobs orphaned by Requests and now owned by | 96 // These jobs correspond to jobs orphaned by Requests and now owned by |
| 91 // HttpStreamFactoryImpl. Since they are no longer tied to Requests, they will | 97 // HttpStreamFactoryImpl. Since they are no longer tied to Requests, they will |
| 92 // not be canceled when Requests are canceled. Therefore, in | 98 // not be canceled when Requests are canceled. Therefore, in |
| 93 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this | 99 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this |
| 94 // set. Leftover jobs will be deleted when the factory is destroyed. | 100 // set. Leftover jobs will be deleted when the factory is destroyed. |
| 95 std::set<const Job*> orphaned_job_set_; | 101 std::set<const Job*> orphaned_job_set_; |
| 96 | 102 |
| 97 // These jobs correspond to preconnect requests and have no associated Request | 103 // These jobs correspond to preconnect requests and have no associated Request |
| 98 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be | 104 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be |
| 99 // deleted when the factory is destroyed. | 105 // deleted when the factory is destroyed. |
| 100 std::set<const Job*> preconnect_job_set_; | 106 std::set<const Job*> preconnect_job_set_; |
| 101 | 107 |
| 102 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); | 108 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 } // namespace net | 111 } // namespace net |
| 106 | 112 |
| 107 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 113 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
| OLD | NEW |