| 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 <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class HttpNetworkSession; | 38 class HttpNetworkSession; |
| 39 class HttpStream; | 39 class HttpStream; |
| 40 class SpdySessionPool; | 40 class SpdySessionPool; |
| 41 class NetLog; | 41 class NetLog; |
| 42 struct SSLConfig; | 42 struct SSLConfig; |
| 43 | 43 |
| 44 // An HttpStreamRequestImpl exists for each stream which is in progress of being | 44 // An HttpStreamRequestImpl exists for each stream which is in progress of being |
| 45 // created for the StreamFactory. | 45 // created for the StreamFactory. |
| 46 class HttpStreamFactoryImpl::Job { | 46 class HttpStreamFactoryImpl::Job { |
| 47 public: | 47 public: |
| 48 // For jobs issued simultaneously to an HTTP/2 supported server, a delay is |
| 49 // applied to avoid unnecessary socket connection establishments. |
| 50 // crbug.com/718576 |
| 51 static const int kHTTP2ThrottleMs = 300; |
| 52 |
| 48 // Delegate to report Job's status to Request and HttpStreamFactory. | 53 // Delegate to report Job's status to Request and HttpStreamFactory. |
| 49 class NET_EXPORT_PRIVATE Delegate { | 54 class NET_EXPORT_PRIVATE Delegate { |
| 50 public: | 55 public: |
| 51 virtual ~Delegate() {} | 56 virtual ~Delegate() {} |
| 52 | 57 |
| 53 // Invoked when |job| has an HttpStream ready. | 58 // Invoked when |job| has an HttpStream ready. |
| 54 virtual void OnStreamReady(Job* job, const SSLConfig& used_ssl_config) = 0; | 59 virtual void OnStreamReady(Job* job, const SSLConfig& used_ssl_config) = 0; |
| 55 | 60 |
| 56 // Invoked when |job| has a BidirectionalStream ready. | 61 // Invoked when |job| has a BidirectionalStream ready. |
| 57 virtual void OnBidirectionalStreamImplReady( | 62 virtual void OnBidirectionalStreamImplReady( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // resumes the main job. | 262 // resumes the main job. |
| 258 // | 263 // |
| 259 // A QUIC alternative job notifies the JobController in DoInitConnection | 264 // A QUIC alternative job notifies the JobController in DoInitConnection |
| 260 // regardless of whether it pools to an existing QUIC session, but the main | 265 // regardless of whether it pools to an existing QUIC session, but the main |
| 261 // job is only resumed after some delay. | 266 // job is only resumed after some delay. |
| 262 // | 267 // |
| 263 // If the main job is resumed, then it races the alternative job. | 268 // If the main job is resumed, then it races the alternative job. |
| 264 STATE_WAIT, | 269 STATE_WAIT, |
| 265 STATE_WAIT_COMPLETE, | 270 STATE_WAIT_COMPLETE, |
| 266 | 271 |
| 272 STATE_EVALUATE_THROTTLE, |
| 267 STATE_INIT_CONNECTION, | 273 STATE_INIT_CONNECTION, |
| 268 STATE_INIT_CONNECTION_COMPLETE, | 274 STATE_INIT_CONNECTION_COMPLETE, |
| 269 STATE_WAITING_USER_ACTION, | 275 STATE_WAITING_USER_ACTION, |
| 270 STATE_RESTART_TUNNEL_AUTH, | 276 STATE_RESTART_TUNNEL_AUTH, |
| 271 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 277 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
| 272 STATE_CREATE_STREAM, | 278 STATE_CREATE_STREAM, |
| 273 STATE_CREATE_STREAM_COMPLETE, | 279 STATE_CREATE_STREAM_COMPLETE, |
| 274 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | 280 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
| 275 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | 281 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
| 276 STATE_DONE, | 282 STATE_DONE, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 301 int StartInternal(); | 307 int StartInternal(); |
| 302 int DoInitConnectionImpl(); | 308 int DoInitConnectionImpl(); |
| 303 | 309 |
| 304 // Each of these methods corresponds to a State value. Those with an input | 310 // Each of these methods corresponds to a State value. Those with an input |
| 305 // argument receive the result from the previous state. If a method returns | 311 // argument receive the result from the previous state. If a method returns |
| 306 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 312 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
| 307 // next state method as the result arg. | 313 // next state method as the result arg. |
| 308 int DoStart(); | 314 int DoStart(); |
| 309 int DoWait(); | 315 int DoWait(); |
| 310 int DoWaitComplete(int result); | 316 int DoWaitComplete(int result); |
| 317 int DoEvaluateThrottle(); |
| 311 int DoInitConnection(); | 318 int DoInitConnection(); |
| 312 int DoInitConnectionComplete(int result); | 319 int DoInitConnectionComplete(int result); |
| 313 int DoWaitingUserAction(int result); | 320 int DoWaitingUserAction(int result); |
| 314 int DoCreateStream(); | 321 int DoCreateStream(); |
| 315 int DoCreateStreamComplete(int result); | 322 int DoCreateStreamComplete(int result); |
| 316 int DoRestartTunnelAuth(); | 323 int DoRestartTunnelAuth(); |
| 317 int DoRestartTunnelAuthComplete(int result); | 324 int DoRestartTunnelAuthComplete(int result); |
| 318 | 325 |
| 326 void ResumeInitConnection(); |
| 319 // Creates a SpdyHttpStream or a BidirectionalStreamImpl from the given values | 327 // Creates a SpdyHttpStream or a BidirectionalStreamImpl from the given values |
| 320 // and sets to |stream_| or |bidirectional_stream_impl_| respectively. Does | 328 // and sets to |stream_| or |bidirectional_stream_impl_| respectively. Does |
| 321 // nothing if |stream_factory_| is for WebSockets. | 329 // nothing if |stream_factory_| is for WebSockets. |
| 322 int SetSpdyHttpStreamOrBidirectionalStreamImpl( | 330 int SetSpdyHttpStreamOrBidirectionalStreamImpl( |
| 323 base::WeakPtr<SpdySession> session, | 331 base::WeakPtr<SpdySession> session, |
| 324 bool direct); | 332 bool direct); |
| 325 | 333 |
| 326 // Returns to STATE_INIT_CONNECTION and resets some state. | 334 // Returns to STATE_INIT_CONNECTION and resets some state. |
| 327 void ReturnToStateInitConnection(bool close_connection); | 335 void ReturnToStateInitConnection(bool close_connection); |
| 328 | 336 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 // True if not connecting to an Https proxy for an Http url. | 480 // True if not connecting to an Https proxy for an Http url. |
| 473 const bool spdy_session_direct_; | 481 const bool spdy_session_direct_; |
| 474 | 482 |
| 475 const SpdySessionKey spdy_session_key_; | 483 const SpdySessionKey spdy_session_key_; |
| 476 | 484 |
| 477 base::TimeTicks job_stream_ready_start_time_; | 485 base::TimeTicks job_stream_ready_start_time_; |
| 478 | 486 |
| 479 // Type of stream that is requested. | 487 // Type of stream that is requested. |
| 480 HttpStreamRequest::StreamType stream_type_; | 488 HttpStreamRequest::StreamType stream_type_; |
| 481 | 489 |
| 490 // Whether Job has continued to DoInitConnection(). |
| 491 bool init_connection_already_resumed_; |
| 492 |
| 482 base::WeakPtrFactory<Job> ptr_factory_; | 493 base::WeakPtrFactory<Job> ptr_factory_; |
| 483 | 494 |
| 484 DISALLOW_COPY_AND_ASSIGN(Job); | 495 DISALLOW_COPY_AND_ASSIGN(Job); |
| 485 }; | 496 }; |
| 486 | 497 |
| 487 // Factory for creating Jobs. | 498 // Factory for creating Jobs. |
| 488 class HttpStreamFactoryImpl::JobFactory { | 499 class HttpStreamFactoryImpl::JobFactory { |
| 489 public: | 500 public: |
| 490 JobFactory(); | 501 JobFactory(); |
| 491 | 502 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 HostPortPair destination, | 543 HostPortPair destination, |
| 533 GURL origin_url, | 544 GURL origin_url, |
| 534 const ProxyServer& alternative_proxy_server, | 545 const ProxyServer& alternative_proxy_server, |
| 535 bool enable_ip_based_pooling, | 546 bool enable_ip_based_pooling, |
| 536 NetLog* net_log); | 547 NetLog* net_log); |
| 537 }; | 548 }; |
| 538 | 549 |
| 539 } // namespace net | 550 } // namespace net |
| 540 | 551 |
| 541 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 552 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
| OLD | NEW |