Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_CONTROLLER_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "net/http/http_stream_factory_impl.h" | 8 #include "net/http/http_stream_factory_impl.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 // Called when |request_| is destructed. | 43 // Called when |request_| is destructed. |
| 44 // Job(s) associated with but not bound to |request_| will be deleted. | 44 // Job(s) associated with but not bound to |request_| will be deleted. |
| 45 // |request_| and |bound_job_| will be nulled if ever set. | 45 // |request_| and |bound_job_| will be nulled if ever set. |
| 46 void OnRequestComplete(); | 46 void OnRequestComplete(); |
| 47 | 47 |
| 48 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials); | 48 int RestartTunnelWithProxyAuth(const AuthCredentials& credentials); |
| 49 | 49 |
| 50 void SetPriority(RequestPriority priority); | 50 void SetPriority(RequestPriority priority); |
| 51 | 51 |
| 52 // Methods below are called by HttpStreamFactoryImpl::Job only. | 52 // Methods below are called by HttpStreamFactoryImpl::Job only |
| 53 void OnStreamReady(Job* job, | 53 void OnStreamReady(Job* job, |
| 54 const SSLConfig& used_ssl_config, | 54 const SSLConfig& used_ssl_config, |
| 55 const ProxyInfo& used_proxy_info); | 55 const ProxyInfo& used_proxy_info); |
| 56 void OnBidirectionalStreamImplReady(Job* job, | 56 void OnBidirectionalStreamImplReady(Job* job, |
| 57 const SSLConfig& used_ssl_config, | 57 const SSLConfig& used_ssl_config, |
| 58 const ProxyInfo& used_proxy_info); | 58 const ProxyInfo& used_proxy_info); |
| 59 void OnWebSocketHandshakeStreamReady(Job* job, | 59 void OnWebSocketHandshakeStreamReady(Job* job, |
| 60 const SSLConfig& used_ssl_config, | 60 const SSLConfig& used_ssl_config, |
| 61 const ProxyInfo& used_proxy_info, | 61 const ProxyInfo& used_proxy_info, |
| 62 WebSocketHandshakeStreamBase* stream); | 62 WebSocketHandshakeStreamBase* stream); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 | 106 |
| 107 // Called when |job| determines the appropriate |spdy_session_key| for the | 107 // Called when |job| determines the appropriate |spdy_session_key| for the |
| 108 // Request. Note that this does not mean that SPDY is necessarily supported | 108 // Request. Note that this does not mean that SPDY is necessarily supported |
| 109 // for this SpdySessionKey, since we may need to wait for NPN to complete | 109 // for this SpdySessionKey, since we may need to wait for NPN to complete |
| 110 // before knowing if SPDY is available. | 110 // before knowing if SPDY is available. |
| 111 void SetSpdySessionKey(Job* job, const SpdySessionKey& spdy_session_key); | 111 void SetSpdySessionKey(Job* job, const SpdySessionKey& spdy_session_key); |
| 112 | 112 |
| 113 // Remove session from the SpdySessionRequestMap. | 113 // Remove session from the SpdySessionRequestMap. |
| 114 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job); | 114 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job); |
| 115 | 115 |
| 116 void MaybeResumeOtherJob(Job* job, const base::TimeDelta& delay); | |
| 117 | |
| 118 void SetWaitTimeForMainJob(const base::TimeDelta& delay) { | |
| 119 wait_time_ = delay; | |
|
Ryan Hamilton
2016/05/17 22:14:09
nit: wait_time_for_main_job_ and set_wait_time_fo
Zhongyi Shi
2016/06/29 21:49:03
Done.
| |
| 120 } | |
| 121 | |
| 122 const base::TimeDelta& GetWaitTime() const { return wait_time_; } | |
| 123 | |
| 124 // Resume |job| with appropriate wait time. Return false if |job| has no | |
| 125 // blocking job and there's no wait time, i.e., |job| won't call | |
| 126 // Job::ResumeAfterDelay(). | |
| 127 bool ResumeJobWithDelay(Job* job) const; | |
| 128 | |
| 116 const BoundNetLog* GetNetLog(Job* job) const; | 129 const BoundNetLog* GetNetLog(Job* job) const; |
| 117 | 130 |
| 131 bool blocking() { return blocking_; } | |
| 132 | |
| 118 WebSocketHandshakeStreamBase::CreateHelper* | 133 WebSocketHandshakeStreamBase::CreateHelper* |
| 119 websocket_handshake_stream_create_helper(); | 134 websocket_handshake_stream_create_helper(); |
| 120 | 135 |
| 121 private: | 136 private: |
| 122 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); | 137 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, SetPriority); |
| 123 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 138 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 124 | 139 |
| 125 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. | 140 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. |
| 126 void CreateJobs(const HttpRequestInfo& request_info, | 141 void CreateJobs(const HttpRequestInfo& request_info, |
| 127 RequestPriority priority, | 142 RequestPriority priority, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 | 202 |
| 188 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a | 203 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a |
| 189 // connection. If |alternative_job_| is unable to do so, |this| will notify | 204 // connection. If |alternative_job_| is unable to do so, |this| will notify |
| 190 // |main_job_| to proceed and then race the two jobs. | 205 // |main_job_| to proceed and then race the two jobs. |
| 191 std::unique_ptr<Job> main_job_; | 206 std::unique_ptr<Job> main_job_; |
| 192 std::unique_ptr<Job> alternative_job_; | 207 std::unique_ptr<Job> alternative_job_; |
| 193 | 208 |
| 194 // True if a Job has ever been bound to the |request_|. | 209 // True if a Job has ever been bound to the |request_|. |
| 195 bool job_bound_; | 210 bool job_bound_; |
| 196 | 211 |
| 212 // True if the |main_job_| has to wait for |alternative_job_|; | |
| 213 bool blocking_; | |
|
Ryan Hamilton
2016/05/17 22:14:09
Can you expand this comment a bit? Under what circ
| |
| 214 base::TimeDelta wait_time_; | |
|
Ryan Hamilton
2016/05/17 22:14:09
Comment?
| |
| 215 | |
| 197 // At the point where a Job is irrevocably tied to |request_|, we set this. | 216 // At the point where a Job is irrevocably tied to |request_|, we set this. |
| 198 // It will be nulled when the |request_| is finished. | 217 // It will be nulled when the |request_| is finished. |
| 199 Job* bound_job_; | 218 Job* bound_job_; |
| 200 }; | 219 }; |
| 201 | 220 |
| 202 } // namespace net | 221 } // namespace net |
| 203 | 222 |
| 204 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ | 223 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| OLD | NEW |