OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 bool IsOrphaned() const; | 106 bool IsOrphaned() const; |
107 | 107 |
108 // Called to indicate that this job succeeded, and some other jobs | 108 // Called to indicate that this job succeeded, and some other jobs |
109 // will be orphaned. | 109 // will be orphaned. |
110 void ReportJobSucceededForRequest(); | 110 void ReportJobSucceededForRequest(); |
111 | 111 |
112 // Marks that the other |job| has completed. | 112 // Marks that the other |job| has completed. |
113 void MarkOtherJobComplete(const Job& job); | 113 void MarkOtherJobComplete(const Job& job); |
114 | 114 |
115 private: | 115 private: |
| 116 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryImplRequestTest, DelayMainJob); |
| 117 |
116 enum State { | 118 enum State { |
117 STATE_START, | 119 STATE_START, |
118 STATE_RESOLVE_PROXY, | 120 STATE_RESOLVE_PROXY, |
119 STATE_RESOLVE_PROXY_COMPLETE, | 121 STATE_RESOLVE_PROXY_COMPLETE, |
120 | 122 |
121 // Note that when Alternate-Protocol says we can connect to an alternate | 123 // Note that when Alternate-Protocol says we can connect to an alternate |
122 // port using a different protocol, we have the choice of communicating over | 124 // port using a different protocol, we have the choice of communicating over |
123 // the original protocol, or speaking the alternate protocol (currently, | 125 // the original protocol, or speaking the alternate protocol (currently, |
124 // only npn-spdy) over an alternate port. For a cold page load, the http | 126 // only npn-spdy) over an alternate port. For a cold page load, the http |
125 // connection that delivers the http response that has the | 127 // connection that delivers the http response that has the |
126 // Alternate-Protocol header will already be warm. So, blocking the next | 128 // Alternate-Protocol header will already be warm. So, blocking the next |
127 // http request on establishing a new npn-spdy connection would incur extra | 129 // http request on establishing a new npn-spdy connection would incur extra |
128 // latency. Even if the http connection was not reused, establishing a new | 130 // latency. Even if the http connection was not reused, establishing a new |
129 // http connection is typically faster than npn-spdy, since npn-spdy | 131 // http connection is typically faster than npn-spdy, since npn-spdy |
130 // requires a SSL handshake. Therefore, we start both the http and the | 132 // requires a SSL handshake. Therefore, we start both the http and the |
131 // npn-spdy jobs in parallel. In order not to unnecessarily waste sockets, | 133 // npn-spdy jobs in parallel. In order not to unnecessarily waste sockets, |
132 // we have the http job block on the npn-spdy job after proxy resolution. | 134 // we have the http job block on the npn-spdy job after proxy resolution. |
133 // The npn-spdy job will Resume() the http job if, in | 135 // The npn-spdy job will Resume() the http job if, in |
134 // STATE_INIT_CONNECTION_COMPLETE, it detects an error or does not find an | 136 // STATE_INIT_CONNECTION_COMPLETE, it detects an error or does not find an |
135 // existing SpdySession. In that case, the http and npn-spdy jobs will race. | 137 // existing SpdySession. In that case, the http and npn-spdy jobs will race. |
| 138 // When QUIC protocol is used by the npn-spdy job, then http job will wait |
| 139 // for |wait_time_| when the http job was resumed. |
136 STATE_WAIT_FOR_JOB, | 140 STATE_WAIT_FOR_JOB, |
137 STATE_WAIT_FOR_JOB_COMPLETE, | 141 STATE_WAIT_FOR_JOB_COMPLETE, |
138 | 142 |
139 STATE_INIT_CONNECTION, | 143 STATE_INIT_CONNECTION, |
140 STATE_INIT_CONNECTION_COMPLETE, | 144 STATE_INIT_CONNECTION_COMPLETE, |
141 STATE_WAITING_USER_ACTION, | 145 STATE_WAITING_USER_ACTION, |
142 STATE_RESTART_TUNNEL_AUTH, | 146 STATE_RESTART_TUNNEL_AUTH, |
143 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 147 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
144 STATE_CREATE_STREAM, | 148 STATE_CREATE_STREAM, |
145 STATE_CREATE_STREAM_COMPLETE, | 149 STATE_CREATE_STREAM_COMPLETE, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // the Job is not a SPDY alternative job, or if |spdy_session| is null. | 198 // the Job is not a SPDY alternative job, or if |spdy_session| is null. |
195 // Returns appropriate error code otherwise. | 199 // Returns appropriate error code otherwise. |
196 int CheckAlternativeServiceValidityForOrigin( | 200 int CheckAlternativeServiceValidityForOrigin( |
197 base::WeakPtr<SpdySession> spdy_session); | 201 base::WeakPtr<SpdySession> spdy_session); |
198 | 202 |
199 SpdySessionPool* const spdy_session_pool_; | 203 SpdySessionPool* const spdy_session_pool_; |
200 const GURL origin_url_; | 204 const GURL origin_url_; |
201 const bool is_spdy_alternative_; | 205 const bool is_spdy_alternative_; |
202 }; | 206 }; |
203 | 207 |
| 208 // Resume the |this| job after the specified |wait_time_|. |
| 209 void ResumeAfterDelay(); |
| 210 |
204 void OnStreamReadyCallback(); | 211 void OnStreamReadyCallback(); |
205 void OnBidirectionalStreamJobReadyCallback(); | 212 void OnBidirectionalStreamJobReadyCallback(); |
206 void OnWebSocketHandshakeStreamReadyCallback(); | 213 void OnWebSocketHandshakeStreamReadyCallback(); |
207 // This callback function is called when a new SPDY session is created. | 214 // This callback function is called when a new SPDY session is created. |
208 void OnNewSpdySessionReadyCallback(); | 215 void OnNewSpdySessionReadyCallback(); |
209 void OnStreamFailedCallback(int result); | 216 void OnStreamFailedCallback(int result); |
210 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); | 217 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); |
211 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, | 218 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, |
212 HttpAuthController* auth_controller); | 219 HttpAuthController* auth_controller); |
213 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); | 220 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 352 |
346 // This is the Job we're dependent on. It will notify us if/when it's OK to | 353 // This is the Job we're dependent on. It will notify us if/when it's OK to |
347 // proceed. | 354 // proceed. |
348 Job* blocking_job_; | 355 Job* blocking_job_; |
349 | 356 |
350 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. | 357 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. |
351 // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to | 358 // If |this| is unable to do so, we'll notify |waiting_job_| that it's ok to |
352 // proceed and then race the two Jobs. | 359 // proceed and then race the two Jobs. |
353 Job* waiting_job_; | 360 Job* waiting_job_; |
354 | 361 |
| 362 base::TimeDelta wait_time_; |
| 363 |
355 // True if handling a HTTPS request, or using SPDY with SSL | 364 // True if handling a HTTPS request, or using SPDY with SSL |
356 bool using_ssl_; | 365 bool using_ssl_; |
357 | 366 |
358 // True if this network transaction is using SPDY instead of HTTP. | 367 // True if this network transaction is using SPDY instead of HTTP. |
359 bool using_spdy_; | 368 bool using_spdy_; |
360 | 369 |
361 // True if this network transaction is using QUIC instead of HTTP. | 370 // True if this network transaction is using QUIC instead of HTTP. |
362 bool using_quic_; | 371 bool using_quic_; |
363 QuicStreamRequest quic_request_; | 372 QuicStreamRequest quic_request_; |
364 | 373 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 bool for_bidirectional_; | 421 bool for_bidirectional_; |
413 | 422 |
414 base::WeakPtrFactory<Job> ptr_factory_; | 423 base::WeakPtrFactory<Job> ptr_factory_; |
415 | 424 |
416 DISALLOW_COPY_AND_ASSIGN(Job); | 425 DISALLOW_COPY_AND_ASSIGN(Job); |
417 }; | 426 }; |
418 | 427 |
419 } // namespace net | 428 } // namespace net |
420 | 429 |
421 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 430 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
OLD | NEW |