Chromium Code Reviews| Index: net/http/http_stream_factory_impl_job_controller.cc |
| diff --git a/net/http/http_stream_factory_impl_job_controller.cc b/net/http/http_stream_factory_impl_job_controller.cc |
| index 7e76ce5ce3436767ba5f47262d75ec4dbcaf16b8..44ab1966568a0bc176c031db6803afb611f43bd5 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -145,9 +145,19 @@ void HttpStreamFactoryImpl::JobController::OnRequestComplete() { |
| if (bound_job_) { |
| if (bound_job_->job_type() == MAIN) { |
| main_job_.reset(); |
| + // |alternative_job_| can be non-null if |main_job_| is resumed after |
| + // |main_job_wait_time_| has elapsed. |
| + // Do not reset |alternative_job_| here and let it run for completion. |
| + // OnOrphanedJobComplete() will clean up |this| when the job completes. |
| } else { |
| DCHECK(bound_job_->job_type() == ALTERNATIVE); |
| alternative_job_.reset(); |
| + // If |main_job_| hasn't started connecting, reset it. Otherwise, |
| + // OnOrphanedJobComplete() will clean up |this| when the job completes. |
| + // Use |main_job_is_blocked_| instead of |main_job_|->is_waiting() because |
| + // |main_job_| can be in proxy resolution step. |
| + if (main_job_ && main_job_is_blocked_) |
|
mmenke
2017/01/09 18:37:20
Should this be:
if (main_job_ && (main_job_is_blo
xunjieli
2017/01/09 18:52:31
In HttpStreamFactoryImpl::Job::DoInitConnectionImp
mmenke
2017/01/09 18:56:19
It's not the same thing. We set main_job_is_block
xunjieli
2017/01/09 19:18:21
Done. Got it, Thanks!
Zhongyi Shi
2017/01/09 20:09:45
Umm, main_job_wait_time is only used to figure out
mmenke
2017/01/09 20:12:27
That strikes me as unexpected - why are we delayin
Zhongyi Shi
2017/01/09 23:18:49
We are delaying the tcp job because we want to giv
mmenke
2017/01/09 23:25:12
So what is fundamentally different between cases w
Zhongyi Shi
2017/01/09 23:39:46
My understanding is: if we've started the timer, t
Zhongyi Shi
2017/01/10 01:11:32
Looks like both jobs and request will be reset her
|
| + main_job_.reset(); |
| } |
| bound_job_ = nullptr; |
| } |
| @@ -177,7 +187,7 @@ void HttpStreamFactoryImpl::JobController::OnStreamReady( |
| factory_->OnStreamReady(job->proxy_info()); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -202,7 +212,7 @@ void HttpStreamFactoryImpl::JobController::OnBidirectionalStreamImplReady( |
| const ProxyInfo& used_proxy_info) { |
| DCHECK(job); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -253,7 +263,7 @@ void HttpStreamFactoryImpl::JobController::OnStreamFailed( |
| MaybeResumeMainJob(job, base::TimeDelta()); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -291,7 +301,7 @@ void HttpStreamFactoryImpl::JobController::OnCertificateError( |
| const SSLInfo& ssl_info) { |
| MaybeResumeMainJob(job, base::TimeDelta()); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -314,7 +324,7 @@ void HttpStreamFactoryImpl::JobController::OnHttpsProxyTunnelResponse( |
| HttpStream* stream) { |
| MaybeResumeMainJob(job, base::TimeDelta()); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -334,7 +344,7 @@ void HttpStreamFactoryImpl::JobController::OnNeedsClientAuth( |
| SSLCertRequestInfo* cert_info) { |
| MaybeResumeMainJob(job, base::TimeDelta()); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -355,7 +365,7 @@ void HttpStreamFactoryImpl::JobController::OnNeedsProxyAuth( |
| HttpAuthController* auth_controller) { |
| MaybeResumeMainJob(job, base::TimeDelta()); |
| - if (job_bound_ && bound_job_ != job) { |
| + if (!request_ || (job_bound_ && bound_job_ != job)) { |
|
mmenke
2017/01/09 18:37:20
Suggest a helper method here, IsJobOrphaned(job) c
xunjieli
2017/01/09 19:18:21
Done.
|
| // We have bound a job to the associated Request, |job| has been orphaned. |
| OnOrphanedJobComplete(job); |
| return; |
| @@ -422,7 +432,7 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady( |
| DCHECK(job->using_spdy()); |
| DCHECK(!is_preconnect_); |
| - bool is_job_orphaned = job_bound_ && bound_job_ != job; |
| + bool is_job_orphaned = !request_ || (job_bound_ && bound_job_ != job); |
| // Cache these values in case the job gets deleted. |
| const SSLConfig used_ssl_config = job->server_ssl_config(); |