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

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

Issue 2806383002: Revert of Remove unreachable code in HttpStreamFactoryImpl::Job::Orphan (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.h ('k') | no next file » | 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) 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
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 const { 664 Job* job) 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
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_);
777 RemoveRequestFromSpdySessionRequestMap(); 776 RemoveRequestFromSpdySessionRequestMap();
778 777
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());
781 alternative_job_->Orphan(); 780 alternative_job_->Orphan();
782 } else if (bound_job_->job_type() == ALTERNATIVE && main_job_) { 781 } else if (bound_job_->job_type() == ALTERNATIVE && main_job_) {
783 // Orphan main job. 782 // Orphan main job.
784 // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise, 783 // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise,
785 // OnOrphanedJobComplete() will clean up |this| when the job completes. 784 // OnOrphanedJobComplete() will clean up |this| when the job completes.
786 // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead 785 // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead
787 // of |main_job_|->is_waiting() because |main_job_| can be in proxy 786 // of |main_job_|->is_waiting() because |main_job_| can be in proxy
788 // resolution step. 787 // resolution step.
789 if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero())) { 788 if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero())) {
790 DCHECK(alternative_job_); 789 DCHECK(alternative_job_);
791 main_job_.reset(); 790 main_job_.reset();
792 } else { 791 } else {
793 DCHECK(!for_websockets());
794 main_job_->Orphan(); 792 main_job_->Orphan();
795 } 793 }
796 } 794 }
797 } 795 }
798 796
799 void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) { 797 void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) {
800 // |job| should only be nullptr if we're being serviced by a late bound 798 // |job| should only be nullptr if we're being serviced by a late bound
801 // SpdySession (one that was not created by a job in our |jobs_| set). 799 // SpdySession (one that was not created by a job in our |jobs_| set).
802 if (!job) { 800 if (!job) {
803 DCHECK(!bound_job_); 801 DCHECK(!bound_job_);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 return; 1157 return;
1160 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1158 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1161 alternative_job_->Start(request_->stream_type()); 1159 alternative_job_->Start(request_->stream_type());
1162 } 1160 }
1163 1161
1164 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { 1162 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
1165 return !request_ || (job_bound_ && bound_job_ != job); 1163 return !request_ || (job_bound_ && bound_job_ != job);
1166 } 1164 }
1167 1165
1168 } // namespace net 1166 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698