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_JOB_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/request_priority.h" | 14 #include "net/base/request_priority.h" |
15 #include "net/http/http_auth.h" | 15 #include "net/http/http_auth.h" |
16 #include "net/http/http_auth_controller.h" | 16 #include "net/http/http_auth_controller.h" |
17 #include "net/http/http_request_info.h" | 17 #include "net/http/http_request_info.h" |
18 #include "net/http/http_stream_factory_impl.h" | 18 #include "net/http/http_stream_factory_impl.h" |
19 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
20 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
21 #include "net/quic/quic_stream_factory.h" | 21 #include "net/quic/quic_stream_factory.h" |
22 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
23 #include "net/socket/client_socket_pool_manager.h" | 23 #include "net/socket/client_socket_pool_manager.h" |
24 #include "net/socket/ssl_client_socket.h" | 24 #include "net/socket/ssl_client_socket.h" |
25 #include "net/spdy/spdy_session_key.h" | 25 #include "net/spdy/spdy_session_key.h" |
26 #include "net/ssl/ssl_config_service.h" | 26 #include "net/ssl/ssl_config_service.h" |
27 | 27 |
28 namespace net { | 28 namespace net { |
29 | 29 |
| 30 class BidirectionalStreamJob; |
30 class ClientSocketHandle; | 31 class ClientSocketHandle; |
31 class HttpAuthController; | 32 class HttpAuthController; |
32 class HttpNetworkSession; | 33 class HttpNetworkSession; |
33 class HttpStream; | 34 class HttpStream; |
34 class SpdySessionPool; | 35 class SpdySessionPool; |
35 class QuicHttpStream; | 36 class QuicHttpStream; |
36 | 37 |
37 // An HttpStreamRequestImpl exists for each stream which is in progress of being | 38 // An HttpStreamRequestImpl exists for each stream which is in progress of being |
38 // created for the StreamFactory. | 39 // created for the StreamFactory. |
39 class HttpStreamFactoryImpl::Job { | 40 class HttpStreamFactoryImpl::Job { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Used to detach the Job from |request|. | 81 // Used to detach the Job from |request|. |
81 void Orphan(const Request* request); | 82 void Orphan(const Request* request); |
82 | 83 |
83 void SetPriority(RequestPriority priority); | 84 void SetPriority(RequestPriority priority); |
84 | 85 |
85 RequestPriority priority() const { return priority_; } | 86 RequestPriority priority() const { return priority_; } |
86 bool was_npn_negotiated() const; | 87 bool was_npn_negotiated() const; |
87 NextProto protocol_negotiated() const; | 88 NextProto protocol_negotiated() const; |
88 bool using_spdy() const; | 89 bool using_spdy() const; |
89 const BoundNetLog& net_log() const { return net_log_; } | 90 const BoundNetLog& net_log() const { return net_log_; } |
| 91 bool for_bidirectional() const { return for_bidirectional_; } |
90 | 92 |
91 const SSLConfig& server_ssl_config() const; | 93 const SSLConfig& server_ssl_config() const; |
92 const SSLConfig& proxy_ssl_config() const; | 94 const SSLConfig& proxy_ssl_config() const; |
93 const ProxyInfo& proxy_info() const; | 95 const ProxyInfo& proxy_info() const; |
94 | 96 |
95 // Indicates whether or not this job is performing a preconnect. | 97 // Indicates whether or not this job is performing a preconnect. |
96 bool IsPreconnecting() const; | 98 bool IsPreconnecting() const; |
97 | 99 |
98 // Indicates whether or not this Job has been orphaned by a Request. | 100 // Indicates whether or not this Job has been orphaned by a Request. |
99 bool IsOrphaned() const; | 101 bool IsOrphaned() const; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Returns appropriate error code otherwise. | 190 // Returns appropriate error code otherwise. |
189 int CheckAlternativeServiceValidityForOrigin( | 191 int CheckAlternativeServiceValidityForOrigin( |
190 base::WeakPtr<SpdySession> spdy_session); | 192 base::WeakPtr<SpdySession> spdy_session); |
191 | 193 |
192 SpdySessionPool* const spdy_session_pool_; | 194 SpdySessionPool* const spdy_session_pool_; |
193 const GURL origin_url_; | 195 const GURL origin_url_; |
194 const bool is_spdy_alternative_; | 196 const bool is_spdy_alternative_; |
195 }; | 197 }; |
196 | 198 |
197 void OnStreamReadyCallback(); | 199 void OnStreamReadyCallback(); |
| 200 void OnBidirectionalStreamJobReadyCallback(); |
198 void OnWebSocketHandshakeStreamReadyCallback(); | 201 void OnWebSocketHandshakeStreamReadyCallback(); |
199 // This callback function is called when a new SPDY session is created. | 202 // This callback function is called when a new SPDY session is created. |
200 void OnNewSpdySessionReadyCallback(); | 203 void OnNewSpdySessionReadyCallback(); |
201 void OnStreamFailedCallback(int result); | 204 void OnStreamFailedCallback(int result); |
202 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); | 205 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); |
203 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, | 206 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, |
204 HttpAuthController* auth_controller); | 207 HttpAuthController* auth_controller); |
205 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); | 208 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); |
206 void OnHttpsProxyTunnelResponseCallback(const HttpResponseInfo& response_info, | 209 void OnHttpsProxyTunnelResponseCallback(const HttpResponseInfo& response_info, |
207 HttpStream* stream); | 210 HttpStream* stream); |
(...skipping 14 matching lines...) Expand all Loading... |
222 int DoWaitForJob(); | 225 int DoWaitForJob(); |
223 int DoWaitForJobComplete(int result); | 226 int DoWaitForJobComplete(int result); |
224 int DoInitConnection(); | 227 int DoInitConnection(); |
225 int DoInitConnectionComplete(int result); | 228 int DoInitConnectionComplete(int result); |
226 int DoWaitingUserAction(int result); | 229 int DoWaitingUserAction(int result); |
227 int DoCreateStream(); | 230 int DoCreateStream(); |
228 int DoCreateStreamComplete(int result); | 231 int DoCreateStreamComplete(int result); |
229 int DoRestartTunnelAuth(); | 232 int DoRestartTunnelAuth(); |
230 int DoRestartTunnelAuthComplete(int result); | 233 int DoRestartTunnelAuthComplete(int result); |
231 | 234 |
232 // Creates a SpdyHttpStream from the given values and sets to |stream_|. Does | 235 // Creates a SpdyHttpStream or a BidirectionalStreamJob from the given values |
| 236 // and sets to |stream_| or |bidirectional_stream_job_| respectively. Does |
233 // nothing if |stream_factory_| is for WebSockets. | 237 // nothing if |stream_factory_| is for WebSockets. |
234 int SetSpdyHttpStream(base::WeakPtr<SpdySession> session, bool direct); | 238 int SetSpdyHttpStreamOrBidirectionalStreamJob( |
| 239 base::WeakPtr<SpdySession> session, |
| 240 bool direct); |
235 | 241 |
236 // Returns to STATE_INIT_CONNECTION and resets some state. | 242 // Returns to STATE_INIT_CONNECTION and resets some state. |
237 void ReturnToStateInitConnection(bool close_connection); | 243 void ReturnToStateInitConnection(bool close_connection); |
238 | 244 |
239 // Set the motivation for this request onto the underlying socket. | 245 // Set the motivation for this request onto the underlying socket. |
240 void SetSocketMotivation(); | 246 void SetSocketMotivation(); |
241 | 247 |
242 bool IsHttpsProxyAndHttpUrl() const; | 248 bool IsHttpsProxyAndHttpUrl() const; |
243 | 249 |
244 // Is this a SPDY or QUIC alternative Job? | 250 // Is this a SPDY or QUIC alternative Job? |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 368 |
363 scoped_refptr<HttpAuthController> | 369 scoped_refptr<HttpAuthController> |
364 auth_controllers_[HttpAuth::AUTH_NUM_TARGETS]; | 370 auth_controllers_[HttpAuth::AUTH_NUM_TARGETS]; |
365 | 371 |
366 // True when the tunnel is in the process of being established - we can't | 372 // True when the tunnel is in the process of being established - we can't |
367 // read from the socket until the tunnel is done. | 373 // read from the socket until the tunnel is done. |
368 bool establishing_tunnel_; | 374 bool establishing_tunnel_; |
369 | 375 |
370 scoped_ptr<HttpStream> stream_; | 376 scoped_ptr<HttpStream> stream_; |
371 scoped_ptr<WebSocketHandshakeStreamBase> websocket_stream_; | 377 scoped_ptr<WebSocketHandshakeStreamBase> websocket_stream_; |
| 378 scoped_ptr<BidirectionalStreamJob> bidirectional_stream_job_; |
372 | 379 |
373 // True if we negotiated NPN. | 380 // True if we negotiated NPN. |
374 bool was_npn_negotiated_; | 381 bool was_npn_negotiated_; |
375 | 382 |
376 // Protocol negotiated with the server. | 383 // Protocol negotiated with the server. |
377 NextProto protocol_negotiated_; | 384 NextProto protocol_negotiated_; |
378 | 385 |
379 // 0 if we're not preconnecting. Otherwise, the number of streams to | 386 // 0 if we're not preconnecting. Otherwise, the number of streams to |
380 // preconnect. | 387 // preconnect. |
381 int num_streams_; | 388 int num_streams_; |
382 | 389 |
383 scoped_ptr<ValidSpdySessionPool> valid_spdy_session_pool_; | 390 scoped_ptr<ValidSpdySessionPool> valid_spdy_session_pool_; |
384 | 391 |
385 // Initialized when we create a new SpdySession. | 392 // Initialized when we create a new SpdySession. |
386 base::WeakPtr<SpdySession> new_spdy_session_; | 393 base::WeakPtr<SpdySession> new_spdy_session_; |
387 | 394 |
388 // Initialized when we have an existing SpdySession. | 395 // Initialized when we have an existing SpdySession. |
389 base::WeakPtr<SpdySession> existing_spdy_session_; | 396 base::WeakPtr<SpdySession> existing_spdy_session_; |
390 | 397 |
391 // Only used if |new_spdy_session_| is non-NULL. | 398 // Only used if |new_spdy_session_| is non-NULL. |
392 bool spdy_session_direct_; | 399 bool spdy_session_direct_; |
393 | 400 |
394 JobStatus job_status_; | 401 JobStatus job_status_; |
395 JobStatus other_job_status_; | 402 JobStatus other_job_status_; |
396 | 403 |
| 404 // True if BidirectionalStreamJob is requested. |
| 405 bool for_bidirectional_; |
| 406 |
397 base::WeakPtrFactory<Job> ptr_factory_; | 407 base::WeakPtrFactory<Job> ptr_factory_; |
398 | 408 |
399 DISALLOW_COPY_AND_ASSIGN(Job); | 409 DISALLOW_COPY_AND_ASSIGN(Job); |
400 }; | 410 }; |
401 | 411 |
402 } // namespace net | 412 } // namespace net |
403 | 413 |
404 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 414 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
OLD | NEW |