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 #include "net/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 if (blocking_job_) | 700 if (blocking_job_) |
701 next_state_ = STATE_WAIT_FOR_JOB; | 701 next_state_ = STATE_WAIT_FOR_JOB; |
702 else | 702 else |
703 next_state_ = STATE_INIT_CONNECTION; | 703 next_state_ = STATE_INIT_CONNECTION; |
704 return OK; | 704 return OK; |
705 } | 705 } |
706 | 706 |
707 bool HttpStreamFactoryImpl::Job::ShouldForceSpdySSL() const { | 707 bool HttpStreamFactoryImpl::Job::ShouldForceSpdySSL() const { |
708 bool rv = session_->params().force_spdy_always && | 708 bool rv = session_->params().force_spdy_always && |
709 session_->params().force_spdy_over_ssl; | 709 session_->params().force_spdy_over_ssl; |
710 return rv && !session_->HasSpdyExclusion(origin_); | 710 return rv && !session_->HasSpdyExclusion(origin_) && |
711 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0; | |
711 } | 712 } |
712 | 713 |
713 bool HttpStreamFactoryImpl::Job::ShouldForceSpdyWithoutSSL() const { | 714 bool HttpStreamFactoryImpl::Job::ShouldForceSpdyWithoutSSL() const { |
714 bool rv = session_->params().force_spdy_always && | 715 bool rv = session_->params().force_spdy_always && |
715 !session_->params().force_spdy_over_ssl; | 716 !session_->params().force_spdy_over_ssl; |
716 return rv && !session_->HasSpdyExclusion(origin_); | 717 return rv && !session_->HasSpdyExclusion(origin_) && |
718 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0; | |
717 } | 719 } |
718 | 720 |
719 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { | 721 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { |
720 return session_->params().enable_quic && | 722 return session_->params().enable_quic && |
721 session_->params().origin_to_force_quic_on.Equals(origin_) && | 723 session_->params().origin_to_force_quic_on.Equals(origin_) && |
722 proxy_info_.is_direct(); | 724 proxy_info_.is_direct() && |
725 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0; | |
723 } | 726 } |
724 | 727 |
725 int HttpStreamFactoryImpl::Job::DoWaitForJob() { | 728 int HttpStreamFactoryImpl::Job::DoWaitForJob() { |
726 DCHECK(blocking_job_); | 729 DCHECK(blocking_job_); |
727 next_state_ = STATE_WAIT_FOR_JOB_COMPLETE; | 730 next_state_ = STATE_WAIT_FOR_JOB_COMPLETE; |
728 return ERR_IO_PENDING; | 731 return ERR_IO_PENDING; |
729 } | 732 } |
730 | 733 |
731 int HttpStreamFactoryImpl::Job::DoWaitForJobComplete(int result) { | 734 int HttpStreamFactoryImpl::Job::DoWaitForJobComplete(int result) { |
732 DCHECK(!blocking_job_); | 735 DCHECK(!blocking_job_); |
733 DCHECK_EQ(OK, result); | 736 DCHECK_EQ(OK, result); |
734 next_state_ = STATE_INIT_CONNECTION; | 737 next_state_ = STATE_INIT_CONNECTION; |
735 return OK; | 738 return OK; |
736 } | 739 } |
737 | 740 |
738 int HttpStreamFactoryImpl::Job::DoInitConnection() { | 741 int HttpStreamFactoryImpl::Job::DoInitConnection() { |
739 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. | 742 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. |
740 tracked_objects::ScopedTracker tracking_profile( | 743 tracked_objects::ScopedTracker tracking_profile( |
741 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 744 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
742 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); | 745 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); |
743 DCHECK(!blocking_job_); | 746 DCHECK(!blocking_job_); |
744 DCHECK(!connection_->is_initialized()); | 747 DCHECK(!connection_->is_initialized()); |
745 DCHECK(proxy_info_.proxy_server().is_valid()); | 748 DCHECK(proxy_info_.proxy_server().is_valid()); |
746 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 749 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
747 | 750 |
748 using_ssl_ = request_info_.url.SchemeIs("https") || | 751 using_ssl_ = (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0 && |
sclittle
2015/03/04 21:35:23
What happens if the load flag is set for a https U
tbansal1
2015/03/06 19:57:40
Done.
| |
749 request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL(); | 752 (request_info_.url.SchemeIs("https") || |
753 request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL()); | |
Ryan Hamilton
2015/03/05 01:43:57
This definitely seems wrong. If HTTP11 is required
tbansal1
2015/03/06 19:57:40
Done.
| |
750 using_spdy_ = false; | 754 using_spdy_ = false; |
751 | 755 |
756 base::WeakPtr<HttpServerProperties> http_server_properties = | |
757 session_->http_server_properties(); | |
758 if (http_server_properties) | |
759 if ((request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) != 0) | |
760 http_server_properties->SetHTTP11Required(origin_); | |
sclittle
2015/03/04 21:35:23
Won't this also force all future requests to this
tbansal1
2015/03/06 19:57:40
Done.
| |
761 | |
752 if (ShouldForceQuic()) | 762 if (ShouldForceQuic()) |
753 using_quic_ = true; | 763 using_quic_ = true; |
754 | 764 |
755 DCHECK(!using_quic_ || session_->params().enable_quic); | 765 DCHECK(!using_quic_ || session_->params().enable_quic); |
756 | 766 |
757 if (proxy_info_.is_quic()) { | 767 if (proxy_info_.is_quic()) { |
758 using_quic_ = true; | 768 using_quic_ = true; |
759 DCHECK(session_->params().enable_quic_for_proxies); | 769 DCHECK(session_->params().enable_quic_for_proxies); |
760 } | 770 } |
761 | 771 |
(...skipping 22 matching lines...) Expand all Loading... | |
784 } | 794 } |
785 return rv; | 795 return rv; |
786 } | 796 } |
787 | 797 |
788 // Check first if we have a spdy session for this group. If so, then go | 798 // Check first if we have a spdy session for this group. If so, then go |
789 // straight to using that. | 799 // straight to using that. |
790 SpdySessionKey spdy_session_key = GetSpdySessionKey(); | 800 SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
791 base::WeakPtr<SpdySession> spdy_session = | 801 base::WeakPtr<SpdySession> spdy_session = |
792 session_->spdy_session_pool()->FindAvailableSession( | 802 session_->spdy_session_pool()->FindAvailableSession( |
793 spdy_session_key, net_log_); | 803 spdy_session_key, net_log_); |
794 if (spdy_session && CanUseExistingSpdySession()) { | 804 if (spdy_session && CanUseExistingSpdySession()) { |
sclittle
2015/03/04 21:35:23
What if there's an existing SPDY session? Could it
tbansal1
2015/03/06 19:57:40
Done.
| |
795 // If we're preconnecting, but we already have a SpdySession, we don't | 805 // If we're preconnecting, but we already have a SpdySession, we don't |
796 // actually need to preconnect any sockets, so we're done. | 806 // actually need to preconnect any sockets, so we're done. |
797 if (IsPreconnecting()) | 807 if (IsPreconnecting()) |
798 return OK; | 808 return OK; |
799 using_spdy_ = true; | 809 using_spdy_ = true; |
800 next_state_ = STATE_CREATE_STREAM; | 810 next_state_ = STATE_CREATE_STREAM; |
801 existing_spdy_session_ = spdy_session; | 811 existing_spdy_session_ = spdy_session; |
802 return OK; | 812 return OK; |
803 } else if (request_ && !request_->HasSpdySessionKey() && | 813 } else if (request_ && !request_->HasSpdySessionKey() && |
804 (using_ssl_ || ShouldForceSpdyWithoutSSL())) { | 814 (using_ssl_ || ShouldForceSpdyWithoutSSL())) { |
(...skipping 20 matching lines...) Expand all Loading... | |
825 true /* is a proxy server */); | 835 true /* is a proxy server */); |
826 // Disable revocation checking for HTTPS proxies since the revocation | 836 // Disable revocation checking for HTTPS proxies since the revocation |
827 // requests are probably going to need to go through the proxy too. | 837 // requests are probably going to need to go through the proxy too. |
828 proxy_ssl_config_.rev_checking_enabled = false; | 838 proxy_ssl_config_.rev_checking_enabled = false; |
829 } | 839 } |
830 if (using_ssl_) { | 840 if (using_ssl_) { |
831 InitSSLConfig(origin_, &server_ssl_config_, | 841 InitSSLConfig(origin_, &server_ssl_config_, |
832 false /* not a proxy server */); | 842 false /* not a proxy server */); |
833 } | 843 } |
834 | 844 |
835 base::WeakPtr<HttpServerProperties> http_server_properties = | |
836 session_->http_server_properties(); | |
837 if (http_server_properties) { | 845 if (http_server_properties) { |
838 http_server_properties->MaybeForceHTTP11(origin_, &server_ssl_config_); | 846 http_server_properties->MaybeForceHTTP11(origin_, &server_ssl_config_); |
839 if (proxy_info_.is_http() || proxy_info_.is_https()) { | 847 if (proxy_info_.is_http() || proxy_info_.is_https()) { |
840 http_server_properties->MaybeForceHTTP11( | 848 http_server_properties->MaybeForceHTTP11( |
841 proxy_info_.proxy_server().host_port_pair(), &proxy_ssl_config_); | 849 proxy_info_.proxy_server().host_port_pair(), &proxy_ssl_config_); |
842 } | 850 } |
843 } | 851 } |
844 | 852 |
845 if (IsPreconnecting()) { | 853 if (IsPreconnecting()) { |
846 DCHECK(!stream_factory_->for_websockets_); | 854 DCHECK(!stream_factory_->for_websockets_); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1502 | 1510 |
1503 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { | 1511 if (job_status_ == STATUS_SUCCEEDED && other_job_status_ == STATUS_BROKEN) { |
1504 HistogramBrokenAlternateProtocolLocation( | 1512 HistogramBrokenAlternateProtocolLocation( |
1505 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); | 1513 BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN); |
1506 session_->http_server_properties()->SetBrokenAlternateProtocol( | 1514 session_->http_server_properties()->SetBrokenAlternateProtocol( |
1507 HostPortPair::FromURL(request_info_.url)); | 1515 HostPortPair::FromURL(request_info_.url)); |
1508 } | 1516 } |
1509 } | 1517 } |
1510 | 1518 |
1511 } // namespace net | 1519 } // namespace net |
OLD | NEW |