| 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 4e3aa673f3e74cfd75524af4417350c9712096e2..83d10def31c1b0139557ded5f99e561e2ab7f9f3 100644
|
| --- a/net/http/http_stream_factory_impl_job_controller.cc
|
| +++ b/net/http/http_stream_factory_impl_job_controller.cc
|
| @@ -144,9 +144,20 @@ 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. Allow |alternative_job_| to run to
|
| + // completion, rather than resetting it. OnOrphanedJobComplete() will
|
| + // clean up |this| when the job completes.
|
| } else {
|
| DCHECK(bound_job_->job_type() == ALTERNATIVE);
|
| alternative_job_.reset();
|
| + // If ResumeMainJob() is not executed, reset |main_job_|. Otherwise,
|
| + // OnOrphanedJobComplete() will clean up |this| when the job completes.
|
| + // Use |main_job_is_blocked_| and |!main_job_wait_time_.is_zero()| instead
|
| + // of |main_job_|->is_waiting() because |main_job_| can be in proxy
|
| + // resolution step.
|
| + if (main_job_ && (main_job_is_blocked_ || !main_job_wait_time_.is_zero()))
|
| + main_job_.reset();
|
| }
|
| bound_job_ = nullptr;
|
| }
|
| @@ -175,7 +186,7 @@ void HttpStreamFactoryImpl::JobController::OnStreamReady(
|
| const ProxyInfo& used_proxy_info) {
|
| DCHECK(job);
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -200,7 +211,7 @@ void HttpStreamFactoryImpl::JobController::OnBidirectionalStreamImplReady(
|
| const ProxyInfo& used_proxy_info) {
|
| DCHECK(job);
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -251,7 +262,7 @@ void HttpStreamFactoryImpl::JobController::OnStreamFailed(
|
|
|
| MaybeResumeMainJob(job, base::TimeDelta());
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -289,7 +300,7 @@ void HttpStreamFactoryImpl::JobController::OnCertificateError(
|
| const SSLInfo& ssl_info) {
|
| MaybeResumeMainJob(job, base::TimeDelta());
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -312,7 +323,7 @@ void HttpStreamFactoryImpl::JobController::OnHttpsProxyTunnelResponse(
|
| HttpStream* stream) {
|
| MaybeResumeMainJob(job, base::TimeDelta());
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -332,7 +343,7 @@ void HttpStreamFactoryImpl::JobController::OnNeedsClientAuth(
|
| SSLCertRequestInfo* cert_info) {
|
| MaybeResumeMainJob(job, base::TimeDelta());
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -353,7 +364,7 @@ void HttpStreamFactoryImpl::JobController::OnNeedsProxyAuth(
|
| HttpAuthController* auth_controller) {
|
| MaybeResumeMainJob(job, base::TimeDelta());
|
|
|
| - if (job_bound_ && bound_job_ != job) {
|
| + if (IsJobOrphaned(job)) {
|
| // We have bound a job to the associated Request, |job| has been orphaned.
|
| OnOrphanedJobComplete(job);
|
| return;
|
| @@ -414,7 +425,7 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady(
|
| DCHECK(job);
|
| DCHECK(job->using_spdy());
|
|
|
| - bool is_job_orphaned = job_bound_ && bound_job_ != job;
|
| + bool is_job_orphaned = IsJobOrphaned(job);
|
|
|
| // Cache these values in case the job gets deleted.
|
| const SSLConfig used_ssl_config = job->server_ssl_config();
|
| @@ -777,7 +788,7 @@ void HttpStreamFactoryImpl::JobController::OnAlternativeJobFailed(Job* job) {
|
| failed_alternative_service_ = job->alternative_service();
|
| }
|
|
|
| - if (!request_ || (job_bound_ && bound_job_ != job)) {
|
| + if (IsJobOrphaned(job)) {
|
| // If |request_| is gone then it must have been successfully served by
|
| // |main_job_|.
|
| // If |request_| is bound to a different job, then it is being
|
| @@ -1077,4 +1088,8 @@ void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() {
|
| alternative_job_->Start(request_->stream_type());
|
| }
|
|
|
| +bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
|
| + return !request_ || (job_bound_ && bound_job_ != job);
|
| +}
|
| +
|
| } // namespace net
|
|
|