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 ac3f92e498b2418ffce4949bfada7e8bed73d558..2b7a78ee0a754b316d2657b2f3140ed8685ba4e4 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -63,6 +63,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), |
| @@ -547,6 +548,10 @@ void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest( |
| } |
| void HttpStreamFactoryImpl::JobController::ResumeMainJob() { |
| + if (main_job_is_resumed_) |
| + return; |
| + |
| + main_job_is_resumed_ = true; |
| main_job_->net_log().AddEvent( |
| NetLogEventType::HTTP_STREAM_JOB_DELAYED, |
| base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); |
| @@ -558,15 +563,23 @@ 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_blocked_) |
| + main_job_is_blocked_ = false; |
|
Ryan Hamilton
2017/02/15 00:52:08
Might as well just set main_job_is_blocked_ = fals
Zhongyi Shi
2017/02/15 01:39:05
Done.
|
| - 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, simply mark it unblocked. |
|
Ryan Hamilton
2017/02/15 00:52:08
If it's not blocked, but main_job_wait_time_ is no
Zhongyi Shi
2017/02/15 01:39:04
Yup.
|
| + // 2) The main job has passed waiting state, no-op. |
|
Zhongyi Shi
2017/02/15 00:26:58
main_job_.is_waiting() will be false
1. main job h
Ryan Hamilton
2017/02/15 00:52:08
Instead of "no-op" I would say something like, "so
Zhongyi Shi
2017/02/15 01:39:04
Done.
|
| return; |
| + } |
| + |
| + main_job_wait_time_ = delay; |
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| FROM_HERE, |