| 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 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), | 196 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), |
| 197 connection_(new ClientSocketHandle), | 197 connection_(new ClientSocketHandle), |
| 198 session_(session), | 198 session_(session), |
| 199 next_state_(STATE_NONE), | 199 next_state_(STATE_NONE), |
| 200 pac_request_(NULL), | 200 pac_request_(NULL), |
| 201 destination_(destination), | 201 destination_(destination), |
| 202 origin_url_(origin_url), | 202 origin_url_(origin_url), |
| 203 alternative_service_(alternative_service), | 203 alternative_service_(alternative_service), |
| 204 job_controller_(job_controller), | 204 job_controller_(job_controller), |
| 205 job_type_(job_type), | 205 job_type_(job_type), |
| 206 blocking_job_(NULL), | |
| 207 waiting_job_(NULL), | |
| 208 using_ssl_(false), | 206 using_ssl_(false), |
| 209 using_spdy_(false), | 207 using_spdy_(false), |
| 210 using_quic_(false), | 208 using_quic_(false), |
| 211 quic_request_(session_->quic_stream_factory()), | 209 quic_request_(session_->quic_stream_factory()), |
| 212 using_existing_quic_session_(false), | 210 using_existing_quic_session_(false), |
| 213 spdy_certificate_error_(OK), | 211 spdy_certificate_error_(OK), |
| 214 establishing_tunnel_(false), | 212 establishing_tunnel_(false), |
| 215 was_npn_negotiated_(false), | 213 was_npn_negotiated_(false), |
| 216 protocol_negotiated_(kProtoUnknown), | 214 protocol_negotiated_(kProtoUnknown), |
| 217 num_streams_(0), | 215 num_streams_(0), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 case STATE_RESOLVE_PROXY_COMPLETE: | 277 case STATE_RESOLVE_PROXY_COMPLETE: |
| 280 return session_->proxy_service()->GetLoadState(pac_request_); | 278 return session_->proxy_service()->GetLoadState(pac_request_); |
| 281 case STATE_INIT_CONNECTION_COMPLETE: | 279 case STATE_INIT_CONNECTION_COMPLETE: |
| 282 case STATE_CREATE_STREAM_COMPLETE: | 280 case STATE_CREATE_STREAM_COMPLETE: |
| 283 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); | 281 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); |
| 284 default: | 282 default: |
| 285 return LOAD_STATE_IDLE; | 283 return LOAD_STATE_IDLE; |
| 286 } | 284 } |
| 287 } | 285 } |
| 288 | 286 |
| 289 void HttpStreamFactoryImpl::Job::WaitFor(Job* job) { | |
| 290 DCHECK_EQ(STATE_NONE, next_state_); | |
| 291 DCHECK_EQ(STATE_NONE, job->next_state_); | |
| 292 DCHECK(!blocking_job_); | |
| 293 DCHECK(!job->waiting_job_); | |
| 294 | |
| 295 // Never share connection with other jobs for FTP requests. | |
| 296 DCHECK(!request_info_.url.SchemeIs("ftp")); | |
| 297 | |
| 298 blocking_job_ = job; | |
| 299 job->waiting_job_ = this; | |
| 300 } | |
| 301 | |
| 302 void HttpStreamFactoryImpl::Job::ResumeAfterDelay() { | 287 void HttpStreamFactoryImpl::Job::ResumeAfterDelay() { |
| 303 DCHECK(!blocking_job_); | 288 DCHECK((job_type_ == ALTERNATIVE || !job_controller_->blocking())); |
| 304 DCHECK_EQ(STATE_WAIT_FOR_JOB_COMPLETE, next_state_); | 289 DCHECK_EQ(STATE_WAIT_FOR_JOB_COMPLETE, next_state_); |
| 305 | 290 |
| 306 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_DELAYED, | 291 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_DELAYED, |
| 307 base::Bind(&NetLogHttpStreamJobDelayCallback, wait_time_)); | 292 base::Bind(&NetLogHttpStreamJobDelayCallback, wait_time_)); |
| 308 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 293 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 309 FROM_HERE, base::Bind(&HttpStreamFactoryImpl::Job::OnIOComplete, | 294 FROM_HERE, base::Bind(&HttpStreamFactoryImpl::Job::OnIOComplete, |
| 310 ptr_factory_.GetWeakPtr(), OK), | 295 ptr_factory_.GetWeakPtr(), OK), |
| 311 wait_time_); | 296 wait_time_); |
| 312 } | 297 } |
| 313 | 298 |
| 314 void HttpStreamFactoryImpl::Job::Resume(Job* job, | 299 void HttpStreamFactoryImpl::Job::Resume(const base::TimeDelta& delay) { |
| 315 const base::TimeDelta& delay) { | |
| 316 DCHECK_EQ(blocking_job_, job); | |
| 317 blocking_job_ = NULL; | |
| 318 | |
| 319 // If |this| job is not past STATE_WAIT_FOR_JOB_COMPLETE state, then it will | 300 // If |this| job is not past STATE_WAIT_FOR_JOB_COMPLETE state, then it will |
| 320 // be delayed by the |wait_time_| when it resumes. | 301 // be delayed by the |wait_time_| when it resumes. |
| 321 if (next_state_ == STATE_NONE || next_state_ <= STATE_WAIT_FOR_JOB_COMPLETE) | 302 if (next_state_ == STATE_NONE || next_state_ <= STATE_WAIT_FOR_JOB_COMPLETE) |
| 322 wait_time_ = delay; | 303 wait_time_ = delay; |
| 323 | 304 |
| 324 // We know we're blocked if the next_state_ is STATE_WAIT_FOR_JOB_COMPLETE. | 305 // We know we're blocked if the next_state_ is STATE_WAIT_FOR_JOB_COMPLETE. |
| 325 // Unblock |this|. | 306 // Unblock |this|. |
| 326 if (next_state_ == STATE_WAIT_FOR_JOB_COMPLETE) | 307 if (next_state_ == STATE_WAIT_FOR_JOB_COMPLETE) |
| 327 ResumeAfterDelay(); | 308 ResumeAfterDelay(); |
| 328 } | 309 } |
| 329 | 310 |
| 330 void HttpStreamFactoryImpl::Job::Orphan() { | 311 void HttpStreamFactoryImpl::Job::Orphan() { |
| 331 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_ORPHANED); | 312 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_ORPHANED); |
| 332 if (blocking_job_) { | 313 |
| 333 // We've been orphaned, but there's a job we're blocked on. Don't bother | 314 job_controller_->MaybeResumeOtherJob(this, base::TimeDelta()); |
| 334 // racing, just cancel ourself. | 315 if (job_controller_->for_websockets()) { |
| 335 DCHECK(blocking_job_->waiting_job_); | |
| 336 blocking_job_->waiting_job_ = NULL; | |
| 337 blocking_job_ = NULL; | |
| 338 if (job_controller_->for_websockets() && connection_ && | |
| 339 connection_->socket()) { | |
| 340 connection_->socket()->Disconnect(); | |
| 341 } | |
| 342 job_controller_->OnOrphanedJobComplete(this); | |
| 343 } else if (job_controller_->for_websockets()) { | |
| 344 // We cancel this job because a WebSocketHandshakeStream can't be created | 316 // We cancel this job because a WebSocketHandshakeStream can't be created |
| 345 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in | 317 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in |
| 346 // the Request class and isn't retrievable by this job. | 318 // the Request class and isn't retrievable by this job. |
| 347 if (connection_ && connection_->socket()) { | 319 if (connection_ && connection_->socket()) { |
| 348 connection_->socket()->Disconnect(); | 320 connection_->socket()->Disconnect(); |
| 349 } | 321 } |
| 350 job_controller_->OnOrphanedJobComplete(this); | 322 job_controller_->OnOrphanedJobComplete(this); |
| 351 } | 323 } |
| 352 } | 324 } |
| 353 | 325 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 523 } |
| 552 | 524 |
| 553 int HttpStreamFactoryImpl::Job::RunLoop(int result) { | 525 int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
| 554 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 526 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), |
| 555 "HttpStreamFactoryImpl::Job::RunLoop"); | 527 "HttpStreamFactoryImpl::Job::RunLoop"); |
| 556 result = DoLoop(result); | 528 result = DoLoop(result); |
| 557 | 529 |
| 558 if (result == ERR_IO_PENDING) | 530 if (result == ERR_IO_PENDING) |
| 559 return result; | 531 return result; |
| 560 | 532 |
| 561 // If there was an error, we should have already resumed the |waiting_job_|, | 533 // If there was an error, we should have already resumed the other waiting |
| 562 // if there was one. | 534 // job, if there was one. |
| 563 DCHECK(result == OK || waiting_job_ == NULL); | 535 DCHECK(result == OK || job_type_ == MAIN || !job_controller_->blocking()); |
| 564 | 536 |
| 565 if (job_type_ == PRECONNECT) { | 537 if (job_type_ == PRECONNECT) { |
| 566 base::ThreadTaskRunnerHandle::Get()->PostTask( | 538 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 567 FROM_HERE, | 539 FROM_HERE, |
| 568 base::Bind(&HttpStreamFactoryImpl::Job::OnPreconnectsComplete, | 540 base::Bind(&HttpStreamFactoryImpl::Job::OnPreconnectsComplete, |
| 569 ptr_factory_.GetWeakPtr())); | 541 ptr_factory_.GetWeakPtr())); |
| 570 return ERR_IO_PENDING; | 542 return ERR_IO_PENDING; |
| 571 } | 543 } |
| 572 | 544 |
| 573 if (IsCertificateError(result)) { | 545 if (IsCertificateError(result)) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 break; | 662 break; |
| 691 case STATE_RESOLVE_PROXY: | 663 case STATE_RESOLVE_PROXY: |
| 692 DCHECK_EQ(OK, rv); | 664 DCHECK_EQ(OK, rv); |
| 693 rv = DoResolveProxy(); | 665 rv = DoResolveProxy(); |
| 694 break; | 666 break; |
| 695 case STATE_RESOLVE_PROXY_COMPLETE: | 667 case STATE_RESOLVE_PROXY_COMPLETE: |
| 696 rv = DoResolveProxyComplete(rv); | 668 rv = DoResolveProxyComplete(rv); |
| 697 break; | 669 break; |
| 698 case STATE_WAIT_FOR_JOB: | 670 case STATE_WAIT_FOR_JOB: |
| 699 DCHECK_EQ(OK, rv); | 671 DCHECK_EQ(OK, rv); |
| 700 rv = DoWaitForJob(); | 672 rv = job_controller_->ScheduleJob(this); |
| 701 break; | 673 break; |
| 702 case STATE_WAIT_FOR_JOB_COMPLETE: | 674 case STATE_WAIT_FOR_JOB_COMPLETE: |
| 703 rv = DoWaitForJobComplete(rv); | 675 rv = DoWaitForJobComplete(rv); |
| 704 break; | 676 break; |
| 705 case STATE_INIT_CONNECTION: | 677 case STATE_INIT_CONNECTION: |
| 706 DCHECK_EQ(OK, rv); | 678 DCHECK_EQ(OK, rv); |
| 707 rv = DoInitConnection(); | 679 rv = DoInitConnection(); |
| 708 break; | 680 break; |
| 709 case STATE_INIT_CONNECTION_COMPLETE: | 681 case STATE_INIT_CONNECTION_COMPLETE: |
| 710 rv = DoInitConnectionComplete(rv); | 682 rv = DoInitConnectionComplete(rv); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 base::Bind(&NetLogHttpStreamJobCallback, net_log->source(), | 726 base::Bind(&NetLogHttpStreamJobCallback, net_log->source(), |
| 755 &request_info_.url, &origin_url_, &alternative_service_, | 727 &request_info_.url, &origin_url_, &alternative_service_, |
| 756 priority_)); | 728 priority_)); |
| 757 net_log->AddEvent(NetLog::TYPE_HTTP_STREAM_REQUEST_STARTED_JOB, | 729 net_log->AddEvent(NetLog::TYPE_HTTP_STREAM_REQUEST_STARTED_JOB, |
| 758 net_log_.source().ToEventParametersCallback()); | 730 net_log_.source().ToEventParametersCallback()); |
| 759 } | 731 } |
| 760 | 732 |
| 761 // Don't connect to restricted ports. | 733 // Don't connect to restricted ports. |
| 762 if (!IsPortAllowedForScheme(destination_.port(), | 734 if (!IsPortAllowedForScheme(destination_.port(), |
| 763 request_info_.url.scheme())) { | 735 request_info_.url.scheme())) { |
| 764 if (waiting_job_) { | 736 job_controller_->MaybeResumeOtherJob(this, base::TimeDelta()); |
| 765 waiting_job_->Resume(this, base::TimeDelta()); | |
| 766 waiting_job_ = NULL; | |
| 767 } | |
| 768 return ERR_UNSAFE_PORT; | 737 return ERR_UNSAFE_PORT; |
| 769 } | 738 } |
| 770 | 739 |
| 771 next_state_ = STATE_RESOLVE_PROXY; | 740 next_state_ = STATE_RESOLVE_PROXY; |
| 772 return OK; | 741 return OK; |
| 773 } | 742 } |
| 774 | 743 |
| 775 int HttpStreamFactoryImpl::Job::DoResolveProxy() { | 744 int HttpStreamFactoryImpl::Job::DoResolveProxy() { |
| 776 DCHECK(!pac_request_); | 745 DCHECK(!pac_request_); |
| 777 DCHECK(session_); | 746 DCHECK(session_); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 result = ERR_NO_SUPPORTED_PROXIES; | 799 result = ERR_NO_SUPPORTED_PROXIES; |
| 831 } else if (using_quic_ && | 800 } else if (using_quic_ && |
| 832 (!proxy_info_.is_quic() && !proxy_info_.is_direct())) { | 801 (!proxy_info_.is_quic() && !proxy_info_.is_direct())) { |
| 833 // QUIC can not be spoken to non-QUIC proxies. This error should not be | 802 // QUIC can not be spoken to non-QUIC proxies. This error should not be |
| 834 // user visible, because the non-alternative Job should be resumed. | 803 // user visible, because the non-alternative Job should be resumed. |
| 835 result = ERR_NO_SUPPORTED_PROXIES; | 804 result = ERR_NO_SUPPORTED_PROXIES; |
| 836 } | 805 } |
| 837 } | 806 } |
| 838 | 807 |
| 839 if (result != OK) { | 808 if (result != OK) { |
| 840 if (waiting_job_) { | 809 job_controller_->MaybeResumeOtherJob(this, base::TimeDelta()); |
| 841 waiting_job_->Resume(this, base::TimeDelta()); | |
| 842 waiting_job_ = NULL; | |
| 843 } | |
| 844 return result; | 810 return result; |
| 845 } | 811 } |
| 846 | 812 |
| 847 next_state_ = STATE_WAIT_FOR_JOB; | 813 next_state_ = STATE_WAIT_FOR_JOB; |
| 848 return OK; | 814 return OK; |
| 849 } | 815 } |
| 850 | 816 |
| 851 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { | 817 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { |
| 852 return session_->params().enable_quic && | 818 return session_->params().enable_quic && |
| 853 ContainsKey(session_->params().origins_to_force_quic_on, | 819 ContainsKey(session_->params().origins_to_force_quic_on, |
| 854 destination_) && | 820 destination_) && |
| 855 proxy_info_.is_direct() && origin_url_.SchemeIs("https"); | 821 proxy_info_.is_direct() && origin_url_.SchemeIs("https"); |
| 856 } | 822 } |
| 857 | 823 |
| 858 int HttpStreamFactoryImpl::Job::DoWaitForJob() { | |
| 859 if (!blocking_job_ && wait_time_.is_zero()) { | |
| 860 // There is no |blocking_job_| and there is no |wait_time_|. | |
| 861 next_state_ = STATE_INIT_CONNECTION; | |
| 862 return OK; | |
| 863 } | |
| 864 | |
| 865 next_state_ = STATE_WAIT_FOR_JOB_COMPLETE; | |
| 866 if (!wait_time_.is_zero()) { | |
| 867 // If there is a waiting_time, then resume the job after the wait_time_. | |
| 868 DCHECK(!blocking_job_); | |
| 869 ResumeAfterDelay(); | |
| 870 } | |
| 871 | |
| 872 return ERR_IO_PENDING; | |
| 873 } | |
| 874 | |
| 875 int HttpStreamFactoryImpl::Job::DoWaitForJobComplete(int result) { | 824 int HttpStreamFactoryImpl::Job::DoWaitForJobComplete(int result) { |
| 876 DCHECK(!blocking_job_); | 825 DCHECK((job_type_ == ALTERNATIVE || !job_controller_->blocking())); |
| 877 DCHECK_EQ(OK, result); | 826 DCHECK_EQ(OK, result); |
| 878 wait_time_ = base::TimeDelta(); | 827 wait_time_ = base::TimeDelta(); |
| 879 next_state_ = STATE_INIT_CONNECTION; | 828 next_state_ = STATE_INIT_CONNECTION; |
| 880 return OK; | 829 return OK; |
| 881 } | 830 } |
| 882 | 831 |
| 883 int HttpStreamFactoryImpl::Job::DoInitConnection() { | 832 int HttpStreamFactoryImpl::Job::DoInitConnection() { |
| 884 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. | 833 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. |
| 885 tracked_objects::ScopedTracker tracking_profile( | 834 tracked_objects::ScopedTracker tracking_profile( |
| 886 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 835 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 887 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); | 836 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); |
| 888 DCHECK(!blocking_job_); | 837 DCHECK((job_type_ == ALTERNATIVE || !job_controller_->blocking())); |
| 889 DCHECK(!connection_->is_initialized()); | 838 DCHECK(!connection_->is_initialized()); |
| 890 DCHECK(proxy_info_.proxy_server().is_valid()); | 839 DCHECK(proxy_info_.proxy_server().is_valid()); |
| 891 next_state_ = STATE_INIT_CONNECTION_COMPLETE; | 840 next_state_ = STATE_INIT_CONNECTION_COMPLETE; |
| 892 | 841 |
| 893 using_ssl_ = origin_url_.SchemeIs("https") || origin_url_.SchemeIs("wss") || | 842 using_ssl_ = origin_url_.SchemeIs("https") || origin_url_.SchemeIs("wss") || |
| 894 IsSpdyAlternative(); | 843 IsSpdyAlternative(); |
| 895 using_spdy_ = false; | 844 using_spdy_ = false; |
| 896 | 845 |
| 897 if (ShouldForceQuic()) | 846 if (ShouldForceQuic()) |
| 898 using_quic_ = true; | 847 using_quic_ = true; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 destination = destination_; | 899 destination = destination_; |
| 951 ssl_config = &server_ssl_config_; | 900 ssl_config = &server_ssl_config_; |
| 952 } | 901 } |
| 953 int rv = | 902 int rv = |
| 954 quic_request_.Request(destination, request_info_.privacy_mode, | 903 quic_request_.Request(destination, request_info_.privacy_mode, |
| 955 ssl_config->GetCertVerifyFlags(), url, | 904 ssl_config->GetCertVerifyFlags(), url, |
| 956 request_info_.method, net_log_, io_callback_); | 905 request_info_.method, net_log_, io_callback_); |
| 957 if (rv == OK) { | 906 if (rv == OK) { |
| 958 using_existing_quic_session_ = true; | 907 using_existing_quic_session_ = true; |
| 959 } else { | 908 } else { |
| 960 // OK, there's no available QUIC session. Let |waiting_job_| resume | 909 base::TimeDelta delay; |
| 961 // if it's paused. | 910 // OK, there's no available QUIC session. Let JobController to resume |
| 962 if (waiting_job_) { | 911 // the waiting job if it's paused. |
| 963 if (rv == ERR_IO_PENDING) { | 912 if (rv == ERR_IO_PENDING) { |
| 964 // Start the |waiting_job_| after the delay returned by | 913 // Start the waiting job after the delay returned by |
| 965 // GetTimeDelayForWaitingJob(). | 914 // GetTimeDelayForWaitingJob(). |
| 966 // | 915 // |
| 967 // If QUIC request fails during handshake, then | 916 // If QUIC request fails during handshake, then |
| 968 // DoInitConnectionComplete() will start the |waiting_job_|. | 917 // DoInitConnectionComplete() will start the waiting job. |
| 969 waiting_job_->Resume(this, quic_request_.GetTimeDelayForWaitingJob()); | 918 delay = quic_request_.GetTimeDelayForWaitingJob(); |
| 970 } else { | |
| 971 // QUIC request has failed, resume the |waiting_job_|. | |
| 972 waiting_job_->Resume(this, base::TimeDelta()); | |
| 973 } | |
| 974 waiting_job_ = NULL; | |
| 975 } | 919 } |
| 920 job_controller_->MaybeResumeOtherJob(this, delay); |
| 976 } | 921 } |
| 977 return rv; | 922 return rv; |
| 978 } | 923 } |
| 979 | 924 |
| 980 SpdySessionKey spdy_session_key = GetSpdySessionKey(); | 925 SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
| 981 | 926 |
| 982 // Check first if we have a spdy session for this group. If so, then go | 927 // Check first if we have a spdy session for this group. If so, then go |
| 983 // straight to using that. | 928 // straight to using that. |
| 984 if (CanUseExistingSpdySession()) { | 929 if (CanUseExistingSpdySession()) { |
| 985 base::WeakPtr<SpdySession> spdy_session; | 930 base::WeakPtr<SpdySession> spdy_session; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 997 existing_spdy_session_ = spdy_session; | 942 existing_spdy_session_ = spdy_session; |
| 998 return OK; | 943 return OK; |
| 999 } | 944 } |
| 1000 } | 945 } |
| 1001 if (using_ssl_) { | 946 if (using_ssl_) { |
| 1002 // Ask |job_controller_| to update the spdy session key for the request | 947 // Ask |job_controller_| to update the spdy session key for the request |
| 1003 // that launched this job. | 948 // that launched this job. |
| 1004 job_controller_->SetSpdySessionKey(this, spdy_session_key); | 949 job_controller_->SetSpdySessionKey(this, spdy_session_key); |
| 1005 } | 950 } |
| 1006 | 951 |
| 1007 // OK, there's no available SPDY session. Let |waiting_job_| resume if it's | 952 // OK, there's no available SPDY session. Let JobController to resume the |
| 1008 // paused. | 953 // non-alternative job if it's paused. |
| 1009 if (waiting_job_) { | 954 job_controller_->MaybeResumeOtherJob(this, base::TimeDelta()); |
| 1010 waiting_job_->Resume(this, base::TimeDelta()); | |
| 1011 waiting_job_ = NULL; | |
| 1012 } | |
| 1013 | 955 |
| 1014 if (proxy_info_.is_http() || proxy_info_.is_https()) | 956 if (proxy_info_.is_http() || proxy_info_.is_https()) |
| 1015 establishing_tunnel_ = using_ssl_; | 957 establishing_tunnel_ = using_ssl_; |
| 1016 | 958 |
| 1017 const bool expect_spdy = IsSpdyAlternative(); | 959 const bool expect_spdy = IsSpdyAlternative(); |
| 1018 | 960 |
| 1019 base::WeakPtr<HttpServerProperties> http_server_properties = | 961 base::WeakPtr<HttpServerProperties> http_server_properties = |
| 1020 session_->http_server_properties(); | 962 session_->http_server_properties(); |
| 1021 if (http_server_properties) { | 963 if (http_server_properties) { |
| 1022 http_server_properties->MaybeForceHTTP11(destination_, &server_ssl_config_); | 964 http_server_properties->MaybeForceHTTP11(destination_, &server_ssl_config_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 } | 998 } |
| 1057 | 999 |
| 1058 return InitSocketHandleForHttpRequest( | 1000 return InitSocketHandleForHttpRequest( |
| 1059 GetSocketGroup(), destination_, request_info_.extra_headers, | 1001 GetSocketGroup(), destination_, request_info_.extra_headers, |
| 1060 request_info_.load_flags, priority_, session_, proxy_info_, expect_spdy, | 1002 request_info_.load_flags, priority_, session_, proxy_info_, expect_spdy, |
| 1061 server_ssl_config_, proxy_ssl_config_, request_info_.privacy_mode, | 1003 server_ssl_config_, proxy_ssl_config_, request_info_.privacy_mode, |
| 1062 net_log_, connection_.get(), resolution_callback, io_callback_); | 1004 net_log_, connection_.get(), resolution_callback, io_callback_); |
| 1063 } | 1005 } |
| 1064 | 1006 |
| 1065 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { | 1007 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
| 1066 if (using_quic_ && result < 0 && waiting_job_) { | 1008 if (using_quic_ && result < 0) { |
| 1067 waiting_job_->Resume(this, base::TimeDelta()); | 1009 job_controller_->MaybeResumeOtherJob(this, base::TimeDelta()); |
| 1068 waiting_job_ = NULL; | |
| 1069 } | 1010 } |
| 1070 if (job_type_ == PRECONNECT) { | 1011 if (job_type_ == PRECONNECT) { |
| 1071 if (using_quic_) | 1012 if (using_quic_) |
| 1072 return result; | 1013 return result; |
| 1073 DCHECK_EQ(OK, result); | 1014 DCHECK_EQ(OK, result); |
| 1074 return OK; | 1015 return OK; |
| 1075 } | 1016 } |
| 1076 | 1017 |
| 1077 if (result == ERR_SPDY_SESSION_ALREADY_EXISTS) { | 1018 if (result == ERR_SPDY_SESSION_ALREADY_EXISTS) { |
| 1078 // We found a SPDY connection after resolving the host. This is | 1019 // We found a SPDY connection after resolving the host. This is |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1096 // Underlying QUIC layer would have closed the connection. | 1037 // Underlying QUIC layer would have closed the connection. |
| 1097 HostPortPair destination = proxy_info_.proxy_server().host_port_pair(); | 1038 HostPortPair destination = proxy_info_.proxy_server().host_port_pair(); |
| 1098 if (session_->quic_stream_factory()->IsQuicDisabled(destination.port())) { | 1039 if (session_->quic_stream_factory()->IsQuicDisabled(destination.port())) { |
| 1099 using_quic_ = false; | 1040 using_quic_ = false; |
| 1100 return ReconsiderProxyAfterError(ERR_QUIC_PROTOCOL_ERROR); | 1041 return ReconsiderProxyAfterError(ERR_QUIC_PROTOCOL_ERROR); |
| 1101 } | 1042 } |
| 1102 } | 1043 } |
| 1103 | 1044 |
| 1104 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable | 1045 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable |
| 1105 // errors, such as ignoring certificate errors for Alternate-Protocol. | 1046 // errors, such as ignoring certificate errors for Alternate-Protocol. |
| 1106 if (result < 0 && waiting_job_) { | 1047 if (result < 0) { |
| 1107 waiting_job_->Resume(this, base::TimeDelta()); | 1048 job_controller_->MaybeResumeOtherJob(this, base::TimeDelta()); |
| 1108 waiting_job_ = NULL; | |
| 1109 } | 1049 } |
| 1110 | 1050 |
| 1111 // |result| may be the result of any of the stacked pools. The following | 1051 // |result| may be the result of any of the stacked pools. The following |
| 1112 // logic is used when determining how to interpret an error. | 1052 // logic is used when determining how to interpret an error. |
| 1113 // If |result| < 0: | 1053 // If |result| < 0: |
| 1114 // and connection_->socket() != NULL, then the SSL handshake ran and it | 1054 // and connection_->socket() != NULL, then the SSL handshake ran and it |
| 1115 // is a potentially recoverable error. | 1055 // is a potentially recoverable error. |
| 1116 // and connection_->socket == NULL and connection_->is_ssl_error() is true, | 1056 // and connection_->socket == NULL and connection_->is_ssl_error() is true, |
| 1117 // then the SSL handshake ran with an unrecoverable error. | 1057 // then the SSL handshake ran with an unrecoverable error. |
| 1118 // otherwise, the error came from one of the other pools. | 1058 // otherwise, the error came from one of the other pools. |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 | 1679 |
| 1740 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1680 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
| 1741 if (connection_->socket()) { | 1681 if (connection_->socket()) { |
| 1742 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1682 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
| 1743 } | 1683 } |
| 1744 | 1684 |
| 1745 job_controller_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1685 job_controller_->AddConnectionAttemptsToRequest(this, socket_attempts); |
| 1746 } | 1686 } |
| 1747 | 1687 |
| 1748 } // namespace net | 1688 } // namespace net |
| OLD | NEW |