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

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

Issue 3417010: Integrate the SpdyProxyClientSocket into the HttpStreamRequest... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rebasing again Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_stream_request.h ('k') | net/socket/socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_request.h" 5 #include "net/http/http_stream_request.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // Check first if we have a spdy session for this group. If so, then go 453 // Check first if we have a spdy session for this group. If so, then go
454 // straight to using that. 454 // straight to using that.
455 HostPortProxyPair pair(endpoint_, proxy_info()->proxy_server()); 455 HostPortProxyPair pair(endpoint_, proxy_info()->proxy_server());
456 if (session_->spdy_session_pool()->HasSession(pair)) { 456 if (session_->spdy_session_pool()->HasSession(pair)) {
457 using_spdy_ = true; 457 using_spdy_ = true;
458 next_state_ = STATE_CREATE_STREAM; 458 next_state_ = STATE_CREATE_STREAM;
459 return OK; 459 return OK;
460 } 460 }
461 // Check next if we have a spdy session for this proxy. If so, then go 461 // Check next if we have a spdy session for this proxy. If so, then go
462 // straight to using that. 462 // straight to using that.
463 if (proxy_info()->is_https()) { 463 if (IsHttpsProxyAndHttpUrl()) {
464 HostPortProxyPair proxy(proxy_info()->proxy_server().host_port_pair(), 464 HostPortProxyPair proxy(proxy_info()->proxy_server().host_port_pair(),
465 proxy_info()->proxy_server()); 465 ProxyServer::Direct());
466 if (session_->spdy_session_pool()->HasSession(proxy)) { 466 if (session_->spdy_session_pool()->HasSession(proxy)) {
467 using_spdy_ = true; 467 using_spdy_ = true;
468 next_state_ = STATE_CREATE_STREAM; 468 next_state_ = STATE_CREATE_STREAM;
469 return OK; 469 return OK;
470 } 470 }
471 } 471 }
472 472
473 // Build the string used to uniquely identify connections of this type. 473 // Build the string used to uniquely identify connections of this type.
474 // Determine the host and port to connect to. 474 // Determine the host and port to connect to.
475 std::string connection_group = endpoint_.ToString(); 475 std::string connection_group = endpoint_.ToString();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 530 }
531 531
532 http_proxy_params = 532 http_proxy_params =
533 new HttpProxySocketParams(proxy_tcp_params, 533 new HttpProxySocketParams(proxy_tcp_params,
534 ssl_params, 534 ssl_params,
535 authentication_url, 535 authentication_url,
536 user_agent, 536 user_agent,
537 endpoint_, 537 endpoint_,
538 session_->auth_cache(), 538 session_->auth_cache(),
539 session_->http_auth_handler_factory(), 539 session_->http_auth_handler_factory(),
540 session_->spdy_session_pool(),
541 session_->mutable_spdy_settings(),
540 using_ssl_); 542 using_ssl_);
541 } else { 543 } else {
542 DCHECK(proxy_info()->is_socks()); 544 DCHECK(proxy_info()->is_socks());
543 char socks_version; 545 char socks_version;
544 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) 546 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5)
545 socks_version = '5'; 547 socks_version = '5';
546 else 548 else
547 socks_version = '4'; 549 socks_version = '4';
548 connection_group = base::StringPrintf( 550 connection_group = base::StringPrintf(
549 "socks%c/%s", socks_version, connection_group.c_str()); 551 "socks%c/%s", socks_version, connection_group.c_str());
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 SpdySessionPool* spdy_pool = session_->spdy_session_pool(); 720 SpdySessionPool* spdy_pool = session_->spdy_session_pool();
719 scoped_refptr<SpdySession> spdy_session; 721 scoped_refptr<SpdySession> spdy_session;
720 722
721 const ProxyServer& proxy_server = proxy_info()->proxy_server(); 723 const ProxyServer& proxy_server = proxy_info()->proxy_server();
722 HostPortProxyPair pair(endpoint_, proxy_server); 724 HostPortProxyPair pair(endpoint_, proxy_server);
723 if (spdy_pool->HasSession(pair)) { 725 if (spdy_pool->HasSession(pair)) {
724 // We have a SPDY session to the origin server. This might be a direct 726 // We have a SPDY session to the origin server. This might be a direct
725 // connection, or it might be a SPDY session through an HTTP or HTTPS proxy. 727 // connection, or it might be a SPDY session through an HTTP or HTTPS proxy.
726 spdy_session = 728 spdy_session =
727 spdy_pool->Get(pair, session_->mutable_spdy_settings(), net_log_); 729 spdy_pool->Get(pair, session_->mutable_spdy_settings(), net_log_);
728 } else if (proxy_info()->is_https()) { 730 } else if (IsHttpsProxyAndHttpUrl()) {
729 // If we don't have a direct SPDY session, and we're using an HTTPS 731 // If we don't have a direct SPDY session, and we're using an HTTPS
730 // proxy, then we might have a SPDY session to the proxy 732 // proxy, then we might have a SPDY session to the proxy
731 pair = HostPortProxyPair(proxy_server.host_port_pair(), proxy_server); 733 pair = HostPortProxyPair(proxy_server.host_port_pair(),
734 ProxyServer::Direct());
732 if (spdy_pool->HasSession(pair)) { 735 if (spdy_pool->HasSession(pair)) {
733 spdy_session = 736 spdy_session =
734 spdy_pool->Get(pair, session_->mutable_spdy_settings(), net_log_); 737 spdy_pool->Get(pair, session_->mutable_spdy_settings(), net_log_);
735 } 738 }
736 direct = false; 739 direct = false;
737 } 740 }
738 741
739 if (!spdy_session.get()) { 742 if (!spdy_session.get()) {
740 // SPDY can be negotiated using the TLS next protocol negotiation (NPN) 743 // SPDY can be negotiated using the TLS next protocol negotiation (NPN)
741 // extension, or just directly using SSL. Either way, |connection_| must 744 // extension, or just directly using SSL. Either way, |connection_| must
742 // contain an SSLClientSocket. 745 // contain an SSLClientSocket.
743 CHECK(connection_->socket()); 746 CHECK(connection_->socket());
744 int error = spdy_pool->GetSpdySessionFromSocket( 747 int error = spdy_pool->GetSpdySessionFromSocket(
745 pair, session_->mutable_spdy_settings(), connection_.release(), 748 pair, session_->mutable_spdy_settings(), connection_.release(),
746 net_log_, spdy_certificate_error_, &spdy_session, using_ssl_); 749 net_log_, spdy_certificate_error_, &spdy_session, using_ssl_);
747 if (error != OK) 750 if (error != OK)
748 return error; 751 return error;
749 } 752 }
750 753
751 if (spdy_session->IsClosed()) 754 if (spdy_session->IsClosed())
752 return ERR_CONNECTION_CLOSED; 755 return ERR_CONNECTION_CLOSED;
753 756
754 stream_.reset(new SpdyHttpStream(spdy_session, direct)); 757 bool useRelativeUrl = direct || request_info().url.SchemeIs("https");
willchan no longer on Chromium 2010/12/02 22:44:31 is this WebKit style sneaking in here? :P s/useRel
758 stream_.reset(new SpdyHttpStream(spdy_session, useRelativeUrl));
755 return OK; 759 return OK;
756 } 760 }
757 761
758 int HttpStreamRequest::DoCreateStreamComplete(int result) { 762 int HttpStreamRequest::DoCreateStreamComplete(int result) {
759 if (result < 0) 763 if (result < 0)
760 return result; 764 return result;
761 765
762 next_state_ = STATE_NONE; 766 next_state_ = STATE_NONE;
763 return OK; 767 return OK;
764 } 768 }
(...skipping 26 matching lines...) Expand all
791 } 795 }
792 796
793 void HttpStreamRequest::SetSocketMotivation() { 797 void HttpStreamRequest::SetSocketMotivation() {
794 if (request_info_->motivation == HttpRequestInfo::PRECONNECT_MOTIVATED) 798 if (request_info_->motivation == HttpRequestInfo::PRECONNECT_MOTIVATED)
795 connection_->socket()->SetSubresourceSpeculation(); 799 connection_->socket()->SetSubresourceSpeculation();
796 else if (request_info_->motivation == HttpRequestInfo::OMNIBOX_MOTIVATED) 800 else if (request_info_->motivation == HttpRequestInfo::OMNIBOX_MOTIVATED)
797 connection_->socket()->SetOmniboxSpeculation(); 801 connection_->socket()->SetOmniboxSpeculation();
798 // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED). 802 // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED).
799 } 803 }
800 804
805 bool HttpStreamRequest::IsHttpsProxyAndHttpUrl() {
806 return proxy_info()->is_https() && request_info().url.SchemeIs("http");
807 }
808
801 // Returns a newly create SSLSocketParams, and sets several 809 // Returns a newly create SSLSocketParams, and sets several
802 // fields of ssl_config_. 810 // fields of ssl_config_.
803 scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSslParams( 811 scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSslParams(
804 scoped_refptr<TCPSocketParams> tcp_params, 812 scoped_refptr<TCPSocketParams> tcp_params,
805 scoped_refptr<HttpProxySocketParams> http_proxy_params, 813 scoped_refptr<HttpProxySocketParams> http_proxy_params,
806 scoped_refptr<SOCKSSocketParams> socks_params, 814 scoped_refptr<SOCKSSocketParams> socks_params,
807 ProxyServer::Scheme proxy_scheme, 815 ProxyServer::Scheme proxy_scheme,
808 std::string hostname, 816 std::string hostname,
809 bool want_spdy_over_npn) { 817 bool want_spdy_over_npn) {
810 818
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 base::TimeDelta::FromMinutes(6), 1014 base::TimeDelta::FromMinutes(6),
1007 100); 1015 100);
1008 break; 1016 break;
1009 default: 1017 default:
1010 NOTREACHED(); 1018 NOTREACHED();
1011 break; 1019 break;
1012 } 1020 }
1013 } 1021 }
1014 1022
1015 } // namespace net 1023 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_request.h ('k') | net/socket/socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698