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_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 #include <vector> | 10 #include <vector> |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 class HttpNetworkSession; | 23 class HttpNetworkSession; |
24 class HttpPipelinedHost; | 24 class HttpPipelinedHost; |
25 class SpdySession; | 25 class SpdySession; |
26 | 26 |
27 class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : | 27 class NET_EXPORT_PRIVATE HttpStreamFactoryImpl : |
28 public HttpStreamFactory, | 28 public HttpStreamFactory, |
29 public HttpPipelinedHostPool::Delegate { | 29 public HttpPipelinedHostPool::Delegate { |
30 public: | 30 public: |
31 explicit HttpStreamFactoryImpl(HttpNetworkSession* session); | 31 // RequestStream may only be called if |for_websockets| is false. |
| 32 // RequestWebSocketStream may only be called if |for_websockets| is true. |
| 33 HttpStreamFactoryImpl(HttpNetworkSession* session, bool for_websockets); |
32 virtual ~HttpStreamFactoryImpl(); | 34 virtual ~HttpStreamFactoryImpl(); |
33 | 35 |
34 // HttpStreamFactory interface | 36 // HttpStreamFactory interface |
35 virtual HttpStreamRequest* RequestStream( | 37 virtual HttpStreamRequest* RequestStream( |
36 const HttpRequestInfo& info, | 38 const HttpRequestInfo& info, |
37 RequestPriority priority, | 39 RequestPriority priority, |
38 const SSLConfig& server_ssl_config, | 40 const SSLConfig& server_ssl_config, |
39 const SSLConfig& proxy_ssl_config, | 41 const SSLConfig& proxy_ssl_config, |
40 HttpStreamRequest::Delegate* delegate, | 42 HttpStreamRequest::Delegate* delegate, |
41 const BoundNetLog& net_log) OVERRIDE; | 43 const BoundNetLog& net_log) OVERRIDE; |
42 | 44 |
| 45 virtual HttpStreamRequest* RequestWebSocketStream( |
| 46 const HttpRequestInfo& info, |
| 47 RequestPriority priority, |
| 48 const SSLConfig& server_ssl_config, |
| 49 const SSLConfig& proxy_ssl_config, |
| 50 HttpStreamRequest::Delegate* delegate, |
| 51 WebSocketStreamBase::Factory* factory, |
| 52 const BoundNetLog& net_log) OVERRIDE; |
| 53 |
43 virtual void PreconnectStreams(int num_streams, | 54 virtual void PreconnectStreams(int num_streams, |
44 const HttpRequestInfo& info, | 55 const HttpRequestInfo& info, |
45 RequestPriority priority, | 56 RequestPriority priority, |
46 const SSLConfig& server_ssl_config, | 57 const SSLConfig& server_ssl_config, |
47 const SSLConfig& proxy_ssl_config) OVERRIDE; | 58 const SSLConfig& proxy_ssl_config) OVERRIDE; |
48 virtual base::Value* PipelineInfoToValue() const OVERRIDE; | 59 virtual base::Value* PipelineInfoToValue() const OVERRIDE; |
49 virtual const HostMappingRules* GetHostMappingRules() const OVERRIDE; | 60 virtual const HostMappingRules* GetHostMappingRules() const OVERRIDE; |
50 | 61 |
51 // HttpPipelinedHostPool::Delegate interface | 62 // HttpPipelinedHostPool::Delegate interface |
52 virtual void OnHttpPipelinedHostHasAdditionalCapacity( | 63 virtual void OnHttpPipelinedHostHasAdditionalCapacity( |
53 HttpPipelinedHost* host) OVERRIDE; | 64 HttpPipelinedHost* host) OVERRIDE; |
54 | 65 |
| 66 size_t num_orphaned_jobs() const { return orphaned_job_set_.size(); } |
| 67 |
55 private: | 68 private: |
56 class Request; | 69 class Request; |
57 class Job; | 70 class Job; |
58 | 71 |
59 typedef std::set<Request*> RequestSet; | 72 typedef std::set<Request*> RequestSet; |
60 typedef std::vector<Request*> RequestVector; | 73 typedef std::vector<Request*> RequestVector; |
61 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; | 74 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; |
62 typedef std::map<HttpPipelinedHost::Key, | 75 typedef std::map<HttpPipelinedHost::Key, |
63 RequestVector> HttpPipeliningRequestMap; | 76 RequestVector> HttpPipeliningRequestMap; |
64 | 77 |
| 78 HttpStreamRequest* RequestStreamInternal( |
| 79 const HttpRequestInfo& info, |
| 80 RequestPriority priority, |
| 81 const SSLConfig& server_ssl_config, |
| 82 const SSLConfig& proxy_ssl_config, |
| 83 HttpStreamRequest::Delegate* delegate, |
| 84 WebSocketStreamBase::Factory* factory, |
| 85 const BoundNetLog& net_log); |
| 86 |
65 PortAlternateProtocolPair GetAlternateProtocolRequestFor( | 87 PortAlternateProtocolPair GetAlternateProtocolRequestFor( |
66 const GURL& original_url, | 88 const GURL& original_url, |
67 GURL* alternate_url) const; | 89 GURL* alternate_url) const; |
68 | 90 |
69 // Detaches |job| from |request|. | 91 // Detaches |job| from |request|. |
70 void OrphanJob(Job* job, const Request* request); | 92 void OrphanJob(Job* job, const Request* request); |
71 | 93 |
72 // Called when a SpdySession is ready. It will find appropriate Requests and | 94 // Called when a SpdySession is ready. It will find appropriate Requests and |
73 // fulfill them. |direct| indicates whether or not |spdy_session| uses a | 95 // fulfill them. |direct| indicates whether or not |spdy_session| uses a |
74 // proxy. | 96 // proxy. |
75 void OnSpdySessionReady(scoped_refptr<SpdySession> spdy_session, | 97 void OnNewSpdySessionReady(scoped_refptr<SpdySession> spdy_session, |
76 bool direct, | 98 bool direct, |
77 const SSLConfig& used_ssl_config, | 99 const SSLConfig& used_ssl_config, |
78 const ProxyInfo& used_proxy_info, | 100 const ProxyInfo& used_proxy_info, |
79 bool was_npn_negotiated, | 101 bool was_npn_negotiated, |
80 NextProto protocol_negotiated, | 102 NextProto protocol_negotiated, |
81 bool using_spdy, | 103 bool using_spdy, |
82 const BoundNetLog& net_log); | 104 const BoundNetLog& net_log); |
83 | 105 |
84 // Called when the Job detects that the endpoint indicated by the | 106 // Called when the Job detects that the endpoint indicated by the |
85 // Alternate-Protocol does not work. Lets the factory update | 107 // Alternate-Protocol does not work. Lets the factory update |
86 // HttpAlternateProtocols with the failure and resets the SPDY session key. | 108 // HttpAlternateProtocols with the failure and resets the SPDY session key. |
87 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); | 109 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); |
88 | 110 |
89 // Invoked when an orphaned Job finishes. | 111 // Invoked when an orphaned Job finishes. |
90 void OnOrphanedJobComplete(const Job* job); | 112 void OnOrphanedJobComplete(const Job* job); |
91 | 113 |
92 // Invoked when the Job finishes preconnecting sockets. | 114 // Invoked when the Job finishes preconnecting sockets. |
(...skipping 24 matching lines...) Expand all Loading... |
117 // not be canceled when Requests are canceled. Therefore, in | 139 // not be canceled when Requests are canceled. Therefore, in |
118 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this | 140 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this |
119 // set. Leftover jobs will be deleted when the factory is destroyed. | 141 // set. Leftover jobs will be deleted when the factory is destroyed. |
120 std::set<const Job*> orphaned_job_set_; | 142 std::set<const Job*> orphaned_job_set_; |
121 | 143 |
122 // These jobs correspond to preconnect requests and have no associated Request | 144 // These jobs correspond to preconnect requests and have no associated Request |
123 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be | 145 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be |
124 // deleted when the factory is destroyed. | 146 // deleted when the factory is destroyed. |
125 std::set<const Job*> preconnect_job_set_; | 147 std::set<const Job*> preconnect_job_set_; |
126 | 148 |
| 149 const bool for_websockets_; |
127 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); | 150 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
128 }; | 151 }; |
129 | 152 |
130 } // namespace net | 153 } // namespace net |
131 | 154 |
132 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 155 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
OLD | NEW |