| 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| can advance to the next state. Otherwise, |job| |
| 141 // will wait for Job::Resume() to be called before advancing. |
| 142 bool ShouldWait(Job* job) override; |
| 143 |
| 136 // Called when |job| determines the appropriate |spdy_session_key| for the | 144 // Called when |job| determines the appropriate |spdy_session_key| for the |
| 137 // Request. Note that this does not mean that SPDY is necessarily supported | 145 // 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 | 146 // for this SpdySessionKey, since we may need to wait for NPN to complete |
| 139 // before knowing if SPDY is available. | 147 // before knowing if SPDY is available. |
| 140 void SetSpdySessionKey(Job* job, | 148 void SetSpdySessionKey(Job* job, |
| 141 const SpdySessionKey& spdy_session_key) override; | 149 const SpdySessionKey& spdy_session_key) override; |
| 142 | 150 |
| 143 // Remove session from the SpdySessionRequestMap. | 151 // Remove session from the SpdySessionRequestMap. |
| 144 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job) override; | 152 void RemoveRequestFromSpdySessionRequestMapForJob(Job* job) override; |
| 145 const BoundNetLog* GetNetLog(Job* job) const override; | 153 const BoundNetLog* GetNetLog(Job* job) const override; |
| 154 |
| 155 void MaybeSetWaitTimeForMainJob(const base::TimeDelta& delay) override; |
| 156 |
| 146 WebSocketHandshakeStreamBase::CreateHelper* | 157 WebSocketHandshakeStreamBase::CreateHelper* |
| 147 websocket_handshake_stream_create_helper() override; | 158 websocket_handshake_stream_create_helper() override; |
| 148 | 159 |
| 149 private: | 160 private: |
| 150 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); | 161 friend class JobControllerPeer; |
| 151 | 162 |
| 152 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. | 163 // Creates Job(s) for |request_|. Job(s) will be owned by |this|. |
| 153 void CreateJobs(const HttpRequestInfo& request_info, | 164 void CreateJobs(const HttpRequestInfo& request_info, |
| 154 RequestPriority priority, | 165 RequestPriority priority, |
| 155 const SSLConfig& server_ssl_config, | 166 const SSLConfig& server_ssl_config, |
| 156 const SSLConfig& proxy_ssl_config, | 167 const SSLConfig& proxy_ssl_config, |
| 157 HttpStreamRequest::Delegate* delegate, | 168 HttpStreamRequest::Delegate* delegate, |
| 158 HttpStreamRequest::StreamType stream_type, | 169 HttpStreamRequest::StreamType stream_type, |
| 159 const BoundNetLog& net_log); | 170 const BoundNetLog& net_log); |
| 160 | 171 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 177 // Called when a Job succeeds. | 188 // Called when a Job succeeds. |
| 178 void OnJobSucceeded(Job* job); | 189 void OnJobSucceeded(Job* job); |
| 179 | 190 |
| 180 // Marks completion of the |request_|. | 191 // Marks completion of the |request_|. |
| 181 void MarkRequestComplete(bool was_npn_negotiated, | 192 void MarkRequestComplete(bool was_npn_negotiated, |
| 182 NextProto protocol_negotiated, | 193 NextProto protocol_negotiated, |
| 183 bool using_spdy); | 194 bool using_spdy); |
| 184 | 195 |
| 185 void MaybeNotifyFactoryOfCompletion(); | 196 void MaybeNotifyFactoryOfCompletion(); |
| 186 | 197 |
| 198 // Called to resume the main job with delay. |
| 199 void MaybeResumeMainJob(Job* job, const base::TimeDelta& delay); |
| 200 |
| 201 void ResumeMainJob(); |
| 202 |
| 187 // Returns true if QUIC is whitelisted for |host|. | 203 // Returns true if QUIC is whitelisted for |host|. |
| 188 bool IsQuicWhitelistedForHost(const std::string& host); | 204 bool IsQuicWhitelistedForHost(const std::string& host); |
| 189 | 205 |
| 190 AlternativeService GetAlternativeServiceFor( | 206 AlternativeService GetAlternativeServiceFor( |
| 191 const HttpRequestInfo& request_info, | 207 const HttpRequestInfo& request_info, |
| 192 HttpStreamRequest::Delegate* delegate, | 208 HttpStreamRequest::Delegate* delegate, |
| 193 HttpStreamRequest::StreamType stream_type); | 209 HttpStreamRequest::StreamType stream_type); |
| 194 | 210 |
| 195 AlternativeService GetAlternativeServiceForInternal( | 211 AlternativeService GetAlternativeServiceForInternal( |
| 196 const HttpRequestInfo& request_info, | 212 const HttpRequestInfo& request_info, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 217 | 233 |
| 218 // |main_job_| is a job waiting to see if |alternative_job_| can reuse a | 234 // |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 | 235 // connection. If |alternative_job_| is unable to do so, |this| will notify |
| 220 // |main_job_| to proceed and then race the two jobs. | 236 // |main_job_| to proceed and then race the two jobs. |
| 221 std::unique_ptr<Job> main_job_; | 237 std::unique_ptr<Job> main_job_; |
| 222 std::unique_ptr<Job> alternative_job_; | 238 std::unique_ptr<Job> alternative_job_; |
| 223 | 239 |
| 224 // True if a Job has ever been bound to the |request_|. | 240 // True if a Job has ever been bound to the |request_|. |
| 225 bool job_bound_; | 241 bool job_bound_; |
| 226 | 242 |
| 243 // True if the main job has to wait for the alternative job: i.e., the main |
| 244 // job must not create a connection until it is resumed. |
| 245 bool main_job_is_blocked_; |
| 246 // Waiting time for the main job before it is resumed. |
| 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 |