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 f8b816257bfc898fe20cedc24331aebd17080643..63139fb38eafafeaf2cd0d61d3d27fbaf57936f0 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -26,6 +26,7 @@ HttpStreamFactoryImpl::JobController::JobController( |
| delegate_(delegate), |
| is_preconnect_(false), |
| job_bound_(false), |
| + blocking_(false), |
| bound_job_(nullptr) { |
| DCHECK(factory); |
| } |
| @@ -390,6 +391,7 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady( |
| void HttpStreamFactoryImpl::JobController::OnPreconnectsComplete(Job* job) { |
| DCHECK_EQ(main_job_.get(), job); |
| + DCHECK(!bound_job_); |
| main_job_.reset(); |
| factory_->OnPreconnectsCompleteInternal(); |
| MaybeNotifyFactoryOfCompletion(); |
| @@ -459,6 +461,33 @@ void HttpStreamFactoryImpl::JobController:: |
| } |
| } |
| +void HttpStreamFactoryImpl::JobController::MaybeResumeOtherJob( |
| + Job* job, |
| + const base::TimeDelta& delay) { |
| + if (!blocking_) |
| + return; |
| + |
| + if (job == alternative_job_.get() && main_job_) { |
| + main_job_->Resume(delay); |
| + } else if (job != main_job_.get() && job != alternative_job_.get()) { |
|
Ryan Hamilton
2016/05/17 22:14:09
nit: I might move this to a DCHECK() at the top of
Zhongyi Shi
2016/06/29 21:49:03
Done.
|
| + NOTREACHED(); |
| + } |
| + blocking_ = false; |
| +} |
| + |
| +bool HttpStreamFactoryImpl::JobController::ResumeJobWithDelay(Job* job) const { |
| + base::WeakPtrFactory<Job> ptr_factory(job); |
| + if (wait_time_.is_zero()) { |
| + if (job->job_type() == ALTERNATIVE || !blocking_) { |
| + // There is no blocking job and there is no |wait_time_|. |
| + return false; |
| + } |
| + } else { |
| + DCHECK(job->job_type() == ALTERNATIVE || !blocking_); |
| + job->ResumeAfterDelay(wait_time_); |
| + } |
| + return true; |
| +} |
| const BoundNetLog* HttpStreamFactoryImpl::JobController::GetNetLog( |
| Job* job) const { |
| if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
| @@ -512,10 +541,7 @@ void HttpStreamFactoryImpl::JobController::CreateJobs( |
| origin_url, alternative_service, net_log.net_log())); |
| AttachJob(alternative_job_.get()); |
| - main_job_->WaitFor(alternative_job_.get()); |
| - // Make sure to wait until we call WaitFor(), before starting |
| - // |alternative_job|, otherwise |alternative_job| will not notify |job| |
| - // appropriately. |
| + blocking_ = true; |
| alternative_job_->Start(request_->stream_type()); |
| } |
| // Even if |alternative_job| has already finished, it will not have notified |