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 when |job| finishes initiating a connection. | |
| 137 // Resume the other job if there's an error raised. | |
| 138 void OnConnectionInitialized(Job* job, int rv) override; | |
| 139 | |
| 140 // Return false if |job| has no blocking job and there's no wait time, | |
| 141 // i.e., |job| won't call Job::ResumeAfterDelay(). Else true and resume | |
|
Ryan Hamilton
2016/07/12 00:21:45
ResumeAfterDelay is now dead, right? Perhaps this
Zhongyi Shi
2016/07/12 23:03:12
Done.
| |
| 142 // |job| with appropriate wait time. | |
| 143 bool ShouldWait(Job* job) override; | |
| 144 | |
| 136 // Called when |job| determines the appropriate |spdy_session_key| for the | 145 // Called when |job| determines the appropriate |spdy_session_key| for the |
| 137 // Request. Note that this does not mean that SPDY is necessarily supported | 146 // 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 | 147 // for this SpdySessionKey, since we may need to wait for NPN to complete |
| 139 // before knowing if SPDY is available. | 148 // before knowing if SPDY is available. |
| 140 void SetSpdySessionKey(Job* job, | 149 void SetSpdySessionKey(Job* job, |
| 141 const SpdySessionKey& spdy_session_key) override; | 150 const SpdySessionKey& spdy_session_key) override; |
| 142 | 151 |
| 143 // Remove session from the SpdySessionRequestMap. | 152 // Remove session from the SpdySessionRequestMap. |
| 144 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job) override; | 153 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job) override; |
| 145 const BoundNetLog* GetNetLog(Job* job) const override; | 154 const BoundNetLog* GetNetLog(Job* job) const override; |
| 155 | |
| 156 void SetWaitTimeForMainJob(const base::TimeDelta& delay) override; | |
| 157 | |
| 146 WebSocketHandshakeStreamBase::CreateHelper* | 158 WebSocketHandshakeStreamBase::CreateHelper* |
| 147 websocket_handshake_stream_create_helper() override; | 159 websocket_handshake_stream_create_helper() override; |
| 148 | 160 |
| 149 private: | 161 private: |
| 150 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 162 friend class JobControllerPeer; |
| 151 | 163 |
| 152 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. | 164 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. |
| 153 void CreateJobs(const HttpRequestInfo& request_info, | 165 void CreateJobs(const HttpRequestInfo& request_info, |
| 154 RequestPriority priority, | 166 RequestPriority priority, |
| 155 const SSLConfig& server_ssl_config, | 167 const SSLConfig& server_ssl_config, |
| 156 const SSLConfig& proxy_ssl_config, | 168 const SSLConfig& proxy_ssl_config, |
| 157 HttpStreamRequest::Delegate* delegate, | 169 HttpStreamRequest::Delegate* delegate, |
| 158 HttpStreamRequest::StreamType stream_type, | 170 HttpStreamRequest::StreamType stream_type, |
| 159 const BoundNetLog& net_log); | 171 const BoundNetLog& net_log); |
| 160 | 172 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 177 // Called when a Job succeeds. | 189 // Called when a Job succeeds. |
| 178 void OnJobSucceeded(Job* job); | 190 void OnJobSucceeded(Job* job); |
| 179 | 191 |
| 180 // Marks completion of the |request_|. | 192 // Marks completion of the |request_|. |
| 181 void MarkRequestComplete(bool was_npn_negotiated, | 193 void MarkRequestComplete(bool was_npn_negotiated, |
| 182 NextProto protocol_negotiated, | 194 NextProto protocol_negotiated, |
| 183 bool using_spdy); | 195 bool using_spdy); |
| 184 | 196 |
| 185 void MaybeNotifyFactoryOfCompletion(); | 197 void MaybeNotifyFactoryOfCompletion(); |
| 186 | 198 |
| 199 // Called to resume the main job with delay. | |
| 200 void MaybeResumeMainJob(Job* job, const base::TimeDelta& delay); | |
| 201 | |
| 202 void ResumeMainJob(); | |
| 203 | |
| 187 // Returns true if QUIC is whitelisted for |host|. | 204 // Returns true if QUIC is whitelisted for |host|. |
| 188 bool IsQuicWhitelistedForHost(const std::string& host); | 205 bool IsQuicWhitelistedForHost(const std::string& host); |
| 189 | 206 |
| 190 AlternativeService GetAlternativeServiceFor( | 207 AlternativeService GetAlternativeServiceFor( |
| 191 const HttpRequestInfo& request_info, | 208 const HttpRequestInfo& request_info, |
| 192 HttpStreamRequest::Delegate* delegate, | 209 HttpStreamRequest::Delegate* delegate, |
| 193 HttpStreamRequest::StreamType stream_type); | 210 HttpStreamRequest::StreamType stream_type); |
| 194 | 211 |
| 195 AlternativeService GetAlternativeServiceForInternal( | 212 AlternativeService GetAlternativeServiceForInternal( |
| 196 const HttpRequestInfo& request_info, | 213 const HttpRequestInfo& request_info, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 217 | 234 |
| 218 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a | 235 // |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 | 236 // connection. If |alternative_job_| is unable to do so, |this| will notify |
| 220 // |main_job_| to proceed and then race the two jobs. | 237 // |main_job_| to proceed and then race the two jobs. |
| 221 std::unique_ptr<Job> main_job_; | 238 std::unique_ptr<Job> main_job_; |
| 222 std::unique_ptr<Job> alternative_job_; | 239 std::unique_ptr<Job> alternative_job_; |
| 223 | 240 |
| 224 // True if a Job has ever been bound to the |request_|. | 241 // True if a Job has ever been bound to the |request_|. |
| 225 bool job_bound_; | 242 bool job_bound_; |
| 226 | 243 |
| 244 // True if the |main_job_| has to wait for |alternative_job_|. The delay | |
| 245 // is specified in |main_job_wait_time_|. | |
| 246 bool main_job_is_blocked_; | |
|
Ryan Hamilton
2016/07/12 00:21:45
Let's comment this a bit more.
When main_job_is_
Zhongyi Shi
2016/07/12 23:03:12
Done.
| |
| 247 base::TimeDelta main_job_wait_time_; | |
| 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_; |
| 252 | |
| 253 base::WeakPtrFactory<JobController> ptr_factory_; | |
| 230 }; | 254 }; |
| 231 | 255 |
| 232 } // namespace net | 256 } // namespace net |
| 233 | 257 |
| 234 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ | 258 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_CONTROLLER_H_ |
| OLD | NEW |