| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // resumes the main job. | 267 // resumes the main job. |
| 263 // | 268 // |
| 264 // A QUIC alternative job notifies the JobController in DoInitConnection | 269 // A QUIC alternative job notifies the JobController in DoInitConnection |
| 265 // regardless of whether it pools to an existing QUIC session, but the main | 270 // regardless of whether it pools to an existing QUIC session, but the main |
| 266 // job is only resumed after some delay. | 271 // job is only resumed after some delay. |
| 267 // | 272 // |
| 268 // If the main job is resumed, then it races the alternative job. | 273 // If the main job is resumed, then it races the alternative job. |
| 269 STATE_WAIT, | 274 STATE_WAIT, |
| 270 STATE_WAIT_COMPLETE, | 275 STATE_WAIT_COMPLETE, |
| 271 | 276 |
| 277 STATE_EVALUATE_THROTTLE, |
| 272 STATE_INIT_CONNECTION, | 278 STATE_INIT_CONNECTION, |
| 273 STATE_INIT_CONNECTION_COMPLETE, | 279 STATE_INIT_CONNECTION_COMPLETE, |
| 274 STATE_WAITING_USER_ACTION, | 280 STATE_WAITING_USER_ACTION, |
| 275 STATE_RESTART_TUNNEL_AUTH, | 281 STATE_RESTART_TUNNEL_AUTH, |
| 276 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 282 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
| 277 STATE_CREATE_STREAM, | 283 STATE_CREATE_STREAM, |
| 278 STATE_CREATE_STREAM_COMPLETE, | 284 STATE_CREATE_STREAM_COMPLETE, |
| 279 STATE_DRAIN_BODY_FOR_AUTH_RESTART, | 285 STATE_DRAIN_BODY_FOR_AUTH_RESTART, |
| 280 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, | 286 STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE, |
| 281 STATE_DONE, | 287 STATE_DONE, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 306 int StartInternal(); | 312 int StartInternal(); |
| 307 int DoInitConnectionImpl(); | 313 int DoInitConnectionImpl(); |
| 308 | 314 |
| 309 // Each of these methods corresponds to a State value. Those with an input | 315 // Each of these methods corresponds to a State value. Those with an input |
| 310 // argument receive the result from the previous state. If a method returns | 316 // argument receive the result from the previous state. If a method returns |
| 311 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the | 317 // ERR_IO_PENDING, then the result from OnIOComplete will be passed to the |
| 312 // next state method as the result arg. | 318 // next state method as the result arg. |
| 313 int DoStart(); | 319 int DoStart(); |
| 314 int DoWait(); | 320 int DoWait(); |
| 315 int DoWaitComplete(int result); | 321 int DoWaitComplete(int result); |
| 322 int DoEvaluateThrottle(); |
| 316 int DoInitConnection(); | 323 int DoInitConnection(); |
| 317 int DoInitConnectionComplete(int result); | 324 int DoInitConnectionComplete(int result); |
| 318 int DoWaitingUserAction(int result); | 325 int DoWaitingUserAction(int result); |
| 319 int DoCreateStream(); | 326 int DoCreateStream(); |
| 320 int DoCreateStreamComplete(int result); | 327 int DoCreateStreamComplete(int result); |
| 321 int DoRestartTunnelAuth(); | 328 int DoRestartTunnelAuth(); |
| 322 int DoRestartTunnelAuthComplete(int result); | 329 int DoRestartTunnelAuthComplete(int result); |
| 323 | 330 |
| 331 void ResumeInitConnection(); |
| 324 // Creates a SpdyHttpStream or a BidirectionalStreamImpl from the given values | 332 // Creates a SpdyHttpStream or a BidirectionalStreamImpl from the given values |
| 325 // and sets to |stream_| or |bidirectional_stream_impl_| respectively. Does | 333 // and sets to |stream_| or |bidirectional_stream_impl_| respectively. Does |
| 326 // nothing if |stream_factory_| is for WebSockets. | 334 // nothing if |stream_factory_| is for WebSockets. |
| 327 int SetSpdyHttpStreamOrBidirectionalStreamImpl( | 335 int SetSpdyHttpStreamOrBidirectionalStreamImpl( |
| 328 base::WeakPtr<SpdySession> session, | 336 base::WeakPtr<SpdySession> session, |
| 329 bool direct); | 337 bool direct); |
| 330 | 338 |
| 331 // Returns to STATE_INIT_CONNECTION and resets some state. | 339 // Returns to STATE_INIT_CONNECTION and resets some state. |
| 332 void ReturnToStateInitConnection(bool close_connection); | 340 void ReturnToStateInitConnection(bool close_connection); |
| 333 | 341 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // True if not connecting to an Https proxy for an Http url. | 481 // True if not connecting to an Https proxy for an Http url. |
| 474 const bool spdy_session_direct_; | 482 const bool spdy_session_direct_; |
| 475 | 483 |
| 476 const SpdySessionKey spdy_session_key_; | 484 const SpdySessionKey spdy_session_key_; |
| 477 | 485 |
| 478 base::TimeTicks job_stream_ready_start_time_; | 486 base::TimeTicks job_stream_ready_start_time_; |
| 479 | 487 |
| 480 // Type of stream that is requested. | 488 // Type of stream that is requested. |
| 481 HttpStreamRequest::StreamType stream_type_; | 489 HttpStreamRequest::StreamType stream_type_; |
| 482 | 490 |
| 491 // Whether Job has continued to DoInitConnection(). |
| 492 bool init_connection_already_resumed_; |
| 493 |
| 483 base::WeakPtrFactory<Job> ptr_factory_; | 494 base::WeakPtrFactory<Job> ptr_factory_; |
| 484 | 495 |
| 485 DISALLOW_COPY_AND_ASSIGN(Job); | 496 DISALLOW_COPY_AND_ASSIGN(Job); |
| 486 }; | 497 }; |
| 487 | 498 |
| 488 // Factory for creating Jobs. | 499 // Factory for creating Jobs. |
| 489 class HttpStreamFactoryImpl::JobFactory { | 500 class HttpStreamFactoryImpl::JobFactory { |
| 490 public: | 501 public: |
| 491 JobFactory(); | 502 JobFactory(); |
| 492 | 503 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 HostPortPair destination, | 544 HostPortPair destination, |
| 534 GURL origin_url, | 545 GURL origin_url, |
| 535 const ProxyServer& alternative_proxy_server, | 546 const ProxyServer& alternative_proxy_server, |
| 536 bool enable_ip_based_pooling, | 547 bool enable_ip_based_pooling, |
| 537 NetLog* net_log); | 548 NetLog* net_log); |
| 538 }; | 549 }; |
| 539 | 550 |
| 540 } // namespace net | 551 } // namespace net |
| 541 | 552 |
| 542 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 553 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
| OLD | NEW |