Chromium Code Reviews| Index: net/http/http_stream_factory_impl_job.h |
| diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h |
| index 01dd6271eee2e3baef8b1424b620560a1d018ec1..67e8efec974fac7ce878264231553a041073bb39 100644 |
| --- a/net/http/http_stream_factory_impl_job.h |
| +++ b/net/http/http_stream_factory_impl_job.h |
| @@ -116,6 +116,13 @@ class HttpStreamFactoryImpl::Job { |
| Job* job, |
| const ConnectionAttempts& attempts) = 0; |
| + // Invoked when |job| finishes initiating a connection. |
| + virtual void OnConnectionInitialized(Job* job, int rv) = 0; |
| + |
| + // Return false if |job| can advance to the next state. Otherwise, |job| |
| + // will wait for Job::OnIOComplete() to be called before advancing. |
|
Ryan Hamilton
2016/07/12 00:21:45
Resume() not OnIOComplete(), right?
Zhongyi Shi
2016/07/12 23:03:12
Done.
|
| + virtual bool ShouldWait(Job* job) = 0; |
| + |
| // Called when |job| determines the appropriate |spdy_session_key| for the |
| // Request. Note that this does not mean that SPDY is necessarily supported |
| // for this SpdySessionKey, since we may need to wait for NPN to complete |
| @@ -131,6 +138,8 @@ class HttpStreamFactoryImpl::Job { |
| virtual WebSocketHandshakeStreamBase::CreateHelper* |
| websocket_handshake_stream_create_helper() = 0; |
| + virtual void SetWaitTimeForMainJob(const base::TimeDelta& delay) = 0; |
| + |
| virtual bool for_websockets() = 0; |
| }; |
| @@ -175,14 +184,9 @@ class HttpStreamFactoryImpl::Job { |
| int RestartTunnelWithProxyAuth(const AuthCredentials& credentials); |
| LoadState GetLoadState() const; |
| - // Tells |this| to wait for |job| to resume it. |
| - void WaitFor(Job* job); |
| - |
| - // Tells |this| that |job| has determined it still needs to continue |
| - // connecting, so allow |this| to continue after the specified |delay|. If |
| - // this is not called, then |request_| is expected to cancel |this| by |
| - // deleting it. |
| - void Resume(Job* job, const base::TimeDelta& delay); |
| + // Tells |this| that |delegate_| has determined it still needs to continue |
| + // connecting. |
| + virtual void Resume(); |
| // Called to detach |this| Job. May resume the other Job, will disconnect |
| // the socket for |this| Job, and notify |delegate| upon completion. |
| @@ -205,6 +209,7 @@ class HttpStreamFactoryImpl::Job { |
| return std::move(bidirectional_stream_impl_); |
| } |
| + bool is_waiting() const { return next_state_ == STATE_WAIT_COMPLETE; } |
| const SSLConfig& server_ssl_config() const; |
| const SSLConfig& proxy_ssl_config() const; |
| const ProxyInfo& proxy_info() const; |
| @@ -219,7 +224,7 @@ class HttpStreamFactoryImpl::Job { |
| JobType job_type() const { return job_type_; } |
| private: |
| - FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| + friend class HttpStreamFactoryImplJobPeer; |
| enum State { |
| STATE_START, |
| @@ -243,8 +248,8 @@ class HttpStreamFactoryImpl::Job { |
| // existing SpdySession. In that case, the http and npn-spdy jobs will race. |
| // When QUIC protocol is used by the npn-spdy job, then http job will wait |
| // for |wait_time_| when the http job was resumed. |
| - STATE_WAIT_FOR_JOB, |
| - STATE_WAIT_FOR_JOB_COMPLETE, |
| + STATE_WAIT, |
| + STATE_WAIT_COMPLETE, |
| STATE_INIT_CONNECTION, |
| STATE_INIT_CONNECTION_COMPLETE, |
| @@ -311,9 +316,6 @@ class HttpStreamFactoryImpl::Job { |
| const bool is_spdy_alternative_; |
| }; |
| - // Resume the |this| job after the specified |wait_time_|. |
| - void ResumeAfterDelay(); |
| - |
| void OnStreamReadyCallback(); |
| void OnBidirectionalStreamImplReadyCallback(); |
| void OnWebSocketHandshakeStreamReadyCallback(); |
| @@ -332,6 +334,7 @@ class HttpStreamFactoryImpl::Job { |
| int RunLoop(int result); |
| int DoLoop(int result); |
| int StartInternal(); |
| + int DoInitConnectionImpl(); |
| // Each of these methods corresponds to a State value. Those with an input |
| // argument receive the result from the previous state. If a method returns |
| @@ -340,8 +343,8 @@ class HttpStreamFactoryImpl::Job { |
| int DoStart(); |
| int DoResolveProxy(); |
| int DoResolveProxyComplete(int result); |
| - int DoWaitForJob(); |
| - int DoWaitForJobComplete(int result); |
| + int DoWait(); |
| + int DoWaitComplete(int result); |
| int DoInitConnection(); |
| int DoInitConnectionComplete(int result); |
| int DoWaitingUserAction(int result); |
| @@ -457,17 +460,6 @@ class HttpStreamFactoryImpl::Job { |
| JobType job_type_; |
| - // This is the Job we're dependent on. It will notify us if/when it's OK to |
| - // proceed. |
| - Job* blocking_job_; |
| - |
| - // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. |
| - // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to |
| - // proceed and then race the two Jobs. |
| - Job* waiting_job_; |
| - |
| - base::TimeDelta wait_time_; |
| - |
| // True if handling a HTTPS request, or using SPDY with SSL |
| bool using_ssl_; |