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 5a264f56962502f8dc476970dd34ba4c64657647..0bb08374dc8e90f0946600b1767183bc6d0f53c6 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -54,6 +54,7 @@ HttpStreamFactoryImpl::JobController::JobController( |
| alternative_job_net_error_(OK), |
| job_bound_(false), |
| main_job_is_blocked_(false), |
| + main_job_is_resumed_(false), |
| bound_job_(nullptr), |
| can_start_alternative_proxy_job_(false), |
| privacy_mode_(PRIVACY_MODE_DISABLED), |
| @@ -549,6 +550,10 @@ void HttpStreamFactoryImpl::JobController::ResumeMainJobLater( |
| } |
| void HttpStreamFactoryImpl::JobController::ResumeMainJob() { |
| + if (main_job_is_resumed_) |
| + return; |
| + |
| + main_job_is_resumed_ = true; |
| main_job_->net_log().AddEvent( |
| NetLogEventType::HTTP_STREAM_JOB_RESUMED, |
| NetLog::Int64Callback("delay", main_job_wait_time_.InMilliseconds())); |
| @@ -560,15 +565,24 @@ void HttpStreamFactoryImpl::JobController::ResumeMainJob() { |
| void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( |
| Job* job, |
| const base::TimeDelta& delay) { |
| + DCHECK(delay == base::TimeDelta() || delay == main_job_wait_time_); |
| DCHECK(job == main_job_.get() || job == alternative_job_.get()); |
| - if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_) |
| + if (job != alternative_job_.get() || !main_job_) |
| return; |
| main_job_is_blocked_ = false; |
| - if (!main_job_->is_waiting()) |
| + if (!main_job_->is_waiting()) { |
| + // There are two cases where the main job is not in WAIT state: |
| + // 1) The main job hasn't got to waiting state, do not yet post a task to |
| + // resume since that will happen in ShouldWait(). |
| + // 2) The main job has passed waiting state, so the main job does not need |
| + // to be resumed. |
| return; |
| + } |
| + |
| + main_job_wait_time_ = delay; |
|
Ryan Hamilton
2017/02/15 14:53:55
Does this need to happen before the early return o
|
| ResumeMainJobLater(main_job_wait_time_); |
| } |