Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: net/http/http_stream_factory_impl_job.cc

Issue 14813024: Introduce RequestWebSocketStream into HttpStreamFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "net/http/http_stream_factory_impl_job.h" 5 #include "net/http/http_stream_factory_impl_job.h"
6 6
7 #include <string>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/stl_util.h" 12 #include "base/stl_util.h"
11 #include "base/string_util.h" 13 #include "base/string_util.h"
12 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
13 #include "base/values.h" 15 #include "base/values.h"
14 #include "build/build_config.h" 16 #include "build/build_config.h"
15 #include "net/base/connection_type_histograms.h" 17 #include "net/base/connection_type_histograms.h"
16 #include "net/base/net_log.h" 18 #include "net/base/net_log.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // https (the normal case) or if we're connection to a SPDY proxy, or 276 // https (the normal case) or if we're connection to a SPDY proxy, or
275 // if we're running with force_spdy_always_. crbug.com/133176 277 // if we're running with force_spdy_always_. crbug.com/133176
276 return request_info_.url.SchemeIs("https") || 278 return request_info_.url.SchemeIs("https") ||
277 proxy_info_.proxy_server().is_https() || 279 proxy_info_.proxy_server().is_https() ||
278 force_spdy_always_; 280 force_spdy_always_;
279 } 281 }
280 282
281 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { 283 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() {
282 DCHECK(stream_.get()); 284 DCHECK(stream_.get());
283 DCHECK(!IsPreconnecting()); 285 DCHECK(!IsPreconnecting());
286 DCHECK(!stream_factory_->for_websockets_);
284 if (IsOrphaned()) { 287 if (IsOrphaned()) {
285 stream_factory_->OnOrphanedJobComplete(this); 288 stream_factory_->OnOrphanedJobComplete(this);
286 } else { 289 } else {
287 request_->Complete(was_npn_negotiated(), 290 request_->Complete(was_npn_negotiated(),
288 protocol_negotiated(), 291 protocol_negotiated(),
289 using_spdy(), 292 using_spdy(),
290 net_log_); 293 net_log_);
291 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, 294 request_->OnStreamReady(this, server_ssl_config_, proxy_info_,
292 stream_.release()); 295 stream_.release());
293 } 296 }
294 // |this| may be deleted after this call. 297 // |this| may be deleted after this call.
295 } 298 }
296 299
297 void HttpStreamFactoryImpl::Job::OnSpdySessionReadyCallback() { 300 void HttpStreamFactoryImpl::Job::OnWebSocketStreamReadyCallback() {
301 DCHECK(!IsPreconnecting());
302 DCHECK(stream_factory_->for_websockets_);
303 DCHECK(websocket_stream_);
304 if (IsOrphaned()) {
305 stream_factory_->OnOrphanedJobComplete(this);
306 } else {
307 request_->Complete(was_npn_negotiated(),
308 protocol_negotiated(),
309 using_spdy(),
310 net_log_);
311 request_->OnWebSocketStreamReady(this,
312 server_ssl_config_,
313 proxy_info_,
314 websocket_stream_.release());
315 }
316 // |this| may be deleted after this call.
317 }
318
319 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() {
298 DCHECK(!stream_.get()); 320 DCHECK(!stream_.get());
299 DCHECK(!IsPreconnecting()); 321 DCHECK(!IsPreconnecting());
300 DCHECK(using_spdy()); 322 DCHECK(using_spdy());
301 DCHECK(new_spdy_session_); 323 DCHECK(new_spdy_session_);
302 scoped_refptr<SpdySession> spdy_session = new_spdy_session_; 324 scoped_refptr<SpdySession> spdy_session = new_spdy_session_;
303 new_spdy_session_ = NULL; 325 new_spdy_session_ = NULL;
304 if (IsOrphaned()) { 326 if (IsOrphaned()) {
305 stream_factory_->OnSpdySessionReady( 327 stream_factory_->OnNewSpdySessionReady(
306 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, 328 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_,
307 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); 329 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_);
308 stream_factory_->OnOrphanedJobComplete(this); 330 stream_factory_->OnOrphanedJobComplete(this);
309 } else { 331 } else {
310 request_->OnSpdySessionReady(this, spdy_session, spdy_session_direct_); 332 request_->OnNewSpdySessionReady(this, spdy_session, spdy_session_direct_);
311 } 333 }
312 // |this| may be deleted after this call. 334 // |this| may be deleted after this call.
313 } 335 }
314 336
315 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { 337 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) {
316 DCHECK(!IsPreconnecting()); 338 DCHECK(!IsPreconnecting());
317 if (IsOrphaned()) 339 if (IsOrphaned())
318 stream_factory_->OnOrphanedJobComplete(this); 340 stream_factory_->OnOrphanedJobComplete(this);
319 else 341 else
320 request_->OnStreamFailed(this, result, server_ssl_config_); 342 request_->OnStreamFailed(this, result, server_ssl_config_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 stream_factory_->OnOrphanedJobComplete(this); 383 stream_factory_->OnOrphanedJobComplete(this);
362 else 384 else
363 request_->OnHttpsProxyTunnelResponse( 385 request_->OnHttpsProxyTunnelResponse(
364 this, response_info, server_ssl_config_, proxy_info_, stream); 386 this, response_info, server_ssl_config_, proxy_info_, stream);
365 // |this| may be deleted after this call. 387 // |this| may be deleted after this call.
366 } 388 }
367 389
368 void HttpStreamFactoryImpl::Job::OnPreconnectsComplete() { 390 void HttpStreamFactoryImpl::Job::OnPreconnectsComplete() {
369 DCHECK(!request_); 391 DCHECK(!request_);
370 if (new_spdy_session_) { 392 if (new_spdy_session_) {
371 stream_factory_->OnSpdySessionReady( 393 stream_factory_->OnNewSpdySessionReady(
372 new_spdy_session_, spdy_session_direct_, server_ssl_config_, 394 new_spdy_session_, spdy_session_direct_, server_ssl_config_,
373 proxy_info_, was_npn_negotiated(), protocol_negotiated(), using_spdy(), 395 proxy_info_, was_npn_negotiated(), protocol_negotiated(), using_spdy(),
374 net_log_); 396 net_log_);
375 } 397 }
376 stream_factory_->OnPreconnectsComplete(this); 398 stream_factory_->OnPreconnectsComplete(this);
377 // |this| may be deleted after this call. 399 // |this| may be deleted after this call.
378 } 400 }
379 401
380 // static 402 // static
381 int HttpStreamFactoryImpl::Job::OnHostResolution( 403 int HttpStreamFactoryImpl::Job::OnHostResolution(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 459
438 ProxyClientSocket* proxy_socket = 460 ProxyClientSocket* proxy_socket =
439 static_cast<ProxyClientSocket*>(connection_->socket()); 461 static_cast<ProxyClientSocket*>(connection_->socket());
440 const HttpResponseInfo* tunnel_auth_response = 462 const HttpResponseInfo* tunnel_auth_response =
441 proxy_socket->GetConnectResponseInfo(); 463 proxy_socket->GetConnectResponseInfo();
442 464
443 next_state_ = STATE_WAITING_USER_ACTION; 465 next_state_ = STATE_WAITING_USER_ACTION;
444 base::MessageLoop::current()->PostTask( 466 base::MessageLoop::current()->PostTask(
445 FROM_HERE, 467 FROM_HERE,
446 base::Bind( 468 base::Bind(
447 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, 469 &Job::OnNeedsProxyAuthCallback,
448 ptr_factory_.GetWeakPtr(), 470 ptr_factory_.GetWeakPtr(),
449 *tunnel_auth_response, 471 *tunnel_auth_response,
450 proxy_socket->GetAuthController())); 472 proxy_socket->GetAuthController()));
451 } 473 }
452 return ERR_IO_PENDING; 474 return ERR_IO_PENDING;
453 475
454 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: 476 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED:
455 base::MessageLoop::current()->PostTask( 477 base::MessageLoop::current()->PostTask(
456 FROM_HERE, 478 FROM_HERE,
457 base::Bind( 479 base::Bind(
458 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, 480 &Job::OnNeedsClientAuthCallback,
459 ptr_factory_.GetWeakPtr(), 481 ptr_factory_.GetWeakPtr(),
460 connection_->ssl_error_response_info().cert_request_info)); 482 connection_->ssl_error_response_info().cert_request_info));
461 return ERR_IO_PENDING; 483 return ERR_IO_PENDING;
462 484
463 case ERR_HTTPS_PROXY_TUNNEL_RESPONSE: 485 case ERR_HTTPS_PROXY_TUNNEL_RESPONSE:
464 { 486 {
465 DCHECK(connection_.get()); 487 DCHECK(connection_.get());
466 DCHECK(connection_->socket()); 488 DCHECK(connection_->socket());
467 DCHECK(establishing_tunnel_); 489 DCHECK(establishing_tunnel_);
468 490
469 ProxyClientSocket* proxy_socket = 491 ProxyClientSocket* proxy_socket =
470 static_cast<ProxyClientSocket*>(connection_->socket()); 492 static_cast<ProxyClientSocket*>(connection_->socket());
471 base::MessageLoop::current()->PostTask( 493 base::MessageLoop::current()->PostTask(
472 FROM_HERE, 494 FROM_HERE,
473 base::Bind( 495 base::Bind(
474 &HttpStreamFactoryImpl::Job::OnHttpsProxyTunnelResponseCallback, 496 &Job::OnHttpsProxyTunnelResponseCallback,
475 ptr_factory_.GetWeakPtr(), 497 ptr_factory_.GetWeakPtr(),
476 *proxy_socket->GetConnectResponseInfo(), 498 *proxy_socket->GetConnectResponseInfo(),
477 proxy_socket->CreateConnectResponseStream())); 499 proxy_socket->CreateConnectResponseStream()));
478 return ERR_IO_PENDING; 500 return ERR_IO_PENDING;
479 } 501 }
480 502
481 case OK: 503 case OK:
482 next_state_ = STATE_DONE; 504 next_state_ = STATE_DONE;
483 if (new_spdy_session_) { 505 if (new_spdy_session_) {
484 base::MessageLoop::current()->PostTask( 506 base::MessageLoop::current()->PostTask(
485 FROM_HERE, 507 FROM_HERE,
486 base::Bind( 508 base::Bind(
487 &HttpStreamFactoryImpl::Job::OnSpdySessionReadyCallback, 509 &Job::OnNewSpdySessionReadyCallback,
510 ptr_factory_.GetWeakPtr()));
511 } else if (stream_factory_->for_websockets_) {
512 DCHECK(websocket_stream_);
513 MessageLoop::current()->PostTask(
514 FROM_HERE,
515 base::Bind(
516 &Job::OnWebSocketStreamReadyCallback,
488 ptr_factory_.GetWeakPtr())); 517 ptr_factory_.GetWeakPtr()));
489 } else { 518 } else {
490 base::MessageLoop::current()->PostTask( 519 base::MessageLoop::current()->PostTask(
491 FROM_HERE, 520 FROM_HERE,
492 base::Bind( 521 base::Bind(
493 &HttpStreamFactoryImpl::Job::OnStreamReadyCallback, 522 &Job::OnStreamReadyCallback,
494 ptr_factory_.GetWeakPtr())); 523 ptr_factory_.GetWeakPtr()));
495 } 524 }
496 return ERR_IO_PENDING; 525 return ERR_IO_PENDING;
497 526
498 default: 527 default:
499 base::MessageLoop::current()->PostTask( 528 base::MessageLoop::current()->PostTask(
500 FROM_HERE, 529 FROM_HERE,
501 base::Bind( 530 base::Bind(
502 &HttpStreamFactoryImpl::Job::OnStreamFailedCallback, 531 &Job::OnStreamFailedCallback,
503 ptr_factory_.GetWeakPtr(), 532 ptr_factory_.GetWeakPtr(),
504 result)); 533 result));
505 return ERR_IO_PENDING; 534 return ERR_IO_PENDING;
506 } 535 }
507 return result; 536 return result;
508 } 537 }
509 538
510 int HttpStreamFactoryImpl::Job::DoLoop(int result) { 539 int HttpStreamFactoryImpl::Job::DoLoop(int result) {
511 DCHECK_NE(next_state_, STATE_NONE); 540 DCHECK_NE(next_state_, STATE_NONE);
512 int rv = result; 541 int rv = result;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 next_state_ = STATE_INIT_CONNECTION; 708 next_state_ = STATE_INIT_CONNECTION;
680 return OK; 709 return OK;
681 } 710 }
682 711
683 int HttpStreamFactoryImpl::Job::DoInitConnection() { 712 int HttpStreamFactoryImpl::Job::DoInitConnection() {
684 DCHECK(!blocking_job_); 713 DCHECK(!blocking_job_);
685 DCHECK(!connection_->is_initialized()); 714 DCHECK(!connection_->is_initialized());
686 DCHECK(proxy_info_.proxy_server().is_valid()); 715 DCHECK(proxy_info_.proxy_server().is_valid());
687 next_state_ = STATE_INIT_CONNECTION_COMPLETE; 716 next_state_ = STATE_INIT_CONNECTION_COMPLETE;
688 717
689 using_ssl_ = request_info_.url.SchemeIs("https") || ShouldForceSpdySSL(); 718 using_ssl_ = request_info_.url.SchemeIs("https") ||
719 request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL();
690 using_spdy_ = false; 720 using_spdy_ = false;
691 721
692 if (ShouldForceQuic()) 722 if (ShouldForceQuic())
693 using_quic_ = true; 723 using_quic_ = true;
694 724
695 if (using_quic_) { 725 if (using_quic_) {
696 DCHECK(session_->params().enable_quic); 726 DCHECK(session_->params().enable_quic);
697 if (!proxy_info_.is_direct()) { 727 if (!proxy_info_.is_direct()) {
698 NOTREACHED(); 728 NOTREACHED();
699 // TODO(rch): support QUIC proxies. 729 // TODO(rch): support QUIC proxies.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 // Disable revocation checking for HTTPS proxies since the revocation 794 // Disable revocation checking for HTTPS proxies since the revocation
765 // requests are probably going to need to go through the proxy too. 795 // requests are probably going to need to go through the proxy too.
766 proxy_ssl_config_.rev_checking_enabled = false; 796 proxy_ssl_config_.rev_checking_enabled = false;
767 } 797 }
768 if (using_ssl_) { 798 if (using_ssl_) {
769 InitSSLConfig(origin_, &server_ssl_config_, 799 InitSSLConfig(origin_, &server_ssl_config_,
770 false /* not a proxy server */); 800 false /* not a proxy server */);
771 } 801 }
772 802
773 if (IsPreconnecting()) { 803 if (IsPreconnecting()) {
804 DCHECK(!stream_factory_->for_websockets_);
774 return PreconnectSocketsForHttpRequest( 805 return PreconnectSocketsForHttpRequest(
775 origin_url_, 806 origin_url_,
776 request_info_.extra_headers, 807 request_info_.extra_headers,
777 request_info_.load_flags, 808 request_info_.load_flags,
778 priority_, 809 priority_,
779 session_, 810 session_,
780 proxy_info_, 811 proxy_info_,
781 ShouldForceSpdySSL(), 812 ShouldForceSpdySSL(),
782 want_spdy_over_npn, 813 want_spdy_over_npn,
783 server_ssl_config_, 814 server_ssl_config_,
784 proxy_ssl_config_, 815 proxy_ssl_config_,
785 request_info_.privacy_mode, 816 request_info_.privacy_mode,
786 net_log_, 817 net_log_,
787 num_streams_); 818 num_streams_);
788 } else { 819 } else {
789 // If we can't use a SPDY session, don't both checking for one after 820 // If we can't use a SPDY session, don't both checking for one after
790 // the hostname is resolved. 821 // the hostname is resolved.
791 OnHostResolutionCallback resolution_callback = CanUseExistingSpdySession() ? 822 OnHostResolutionCallback resolution_callback = CanUseExistingSpdySession() ?
792 base::Bind(&Job::OnHostResolution, session_->spdy_session_pool(), 823 base::Bind(&Job::OnHostResolution, session_->spdy_session_pool(),
793 GetSpdySessionKey()) : 824 GetSpdySessionKey()) :
794 OnHostResolutionCallback(); 825 OnHostResolutionCallback();
795 return InitSocketHandleForHttpRequest( 826 return InitSocketHandleForHttpRequest(
796 origin_url_, request_info_.extra_headers, request_info_.load_flags, 827 origin_url_, request_info_.extra_headers, request_info_.load_flags,
797 priority_, session_, proxy_info_, ShouldForceSpdySSL(), 828 priority_, session_, proxy_info_, ShouldForceSpdySSL(),
798 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, 829 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_,
799 request_info_.privacy_mode, net_log_, 830 request_info_.privacy_mode, net_log_,
800 connection_.get(), resolution_callback, io_callback_); 831 connection_.get(), resolution_callback, io_callback_);
801 } 832 }
802 } 833 }
803 834
804 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { 835 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
805 if (IsPreconnecting()) { 836 if (IsPreconnecting()) {
806 if (using_quic_) 837 if (using_quic_)
807 return result; 838 return result;
808 DCHECK_EQ(OK, result); 839 DCHECK_EQ(OK, result);
809 return OK; 840 return OK;
810 } 841 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 if (ssl_socket->WasNpnNegotiated()) { 885 if (ssl_socket->WasNpnNegotiated()) {
855 was_npn_negotiated_ = true; 886 was_npn_negotiated_ = true;
856 std::string proto; 887 std::string proto;
857 std::string server_protos; 888 std::string server_protos;
858 SSLClientSocket::NextProtoStatus status = 889 SSLClientSocket::NextProtoStatus status =
859 ssl_socket->GetNextProto(&proto, &server_protos); 890 ssl_socket->GetNextProto(&proto, &server_protos);
860 NextProto protocol_negotiated = 891 NextProto protocol_negotiated =
861 SSLClientSocket::NextProtoFromString(proto); 892 SSLClientSocket::NextProtoFromString(proto);
862 protocol_negotiated_ = protocol_negotiated; 893 protocol_negotiated_ = protocol_negotiated;
863 net_log_.AddEvent( 894 net_log_.AddEvent(
864 NetLog::TYPE_HTTP_STREAM_REQUEST_PROTO, 895 NetLog::TYPE_HTTP_STREAM_REQUEST_PROTO,
865 base::Bind(&NetLogHttpStreamProtoCallback, 896 base::Bind(&NetLogHttpStreamProtoCallback,
866 status, &proto, &server_protos)); 897 status, &proto, &server_protos));
867 if (ssl_socket->was_spdy_negotiated()) 898 if (ssl_socket->was_spdy_negotiated())
868 SwitchToSpdyMode(); 899 SwitchToSpdyMode();
869 } 900 }
870 if (ShouldForceSpdySSL()) 901 if (ShouldForceSpdySSL())
871 SwitchToSpdyMode(); 902 SwitchToSpdyMode();
872 } else if (proxy_info_.is_https() && connection_->socket() && 903 } else if (proxy_info_.is_https() && connection_->socket() &&
873 result == OK) { 904 result == OK) {
874 ProxyClientSocket* proxy_socket = 905 ProxyClientSocket* proxy_socket =
875 static_cast<ProxyClientSocket*>(connection_->socket()); 906 static_cast<ProxyClientSocket*>(connection_->socket());
876 if (proxy_socket->IsUsingSpdy()) { 907 if (proxy_socket->IsUsingSpdy()) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 if (connection_->socket() && !connection_->is_reused()) 1003 if (connection_->socket() && !connection_->is_reused())
973 SetSocketMotivation(); 1004 SetSocketMotivation();
974 1005
975 if (!using_spdy_) { 1006 if (!using_spdy_) {
976 // We may get ftp scheme when fetching ftp resources through proxy. 1007 // We may get ftp scheme when fetching ftp resources through proxy.
977 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && 1008 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) &&
978 (request_info_.url.SchemeIs("http") || 1009 (request_info_.url.SchemeIs("http") ||
979 request_info_.url.SchemeIs("ftp")); 1010 request_info_.url.SchemeIs("ftp"));
980 if (stream_factory_->http_pipelined_host_pool_. 1011 if (stream_factory_->http_pipelined_host_pool_.
981 IsExistingPipelineAvailableForKey(*http_pipelining_key_.get())) { 1012 IsExistingPipelineAvailableForKey(*http_pipelining_key_.get())) {
1013 DCHECK(!stream_factory_->for_websockets_);
982 stream_.reset(stream_factory_->http_pipelined_host_pool_. 1014 stream_.reset(stream_factory_->http_pipelined_host_pool_.
983 CreateStreamOnExistingPipeline( 1015 CreateStreamOnExistingPipeline(
984 *http_pipelining_key_.get())); 1016 *http_pipelining_key_.get()));
985 CHECK(stream_.get()); 1017 CHECK(stream_.get());
1018 } else if (stream_factory_->for_websockets_) {
1019 DCHECK(request_ && request_->websocket_stream_factory());
1020 websocket_stream_.reset(
1021 request_->websocket_stream_factory()->CreateBasicStream(
1022 connection_.release(), using_proxy));
986 } else if (!using_proxy && IsRequestEligibleForPipelining()) { 1023 } else if (!using_proxy && IsRequestEligibleForPipelining()) {
987 // TODO(simonjam): Support proxies. 1024 // TODO(simonjam): Support proxies.
988 stream_.reset( 1025 stream_.reset(
989 stream_factory_->http_pipelined_host_pool_.CreateStreamOnNewPipeline( 1026 stream_factory_->http_pipelined_host_pool_.CreateStreamOnNewPipeline(
990 *http_pipelining_key_.get(), 1027 *http_pipelining_key_.get(),
991 connection_.release(), 1028 connection_.release(),
992 server_ssl_config_, 1029 server_ssl_config_,
993 proxy_info_, 1030 proxy_info_,
994 net_log_, 1031 net_log_,
995 was_npn_negotiated_, 1032 was_npn_negotiated_,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 } 1081 }
1045 } 1082 }
1046 1083
1047 if (spdy_session->IsClosed()) 1084 if (spdy_session->IsClosed())
1048 return ERR_CONNECTION_CLOSED; 1085 return ERR_CONNECTION_CLOSED;
1049 1086
1050 // TODO(willchan): Delete this code, because eventually, the 1087 // TODO(willchan): Delete this code, because eventually, the
1051 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it 1088 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it
1052 // will know when SpdySessions become available. 1089 // will know when SpdySessions become available.
1053 1090
1054 bool use_relative_url = direct || request_info_.url.SchemeIs("https"); 1091 if (stream_factory_->for_websockets_) {
1055 stream_.reset(new SpdyHttpStream(spdy_session, use_relative_url)); 1092 bool use_relative_url = direct || request_info_.url.SchemeIs("wss");
1093 websocket_stream_.reset(
1094 request_->websocket_stream_factory()->CreateSpdyStream(
1095 spdy_session, use_relative_url));
1096 } else {
1097 bool use_relative_url = direct || request_info_.url.SchemeIs("https");
1098 stream_.reset(new SpdyHttpStream(spdy_session, use_relative_url));
1099 }
1056 return OK; 1100 return OK;
1057 } 1101 }
1058 1102
1059 int HttpStreamFactoryImpl::Job::DoCreateStreamComplete(int result) { 1103 int HttpStreamFactoryImpl::Job::DoCreateStreamComplete(int result) {
1060 if (result < 0) 1104 if (result < 0)
1061 return result; 1105 return result;
1062 1106
1063 session_->proxy_service()->ReportSuccess(proxy_info_); 1107 session_->proxy_service()->ReportSuccess(proxy_info_);
1064 next_state_ = STATE_NONE; 1108 next_state_ = STATE_NONE;
1065 return OK; 1109 return OK;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 } 1390 }
1347 1391
1348 bool HttpStreamFactoryImpl::Job::IsOrphaned() const { 1392 bool HttpStreamFactoryImpl::Job::IsOrphaned() const {
1349 return !IsPreconnecting() && !request_; 1393 return !IsPreconnecting() && !request_;
1350 } 1394 }
1351 1395
1352 bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() { 1396 bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() {
1353 if (IsPreconnecting() || !request_) { 1397 if (IsPreconnecting() || !request_) {
1354 return false; 1398 return false;
1355 } 1399 }
1400 if (stream_factory_->for_websockets_) {
1401 return false;
1402 }
1356 if (session_->force_http_pipelining()) { 1403 if (session_->force_http_pipelining()) {
1357 return true; 1404 return true;
1358 } 1405 }
1359 if (!session_->params().http_pipelining_enabled) { 1406 if (!session_->params().http_pipelining_enabled) {
1360 return false; 1407 return false;
1361 } 1408 }
1362 if (using_ssl_) { 1409 if (using_ssl_) {
1363 return false; 1410 return false;
1364 } 1411 }
1365 if (request_info_.method != "GET" && request_info_.method != "HEAD") { 1412 if (request_info_.method != "GET" && request_info_.method != "HEAD") {
1366 return false; 1413 return false;
1367 } 1414 }
1368 if (request_info_.load_flags & 1415 if (request_info_.load_flags &
1369 (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH | 1416 (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH |
1370 net::LOAD_IS_DOWNLOAD)) { 1417 net::LOAD_IS_DOWNLOAD)) {
1371 // Avoid pipelining resources that may be streamed for a long time. 1418 // Avoid pipelining resources that may be streamed for a long time.
1372 return false; 1419 return false;
1373 } 1420 }
1374 return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining( 1421 return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining(
1375 *http_pipelining_key_.get()); 1422 *http_pipelining_key_.get());
1376 } 1423 }
1377 1424
1378 } // namespace net 1425 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698