Chromium Code Reviews| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 if (bound_job_) { | 145 if (bound_job_) { |
| 146 if (bound_job_->job_type() == MAIN) { | 146 if (bound_job_->job_type() == MAIN) { |
| 147 main_job_.reset(); | 147 main_job_.reset(); |
| 148 // |alternative_job_| can be non-null if |main_job_| is resumed after | 148 // |alternative_job_| can be non-null if |main_job_| is resumed after |
| 149 // |main_job_wait_time_| has elapsed. Allow |alternative_job_| to run to | 149 // |main_job_wait_time_| has elapsed. Allow |alternative_job_| to run to |
| 150 // completion, rather than resetting it. OnOrphanedJobComplete() will | 150 // completion, rather than resetting it. OnOrphanedJobComplete() will |
| 151 // clean up |this| when the job completes. | 151 // clean up |this| when the job completes. |
| 152 } else { | 152 } else { |
| 153 DCHECK(bound_job_->job_type() == ALTERNATIVE); | 153 DCHECK(bound_job_->job_type() == ALTERNATIVE); |
| 154 alternative_job_.reset(); | 154 alternative_job_.reset(); |
| 155 // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise, | |
| 156 // OnOrphanedJobComplete() will clean up |this| when the job completes. | |
| 157 // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead | |
| 158 // of |main_job_|->is_waiting() because |main_job_| can be in proxy | |
| 159 // resolution step. | |
| 160 if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero())) | |
| 161 main_job_.reset(); | |
| 162 } | 155 } |
| 163 bound_job_ = nullptr; | 156 bound_job_ = nullptr; |
| 164 } | 157 } |
| 165 MaybeNotifyFactoryOfCompletion(); | 158 MaybeNotifyFactoryOfCompletion(); |
| 166 } | 159 } |
| 167 | 160 |
| 168 int HttpStreamFactoryImpl::JobController::RestartTunnelWithProxyAuth( | 161 int HttpStreamFactoryImpl::JobController::RestartTunnelWithProxyAuth( |
| 169 const AuthCredentials& credentials) { | 162 const AuthCredentials& credentials) { |
| 170 DCHECK(bound_job_); | 163 DCHECK(bound_job_); |
| 171 return bound_job_->RestartTunnelWithProxyAuth(credentials); | 164 return bound_job_->RestartTunnelWithProxyAuth(credentials); |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 DCHECK(request_); | 729 DCHECK(request_); |
| 737 RemoveRequestFromSpdySessionRequestMap(); | 730 RemoveRequestFromSpdySessionRequestMap(); |
| 738 | 731 |
| 739 DCHECK(bound_job_); | 732 DCHECK(bound_job_); |
| 740 if (bound_job_->job_type() == MAIN && alternative_job_) { | 733 if (bound_job_->job_type() == MAIN && alternative_job_) { |
| 741 factory_->request_map_.erase(alternative_job_.get()); | 734 factory_->request_map_.erase(alternative_job_.get()); |
| 742 alternative_job_->Orphan(); | 735 alternative_job_->Orphan(); |
| 743 } else if (bound_job_->job_type() == ALTERNATIVE && main_job_) { | 736 } else if (bound_job_->job_type() == ALTERNATIVE && main_job_) { |
| 744 // Orphan main job. | 737 // Orphan main job. |
| 745 factory_->request_map_.erase(main_job_.get()); | 738 factory_->request_map_.erase(main_job_.get()); |
| 746 main_job_->Orphan(); | 739 // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise, |
| 740 // OnOrphanedJobComplete() will clean up |this| when the job completes. | |
| 741 // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead | |
| 742 // of |main_job_|->is_waiting() because |main_job_| can be in proxy | |
| 743 // resolution step. | |
| 744 if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero())) { | |
|
mmenke
2017/01/12 22:46:48
DCHECK(alternative_job_)? (If alternate_job_ is r
Zhongyi Shi
2017/01/12 23:17:50
Done.
bound_job_ will only be reset to nullptr whe
| |
| 745 main_job_.reset(); | |
| 746 } else { | |
| 747 main_job_->Orphan(); | |
|
xunjieli
2017/01/12 23:00:32
Should HttpStreamFactoryImpl::Job::Orphan() also c
xunjieli
2017/01/12 23:04:30
Think that the old code calls OnOrphanedJobComplet
Zhongyi Shi
2017/01/12 23:17:50
For non-websockets case, the Job will continue con
| |
| 748 } | |
| 747 } | 749 } |
| 748 } | 750 } |
| 749 | 751 |
| 750 void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) { | 752 void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) { |
| 751 // |job| should only be nullptr if we're being serviced by a late bound | 753 // |job| should only be nullptr if we're being serviced by a late bound |
| 752 // SpdySession (one that was not created by a job in our |jobs_| set). | 754 // SpdySession (one that was not created by a job in our |jobs_| set). |
| 753 if (!job) { | 755 if (!job) { |
| 754 DCHECK(!bound_job_); | 756 DCHECK(!bound_job_); |
| 755 // NOTE(willchan): We do *NOT* call OrphanUnboundJob() here. The reason is | 757 // NOTE(willchan): We do *NOT* call OrphanUnboundJob() here. The reason is |
| 756 // because we *WANT* to cancel the unnecessary Jobs from other requests if | 758 // because we *WANT* to cancel the unnecessary Jobs from other requests if |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 return; | 1096 return; |
| 1095 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1097 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1096 alternative_job_->Start(request_->stream_type()); | 1098 alternative_job_->Start(request_->stream_type()); |
| 1097 } | 1099 } |
| 1098 | 1100 |
| 1099 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1101 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1100 return !request_ || (job_bound_ && bound_job_ != job); | 1102 return !request_ || (job_bound_ && bound_job_ != job); |
| 1101 } | 1103 } |
| 1102 | 1104 |
| 1103 } // namespace net | 1105 } // namespace net |
| OLD | NEW |