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. |
Ryan Hamilton
2016/01/19 23:23:27
Can you update this comment when you have a chance
ramant (doing other things)
2016/01/20 04:37:52
Done.
| |
136 STATE_WAIT_FOR_JOB, | 138 STATE_WAIT_FOR_JOB, |
137 STATE_WAIT_FOR_JOB_COMPLETE, | 139 STATE_WAIT_FOR_JOB_COMPLETE, |
138 | 140 |
139 STATE_INIT_CONNECTION, | 141 STATE_INIT_CONNECTION, |
140 STATE_INIT_CONNECTION_COMPLETE, | 142 STATE_INIT_CONNECTION_COMPLETE, |
141 STATE_WAITING_USER_ACTION, | 143 STATE_WAITING_USER_ACTION, |
142 STATE_RESTART_TUNNEL_AUTH, | 144 STATE_RESTART_TUNNEL_AUTH, |
143 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 145 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
144 STATE_CREATE_STREAM, | 146 STATE_CREATE_STREAM, |
145 STATE_CREATE_STREAM_COMPLETE, | 147 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. | 196 // the Job is not a SPDY alternative job, or if |spdy_session| is null. |
195 // Returns appropriate error code otherwise. | 197 // Returns appropriate error code otherwise. |
196 int CheckAlternativeServiceValidityForOrigin( | 198 int CheckAlternativeServiceValidityForOrigin( |
197 base::WeakPtr<SpdySession> spdy_session); | 199 base::WeakPtr<SpdySession> spdy_session); |
198 | 200 |
199 SpdySessionPool* const spdy_session_pool_; | 201 SpdySessionPool* const spdy_session_pool_; |
200 const GURL origin_url_; | 202 const GURL origin_url_; |
201 const bool is_spdy_alternative_; | 203 const bool is_spdy_alternative_; |
202 }; | 204 }; |
203 | 205 |
206 // Resume the |this| job after the specified |delay|. | |
207 void ResumeWaitingJobAfterDelay(const base::TimeDelta& delay); | |
208 | |
204 void OnStreamReadyCallback(); | 209 void OnStreamReadyCallback(); |
205 void OnBidirectionalStreamJobReadyCallback(); | 210 void OnBidirectionalStreamJobReadyCallback(); |
206 void OnWebSocketHandshakeStreamReadyCallback(); | 211 void OnWebSocketHandshakeStreamReadyCallback(); |
207 // This callback function is called when a new SPDY session is created. | 212 // This callback function is called when a new SPDY session is created. |
208 void OnNewSpdySessionReadyCallback(); | 213 void OnNewSpdySessionReadyCallback(); |
209 void OnStreamFailedCallback(int result); | 214 void OnStreamFailedCallback(int result); |
210 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); | 215 void OnCertificateErrorCallback(int result, const SSLInfo& ssl_info); |
211 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, | 216 void OnNeedsProxyAuthCallback(const HttpResponseInfo& response_info, |
212 HttpAuthController* auth_controller); | 217 HttpAuthController* auth_controller); |
213 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); | 218 void OnNeedsClientAuthCallback(SSLCertRequestInfo* cert_info); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 | 350 |
346 // This is the Job we're dependent on. It will notify us if/when it's OK to | 351 // This is the Job we're dependent on. It will notify us if/when it's OK to |
347 // proceed. | 352 // proceed. |
348 Job* blocking_job_; | 353 Job* blocking_job_; |
349 | 354 |
350 // |waiting_job_| is a Job waiting to see if |this| can reuse a connection. | 355 // |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 | 356 // 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. | 357 // proceed and then race the two Jobs. |
353 Job* waiting_job_; | 358 Job* waiting_job_; |
354 | 359 |
360 base::TimeDelta wait_time_; | |
361 | |
355 // True if handling a HTTPS request, or using SPDY with SSL | 362 // True if handling a HTTPS request, or using SPDY with SSL |
356 bool using_ssl_; | 363 bool using_ssl_; |
357 | 364 |
358 // True if this network transaction is using SPDY instead of HTTP. | 365 // True if this network transaction is using SPDY instead of HTTP. |
359 bool using_spdy_; | 366 bool using_spdy_; |
360 | 367 |
361 // True if this network transaction is using QUIC instead of HTTP. | 368 // True if this network transaction is using QUIC instead of HTTP. |
362 bool using_quic_; | 369 bool using_quic_; |
363 QuicStreamRequest quic_request_; | 370 QuicStreamRequest quic_request_; |
364 | 371 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 bool for_bidirectional_; | 419 bool for_bidirectional_; |
413 | 420 |
414 base::WeakPtrFactory<Job> ptr_factory_; | 421 base::WeakPtrFactory<Job> ptr_factory_; |
415 | 422 |
416 DISALLOW_COPY_AND_ASSIGN(Job); | 423 DISALLOW_COPY_AND_ASSIGN(Job); |
417 }; | 424 }; |
418 | 425 |
419 } // namespace net | 426 } // namespace net |
420 | 427 |
421 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 428 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
OLD | NEW |