| 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 2bcf4f00562b6064b21e7945be730d3b882bc641..052a17e3da2ab5a6d5a396109eb900c3d88ba903 100644
|
| --- a/net/http/http_stream_factory_impl_job_controller.cc
|
| +++ b/net/http/http_stream_factory_impl_job_controller.cc
|
| @@ -26,6 +26,15 @@
|
| #include "url/url_constants.h"
|
|
|
| namespace net {
|
| +
|
| +// Returns parameters associated with the delay of the HTTP stream job.
|
| +std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback(
|
| + base::TimeDelta delay,
|
| + NetLogCaptureMode /* capture_mode */) {
|
| + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
|
| + dict->SetInteger("resume_after_ms", static_cast<int>(delay.InMilliseconds()));
|
| + return std::move(dict);
|
| +}
|
|
|
| HttpStreamFactoryImpl::JobController::JobController(
|
| HttpStreamFactoryImpl* factory,
|
| @@ -506,40 +515,33 @@
|
| request_->AddConnectionAttempts(attempts);
|
| }
|
|
|
| -void HttpStreamFactoryImpl::JobController::ResumeMainJobLater(
|
| +void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
|
| + main_job_->net_log().AddEvent(
|
| + NetLogEventType::HTTP_STREAM_JOB_DELAYED,
|
| + base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_));
|
| +
|
| + main_job_->Resume();
|
| + main_job_wait_time_ = base::TimeDelta();
|
| +}
|
| +
|
| +void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob(
|
| + Job* job,
|
| const base::TimeDelta& delay) {
|
| - net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_DELAYED,
|
| - NetLog::Int64Callback("delay", delay.InMilliseconds()));
|
| + DCHECK(job == main_job_.get() || job == alternative_job_.get());
|
| +
|
| + if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_)
|
| + return;
|
| +
|
| + main_job_is_blocked_ = false;
|
| +
|
| + if (!main_job_->is_waiting())
|
| + return;
|
| +
|
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| FROM_HERE,
|
| base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
|
| ptr_factory_.GetWeakPtr()),
|
| - delay);
|
| -}
|
| -
|
| -void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
|
| - main_job_->net_log().AddEvent(
|
| - NetLogEventType::HTTP_STREAM_JOB_RESUMED,
|
| - NetLog::Int64Callback("delay", main_job_wait_time_.InMilliseconds()));
|
| -
|
| - main_job_->Resume();
|
| - main_job_wait_time_ = base::TimeDelta();
|
| -}
|
| -
|
| -void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob(
|
| - Job* job,
|
| - const base::TimeDelta& delay) {
|
| - DCHECK(job == main_job_.get() || job == alternative_job_.get());
|
| -
|
| - if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_)
|
| - return;
|
| -
|
| - main_job_is_blocked_ = false;
|
| -
|
| - if (!main_job_->is_waiting())
|
| - return;
|
| -
|
| - ResumeMainJobLater(main_job_wait_time_);
|
| + main_job_wait_time_);
|
| }
|
|
|
| void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job,
|
| @@ -562,7 +564,12 @@
|
| if (main_job_wait_time_.is_zero())
|
| return false;
|
|
|
| - ResumeMainJobLater(main_job_wait_time_);
|
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| + FROM_HERE,
|
| + base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
|
| + ptr_factory_.GetWeakPtr()),
|
| + main_job_wait_time_);
|
| +
|
| return true;
|
| }
|
|
|
|
|