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 <memory> | 8 #include <memory> |
9 #include <utility> | |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
15 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
16 #include "net/base/request_priority.h" | 17 #include "net/base/request_priority.h" |
17 #include "net/http/bidirectional_stream_impl.h" | 18 #include "net/http/bidirectional_stream_impl.h" |
18 #include "net/http/http_auth.h" | 19 #include "net/http/http_auth.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 } | 251 } |
251 | 252 |
252 private: | 253 private: |
253 friend class HttpStreamFactoryImplJobPeer; | 254 friend class HttpStreamFactoryImplJobPeer; |
254 | 255 |
255 enum State { | 256 enum State { |
256 STATE_START, | 257 STATE_START, |
257 STATE_RESOLVE_PROXY, | 258 STATE_RESOLVE_PROXY, |
258 STATE_RESOLVE_PROXY_COMPLETE, | 259 STATE_RESOLVE_PROXY_COMPLETE, |
259 | 260 |
260 // Note that when Alternate-Protocol says we can connect to an alternate | 261 // The main and alternative jobs are started in parallel. The main job |
261 // port using a different protocol, we have the choice of communicating over | 262 // waits after it finishes proxy resolution. The alternative job never |
262 // the original protocol, or speaking the alternate protocol (currently, | 263 // waits. |
263 // only npn-spdy) over an alternate port. For a cold page load, the http | 264 // |
264 // connection that delivers the http response that has the | 265 // An HTTP/2 alternative job notifies the JobController in DoInitConnection |
265 // Alternate-Protocol header will already be warm. So, blocking the next | 266 // unless it can pool to an existing SpdySession. JobController, in turn, |
266 // http request on establishing a new npn-spdy connection would incur extra | 267 // resumes the main job. |
267 // latency. Even if the http connection was not reused, establishing a new | 268 // |
268 // http connection is typically faster than npn-spdy, since npn-spdy | 269 // A QUIC alternative job notifies the JobController in DoInitConnection |
Bence
2016/09/22 19:30:32
This is obsolete: Alt-Svc is only allowed for http
| |
269 // requires a SSL handshake. Therefore, we start both the http and the | 270 // regardless of whether it pools to an existing QUIC session, but the main |
270 // npn-spdy jobs in parallel. In order not to unnecessarily waste sockets, | 271 // job is only resumed after some delay. |
271 // we have the http job block on the npn-spdy job after proxy resolution. | 272 // |
272 // The npn-spdy job will Resume() the http job if, in | 273 // If the main job is resumed, then it races the alternative job. |
273 // STATE_INIT_CONNECTION_COMPLETE, it detects an error or does not find an | |
274 // existing SpdySession. In that case, the http and npn-spdy jobs will race. | |
275 // When QUIC protocol is used by the npn-spdy job, then http job will wait | |
276 // for |wait_time_| when the http job was resumed. | |
277 STATE_WAIT, | 274 STATE_WAIT, |
278 STATE_WAIT_COMPLETE, | 275 STATE_WAIT_COMPLETE, |
279 | 276 |
280 STATE_INIT_CONNECTION, | 277 STATE_INIT_CONNECTION, |
281 STATE_INIT_CONNECTION_COMPLETE, | 278 STATE_INIT_CONNECTION_COMPLETE, |
282 STATE_WAITING_USER_ACTION, | 279 STATE_WAITING_USER_ACTION, |
283 STATE_RESTART_TUNNEL_AUTH, | 280 STATE_RESTART_TUNNEL_AUTH, |
284 STATE_RESTART_TUNNEL_AUTH_COMPLETE, | 281 STATE_RESTART_TUNNEL_AUTH_COMPLETE, |
285 STATE_CREATE_STREAM, | 282 STATE_CREATE_STREAM, |
286 STATE_CREATE_STREAM_COMPLETE, | 283 STATE_CREATE_STREAM_COMPLETE, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 int ReconsiderProxyAfterError(int error); | 366 int ReconsiderProxyAfterError(int error); |
370 | 367 |
371 // Called to handle a certificate error. Stores the certificate in the | 368 // Called to handle a certificate error. Stores the certificate in the |
372 // allowed_bad_certs list, and checks if the error can be ignored. Returns | 369 // allowed_bad_certs list, and checks if the error can be ignored. Returns |
373 // OK if it can be ignored, or the error code otherwise. | 370 // OK if it can be ignored, or the error code otherwise. |
374 int HandleCertificateError(int error); | 371 int HandleCertificateError(int error); |
375 | 372 |
376 // Called to handle a client certificate request. | 373 // Called to handle a client certificate request. |
377 int HandleCertificateRequest(int error); | 374 int HandleCertificateRequest(int error); |
378 | 375 |
379 // Moves this stream request into SPDY mode. | |
380 void SwitchToSpdyMode(); | |
381 | |
382 // Should we force QUIC for this stream request. | 376 // Should we force QUIC for this stream request. |
383 bool ShouldForceQuic() const; | 377 bool ShouldForceQuic() const; |
384 | 378 |
385 ClientSocketPoolManager::SocketGroupType GetSocketGroup() const; | 379 ClientSocketPoolManager::SocketGroupType GetSocketGroup() const; |
386 | 380 |
387 void MaybeCopyConnectionAttemptsFromSocketOrHandle(); | 381 void MaybeCopyConnectionAttemptsFromSocketOrHandle(); |
388 | 382 |
389 // Record histograms of latency until Connect() completes. | 383 // Record histograms of latency until Connect() completes. |
390 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); | 384 static void LogHttpConnectedMetrics(const ClientSocketHandle& handle); |
391 | 385 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 const SSLConfig& server_ssl_config, | 527 const SSLConfig& server_ssl_config, |
534 const SSLConfig& proxy_ssl_config, | 528 const SSLConfig& proxy_ssl_config, |
535 HostPortPair destination, | 529 HostPortPair destination, |
536 GURL origin_url, | 530 GURL origin_url, |
537 NetLog* net_log) = 0; | 531 NetLog* net_log) = 0; |
538 }; | 532 }; |
539 | 533 |
540 } // namespace net | 534 } // namespace net |
541 | 535 |
542 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ | 536 #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_JOB_H_ |
OLD | NEW |