OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_controller.h" | 5 #include "net/http/http_stream_factory_impl_job_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 DCHECK(base::ContainsKey(spdy_session_request_map, *spdy_session_key)); | 653 DCHECK(base::ContainsKey(spdy_session_request_map, *spdy_session_key)); |
654 RequestSet& request_set = spdy_session_request_map[*spdy_session_key]; | 654 RequestSet& request_set = spdy_session_request_map[*spdy_session_key]; |
655 DCHECK(base::ContainsKey(request_set, request_)); | 655 DCHECK(base::ContainsKey(request_set, request_)); |
656 request_set.erase(request_); | 656 request_set.erase(request_); |
657 if (request_set.empty()) | 657 if (request_set.empty()) |
658 spdy_session_request_map.erase(*spdy_session_key); | 658 spdy_session_request_map.erase(*spdy_session_key); |
659 request_->ResetSpdySessionKey(); | 659 request_->ResetSpdySessionKey(); |
660 } | 660 } |
661 } | 661 } |
662 | 662 |
663 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( | 663 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog() |
664 Job* job) const { | 664 const { |
665 return &net_log_; | 665 return &net_log_; |
666 } | 666 } |
667 | 667 |
668 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( | 668 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( |
669 const base::TimeDelta& delay) { | 669 const base::TimeDelta& delay) { |
670 if (main_job_is_blocked_) { | 670 if (main_job_is_blocked_) { |
671 main_job_wait_time_ = std::min( | 671 main_job_wait_time_ = std::min( |
672 delay, base::TimeDelta::FromSeconds(kMaxDelayTimeForMainJobSecs)); | 672 delay, base::TimeDelta::FromSeconds(kMaxDelayTimeForMainJobSecs)); |
673 } | 673 } |
674 } | 674 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 if (job_bound_) | 766 if (job_bound_) |
767 return; | 767 return; |
768 if (alternative_job_) | 768 if (alternative_job_) |
769 alternative_job_.reset(); | 769 alternative_job_.reset(); |
770 if (main_job_) | 770 if (main_job_) |
771 main_job_.reset(); | 771 main_job_.reset(); |
772 } | 772 } |
773 | 773 |
774 void HttpStreamFactoryImpl::JobController::OrphanUnboundJob() { | 774 void HttpStreamFactoryImpl::JobController::OrphanUnboundJob() { |
775 DCHECK(request_); | 775 DCHECK(request_); |
| 776 DCHECK(bound_job_); |
776 RemoveRequestFromSpdySessionRequestMap(); | 777 RemoveRequestFromSpdySessionRequestMap(); |
777 | 778 |
778 DCHECK(bound_job_); | |
779 if (bound_job_->job_type() == MAIN && alternative_job_) { | 779 if (bound_job_->job_type() == MAIN && alternative_job_) { |
| 780 DCHECK(!for_websockets()); |
780 alternative_job_->Orphan(); | 781 alternative_job_->Orphan(); |
781 } else if (bound_job_->job_type() == ALTERNATIVE && main_job_) { | 782 } else if (bound_job_->job_type() == ALTERNATIVE && main_job_) { |
782 // Orphan main job. | 783 // Orphan main job. |
783 // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise, | 784 // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise, |
784 // OnOrphanedJobComplete() will clean up |this| when the job completes. | 785 // OnOrphanedJobComplete() will clean up |this| when the job completes. |
785 // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead | 786 // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead |
786 // of |main_job_|->is_waiting() because |main_job_| can be in proxy | 787 // of |main_job_|->is_waiting() because |main_job_| can be in proxy |
787 // resolution step. | 788 // resolution step. |
788 if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero())) { | 789 if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero())) { |
789 DCHECK(alternative_job_); | 790 DCHECK(alternative_job_); |
790 main_job_.reset(); | 791 main_job_.reset(); |
791 } else { | 792 } else { |
| 793 DCHECK(!for_websockets()); |
792 main_job_->Orphan(); | 794 main_job_->Orphan(); |
793 } | 795 } |
794 } | 796 } |
795 } | 797 } |
796 | 798 |
797 void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) { | 799 void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) { |
798 // |job| should only be nullptr if we're being serviced by a late bound | 800 // |job| should only be nullptr if we're being serviced by a late bound |
799 // SpdySession (one that was not created by a job in our |jobs_| set). | 801 // SpdySession (one that was not created by a job in our |jobs_| set). |
800 if (!job) { | 802 if (!job) { |
801 DCHECK(!bound_job_); | 803 DCHECK(!bound_job_); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 return; | 1159 return; |
1158 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1160 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
1159 alternative_job_->Start(request_->stream_type()); | 1161 alternative_job_->Start(request_->stream_type()); |
1160 } | 1162 } |
1161 | 1163 |
1162 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1164 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
1163 return !request_ || (job_bound_ && bound_job_ != job); | 1165 return !request_ || (job_bound_ && bound_job_ != job); |
1164 } | 1166 } |
1165 | 1167 |
1166 } // namespace net | 1168 } // namespace net |
OLD | NEW |