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 |
55 private: | 66 protected: |
67 // Used in unittests. | |
56 class Request; | 68 class Request; |
mmenke
2013/06/13 17:59:56
nit: Is this used in the unit tests?
yhirano
2013/06/14 04:11:25
Reverted.
| |
57 class Job; | 69 class Job; |
58 | 70 |
71 // Invoked when an orphaned Job finishes. | |
72 // virtual for testing. | |
73 virtual void OnOrphanedJobComplete(const Job* job); | |
mmenke
2013/06/13 17:59:56
If you follow my other comment, these may not be n
yhirano
2013/06/14 04:11:25
Done.
| |
74 | |
75 private: | |
59 typedef std::set<Request*> RequestSet; | 76 typedef std::set<Request*> RequestSet; |
60 typedef std::vector<Request*> RequestVector; | 77 typedef std::vector<Request*> RequestVector; |
61 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; | 78 typedef std::map<SpdySessionKey, RequestSet> SpdySessionRequestMap; |
62 typedef std::map<HttpPipelinedHost::Key, | 79 typedef std::map<HttpPipelinedHost::Key, |
63 RequestVector> HttpPipeliningRequestMap; | 80 RequestVector> HttpPipeliningRequestMap; |
64 | 81 |
82 HttpStreamRequest* RequestStreamInternal( | |
83 const HttpRequestInfo& info, | |
84 RequestPriority priority, | |
85 const SSLConfig& server_ssl_config, | |
86 const SSLConfig& proxy_ssl_config, | |
87 HttpStreamRequest::Delegate* delegate, | |
88 WebSocketStreamBase::Factory* factory, | |
89 const BoundNetLog& net_log); | |
90 | |
65 PortAlternateProtocolPair GetAlternateProtocolRequestFor( | 91 PortAlternateProtocolPair GetAlternateProtocolRequestFor( |
66 const GURL& original_url, | 92 const GURL& original_url, |
67 GURL* alternate_url) const; | 93 GURL* alternate_url) const; |
68 | 94 |
69 // Detaches |job| from |request|. | 95 // Detaches |job| from |request|. |
70 void OrphanJob(Job* job, const Request* request); | 96 void OrphanJob(Job* job, const Request* request); |
71 | 97 |
72 // Called when a SpdySession is ready. It will find appropriate Requests and | 98 // Called when a SpdySession is ready. It will find appropriate Requests and |
73 // fulfill them. |direct| indicates whether or not |spdy_session| uses a | 99 // fulfill them. |direct| indicates whether or not |spdy_session| uses a |
74 // proxy. | 100 // proxy. |
75 void OnSpdySessionReady(scoped_refptr<SpdySession> spdy_session, | 101 void OnNewSpdySessionReady(scoped_refptr<SpdySession> spdy_session, |
76 bool direct, | 102 bool direct, |
77 const SSLConfig& used_ssl_config, | 103 const SSLConfig& used_ssl_config, |
78 const ProxyInfo& used_proxy_info, | 104 const ProxyInfo& used_proxy_info, |
79 bool was_npn_negotiated, | 105 bool was_npn_negotiated, |
80 NextProto protocol_negotiated, | 106 NextProto protocol_negotiated, |
81 bool using_spdy, | 107 bool using_spdy, |
82 const BoundNetLog& net_log); | 108 const BoundNetLog& net_log); |
83 | 109 |
84 // Called when the Job detects that the endpoint indicated by the | 110 // Called when the Job detects that the endpoint indicated by the |
85 // Alternate-Protocol does not work. Lets the factory update | 111 // Alternate-Protocol does not work. Lets the factory update |
86 // HttpAlternateProtocols with the failure and resets the SPDY session key. | 112 // HttpAlternateProtocols with the failure and resets the SPDY session key. |
87 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); | 113 void OnBrokenAlternateProtocol(const Job*, const HostPortPair& origin); |
88 | 114 |
89 // Invoked when an orphaned Job finishes. | |
90 void OnOrphanedJobComplete(const Job* job); | |
91 | |
92 // Invoked when the Job finishes preconnecting sockets. | 115 // Invoked when the Job finishes preconnecting sockets. |
93 void OnPreconnectsComplete(const Job* job); | 116 void OnPreconnectsComplete(const Job* job); |
94 | 117 |
95 // Called when the Preconnect completes. Used for testing. | 118 // Called when the Preconnect completes. Used for testing. |
96 virtual void OnPreconnectsCompleteInternal() {} | 119 virtual void OnPreconnectsCompleteInternal() {} |
97 | 120 |
98 void AbortPipelinedRequestsWithKey(const Job* job, | 121 void AbortPipelinedRequestsWithKey(const Job* job, |
99 const HttpPipelinedHost::Key& key, | 122 const HttpPipelinedHost::Key& key, |
100 int status, | 123 int status, |
101 const SSLConfig& used_ssl_config); | 124 const SSLConfig& used_ssl_config); |
(...skipping 15 matching lines...) Expand all Loading... | |
117 // not be canceled when Requests are canceled. Therefore, in | 140 // not be canceled when Requests are canceled. Therefore, in |
118 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this | 141 // ~HttpStreamFactoryImpl, it is possible for some jobs to still exist in this |
119 // set. Leftover jobs will be deleted when the factory is destroyed. | 142 // set. Leftover jobs will be deleted when the factory is destroyed. |
120 std::set<const Job*> orphaned_job_set_; | 143 std::set<const Job*> orphaned_job_set_; |
121 | 144 |
122 // These jobs correspond to preconnect requests and have no associated Request | 145 // These jobs correspond to preconnect requests and have no associated Request |
123 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be | 146 // object. They're owned by HttpStreamFactoryImpl. Leftover jobs will be |
124 // deleted when the factory is destroyed. | 147 // deleted when the factory is destroyed. |
125 std::set<const Job*> preconnect_job_set_; | 148 std::set<const Job*> preconnect_job_set_; |
126 | 149 |
150 const bool for_websockets_; | |
127 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); | 151 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImpl); |
128 }; | 152 }; |
129 | 153 |
130 } // namespace net | 154 } // namespace net |
131 | 155 |
132 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ | 156 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |
OLD | NEW |