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_job.h" | 8 #include "net/http/http_stream_factory_impl_job.h" |
| 9 #include "net/http/http_stream_factory_impl_request.h" | 9 #include "net/http/http_stream_factory_impl_request.h" |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 | 126 |
| 127 // Invoked when the |job| finishes pre-connecting sockets. | 127 // Invoked when the |job| finishes pre-connecting sockets. |
| 128 void OnPreconnectsComplete(Job* job) override; | 128 void OnPreconnectsComplete(Job* job) override; |
| 129 | 129 |
| 130 // Invoked to record connection attempts made by the socket layer to | 130 // Invoked to record connection attempts made by the socket layer to |
| 131 // Request if |job| is associated with Request. | 131 // Request if |job| is associated with Request. |
| 132 void AddConnectionAttemptsToRequest( | 132 void AddConnectionAttemptsToRequest( |
| 133 Job* job, | 133 Job* job, |
| 134 const ConnectionAttempts& attempts) override; | 134 const ConnectionAttempts& attempts) override; |
| 135 | 135 |
| 136 // Invoked to resume the main job when |job| initiates a connection but | |
| 137 // does not succeed. | |
| 138 void OnInitConnectionNotSuccessful(Job* job, | |
| 139 const base::TimeDelta& delay) override; | |
| 140 | |
| 141 // Return false if |job| has no blocking job and there's no wait time, | |
| 142 // i.e., |job| won't call Job::ResumeAfterDelay(). Else true and resume | |
| 143 // |job| with appropriate wait time. | |
| 144 bool ShoudWait(Job* job) const override; | |
| 145 | |
| 136 // Called when |job| determines the appropriate |spdy_session_key| for the | 146 // Called when |job| determines the appropriate |spdy_session_key| for the |
| 137 // Request. Note that this does not mean that SPDY is necessarily supported | 147 // Request. Note that this does not mean that SPDY is necessarily supported |
| 138 // for this SpdySessionKey, since we may need to wait for NPN to complete | 148 // for this SpdySessionKey, since we may need to wait for NPN to complete |
| 139 // before knowing if SPDY is available. | 149 // before knowing if SPDY is available. |
| 140 void SetSpdySessionKey(Job* job, | 150 void SetSpdySessionKey(Job* job, |
| 141 const SpdySessionKey& spdy_session_key) override; | 151 const SpdySessionKey& spdy_session_key) override; |
| 142 | 152 |
| 143 // Remove session from the SpdySessionRequestMap. | 153 // Remove session from the SpdySessionRequestMap. |
| 144 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job) override; | 154 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job) override; |
| 145 const BoundNetLog* GetNetLog(Job* job) const override; | 155 const BoundNetLog* GetNetLog(Job* job) const override; |
| 156 | |
| 157 const base::TimeDelta& wait_time_for_main_job() const override; | |
| 158 void set_wait_time_for_main_job(const base::TimeDelta& delay) override; | |
| 159 bool blocking() override; | |
| 160 | |
| 146 WebSocketHandshakeStreamBase::CreateHelper* | 161 WebSocketHandshakeStreamBase::CreateHelper* |
| 147 websocket_handshake_stream_create_helper() override; | 162 websocket_handshake_stream_create_helper() override; |
| 148 | 163 |
| 149 private: | 164 private: |
| 150 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 165 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 151 | 166 |
| 152 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. | 167 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. |
| 153 void CreateJobs(const HttpRequestInfo& request_info, | 168 void CreateJobs(const HttpRequestInfo& request_info, |
| 154 RequestPriority priority, | 169 RequestPriority priority, |
| 155 const SSLConfig& server_ssl_config, | 170 const SSLConfig& server_ssl_config, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 177 // Called when a Job succeeds. | 192 // Called when a Job succeeds. |
| 178 void OnJobSucceeded(Job* job); | 193 void OnJobSucceeded(Job* job); |
| 179 | 194 |
| 180 // Marks completion of the |request_|. | 195 // Marks completion of the |request_|. |
| 181 void MarkRequestComplete(bool was_npn_negotiated, | 196 void MarkRequestComplete(bool was_npn_negotiated, |
| 182 NextProto protocol_negotiated, | 197 NextProto protocol_negotiated, |
| 183 bool using_spdy); | 198 bool using_spdy); |
| 184 | 199 |
| 185 void MaybeNotifyFactoryOfCompletion(); | 200 void MaybeNotifyFactoryOfCompletion(); |
| 186 | 201 |
| 202 // Called to resume the alternative job. | |
| 203 void MaybeResumeOtherJob(Job* job, const base::TimeDelta& delay); | |
|
Ryan Hamilton
2016/06/29 23:12:28
I think this can only resume the *main* job, right
Zhongyi Shi
2016/06/30 22:53:39
Urgh, right! it should resume the main job only!
| |
| 204 | |
| 187 // Returns true if QUIC is whitelisted for |host|. | 205 // Returns true if QUIC is whitelisted for |host|. |
| 188 bool IsQuicWhitelistedForHost(const std::string& host); | 206 bool IsQuicWhitelistedForHost(const std::string& host); |
| 189 | 207 |
| 190 AlternativeService GetAlternativeServiceFor( | 208 AlternativeService GetAlternativeServiceFor( |
| 191 const HttpRequestInfo& request_info, | 209 const HttpRequestInfo& request_info, |
| 192 HttpStreamRequest::Delegate* delegate, | 210 HttpStreamRequest::Delegate* delegate, |
| 193 HttpStreamRequest::StreamType stream_type); | 211 HttpStreamRequest::StreamType stream_type); |
| 194 | 212 |
| 195 AlternativeService GetAlternativeServiceForInternal( | 213 AlternativeService GetAlternativeServiceForInternal( |
| 196 const HttpRequestInfo& request_info, | 214 const HttpRequestInfo& request_info, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 217 | 235 |
| 218 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a | 236 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a |
| 219 // connection. If |alternative_job_| is unable to do so, |this| will notify | 237 // connection. If |alternative_job_| is unable to do so, |this| will notify |
| 220 // |main_job_| to proceed and then race the two jobs. | 238 // |main_job_| to proceed and then race the two jobs. |
| 221 std::unique_ptr<Job> main_job_; | 239 std::unique_ptr<Job> main_job_; |
| 222 std::unique_ptr<Job> alternative_job_; | 240 std::unique_ptr<Job> alternative_job_; |
| 223 | 241 |
| 224 // True if a Job has ever been bound to the |request_|. | 242 // True if a Job has ever been bound to the |request_|. |
| 225 bool job_bound_; | 243 bool job_bound_; |
| 226 | 244 |
| 245 // True if the |main_job_| has to wait for |alternative_job_|; | |
| 246 bool blocking_; | |
|
Ryan Hamilton
2016/06/29 23:12:28
nit: main_job_is_blocked_;
| |
| 247 base::TimeDelta wait_time_; | |
|
Ryan Hamilton
2016/06/29 23:12:28
nit: main_job_wait_time_? (or some such)
Can you
| |
| 248 | |
| 227 // At the point where a Job is irrevocably tied to |request_|, we set this. | 249 // At the point where a Job is irrevocably tied to |request_|, we set this. |
| 228 // It will be nulled when the |request_| is finished. | 250 // It will be nulled when the |request_| is finished. |
| 229 Job* bound_job_; | 251 Job* bound_job_; |
| 230 }; | 252 }; |
| 231 | 253 |
| 232 } // namespace net | 254 } // namespace net |
| 233 | 255 |
| 234 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ | 256 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| OLD | NEW |