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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 } | 711 } |
712 | 712 |
713 bool HttpStreamFactoryImpl::Job::ShouldForceSpdyWithoutSSL() const { | 713 bool HttpStreamFactoryImpl::Job::ShouldForceSpdyWithoutSSL() const { |
714 bool rv = session_->params().force_spdy_always && | 714 bool rv = session_->params().force_spdy_always && |
715 !session_->params().force_spdy_over_ssl; | 715 !session_->params().force_spdy_over_ssl; |
716 return rv && !session_->HasSpdyExclusion(origin_); | 716 return rv && !session_->HasSpdyExclusion(origin_); |
717 } | 717 } |
718 | 718 |
719 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { | 719 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { |
720 return session_->params().enable_quic && | 720 return session_->params().enable_quic && |
721 session_->params().origin_to_force_quic_on.Equals(origin_) && | 721 session_->params().origin_to_force_quic_on.Equals(origin_) && |
722 proxy_info_.is_direct(); | 722 proxy_info_.is_direct() && |
723 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0; | |
Ryan Hamilton
2015/03/06 23:19:52
This method is also only called from a command lin
| |
723 } | 724 } |
724 | 725 |
725 int HttpStreamFactoryImpl::Job::DoWaitForJob() { | 726 int HttpStreamFactoryImpl::Job::DoWaitForJob() { |
726 DCHECK(blocking_job_); | 727 DCHECK(blocking_job_); |
727 next_state_ = STATE_WAIT_FOR_JOB_COMPLETE; | 728 next_state_ = STATE_WAIT_FOR_JOB_COMPLETE; |
728 return ERR_IO_PENDING; | 729 return ERR_IO_PENDING; |
729 } | 730 } |
730 | 731 |
731 int HttpStreamFactoryImpl::Job::DoWaitForJobComplete(int result) { | 732 int HttpStreamFactoryImpl::Job::DoWaitForJobComplete(int result) { |
732 DCHECK(!blocking_job_); | 733 DCHECK(!blocking_job_); |
733 DCHECK_EQ(OK, result); | 734 DCHECK_EQ(OK, result); |
734 next_state_ = STATE_INIT_CONNECTION; | 735 next_state_ = STATE_INIT_CONNECTION; |
735 return OK; | 736 return OK; |
736 } | 737 } |
737 | 738 |
738 int HttpStreamFactoryImpl::Job::DoInitConnection() { | 739 int HttpStreamFactoryImpl::Job::DoInitConnection() { |
739 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. | 740 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. |
740 tracked_objects::ScopedTracker tracking_profile( | 741 tracked_objects::ScopedTracker tracking_profile( |
741 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 742 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
742 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); | 743 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); |
743 DCHECK(!blocking_job_); | 744 DCHECK(!blocking_job_); |
744 DCHECK(!connection_->is_initialized()); | 745 DCHECK(!connection_->is_initialized()); |
745 DCHECK(proxy_info_.proxy_server().is_valid()); | 746 DCHECK(proxy_info_.proxy_server().is_valid()); |
746 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 747 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
747 | 748 |
748 using_ssl_ = request_info_.url.SchemeIs("https") || | 749 using_ssl_ = request_info_.url.SchemeIs("https") || |
749 request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL(); | 750 request_info_.url.SchemeIs("wss") || ShouldForceSpdySSL(); |
751 DCHECK(!using_ssl_ || | |
752 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0); | |
753 | |
750 using_spdy_ = false; | 754 using_spdy_ = false; |
751 | 755 |
752 if (ShouldForceQuic()) | 756 if (ShouldForceQuic()) |
753 using_quic_ = true; | 757 using_quic_ = true; |
754 | 758 |
755 DCHECK(!using_quic_ || session_->params().enable_quic); | 759 DCHECK(!using_quic_ || session_->params().enable_quic); |
760 DCHECK(!using_quic_ || | |
761 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0); | |
756 | 762 |
757 if (proxy_info_.is_quic()) { | 763 if (proxy_info_.is_quic()) { |
758 using_quic_ = true; | 764 using_quic_ = true; |
759 DCHECK(session_->params().enable_quic_for_proxies); | 765 DCHECK(session_->params().enable_quic_for_proxies); |
760 } | 766 } |
761 | 767 |
762 if (using_quic_) { | 768 if (using_quic_) { |
763 if (proxy_info_.is_quic() && !request_info_.url.SchemeIs("http")) { | 769 if (proxy_info_.is_quic() && !request_info_.url.SchemeIs("http")) { |
764 NOTREACHED(); | 770 NOTREACHED(); |
765 // TODO(rch): support QUIC proxies for HTTPS urls. | 771 // TODO(rch): support QUIC proxies for HTTPS urls. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 return OK; | 804 return OK; |
799 using_spdy_ = true; | 805 using_spdy_ = true; |
800 next_state_ = STATE_CREATE_STREAM; | 806 next_state_ = STATE_CREATE_STREAM; |
801 existing_spdy_session_ = spdy_session; | 807 existing_spdy_session_ = spdy_session; |
802 return OK; | 808 return OK; |
803 } else if (request_ && !request_->HasSpdySessionKey() && | 809 } else if (request_ && !request_->HasSpdySessionKey() && |
804 (using_ssl_ || ShouldForceSpdyWithoutSSL())) { | 810 (using_ssl_ || ShouldForceSpdyWithoutSSL())) { |
805 // Update the spdy session key for the request that launched this job. | 811 // Update the spdy session key for the request that launched this job. |
806 request_->SetSpdySessionKey(spdy_session_key); | 812 request_->SetSpdySessionKey(spdy_session_key); |
807 } | 813 } |
814 DCHECK(!using_spdy_ || | |
815 (request_info_.load_flags & LOAD_UNENCRYPTED_HTTP11) == 0); | |
808 | 816 |
809 // OK, there's no available SPDY session. Let |waiting_job_| resume if it's | 817 // OK, there's no available SPDY session. Let |waiting_job_| resume if it's |
810 // paused. | 818 // paused. |
811 | 819 |
812 if (waiting_job_) { | 820 if (waiting_job_) { |
813 waiting_job_->Resume(this); | 821 waiting_job_->Resume(this); |
814 waiting_job_ = NULL; | 822 waiting_job_ = NULL; |
815 } | 823 } |
816 | 824 |
817 if (proxy_info_.is_http() || proxy_info_.is_https()) | 825 if (proxy_info_.is_http() || proxy_info_.is_https()) |
(...skipping 684 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 |