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..5a264f56962502f8dc476970dd34ba4c64657647 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -28,15 +28,6 @@ |
| 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); |
| -} |
| - |
| std::unique_ptr<base::Value> NetLogJobControllerCallback( |
| const GURL* url, |
| bool is_preconnect, |
| @@ -546,10 +537,21 @@ void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest( |
| request_->AddConnectionAttempts(attempts); |
| } |
| +void HttpStreamFactoryImpl::JobController::ResumeMainJobLater( |
| + const base::TimeDelta& delay) { |
| + net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_DELAYED, |
| + NetLog::Int64Callback("delay", delay.InMilliseconds())); |
|
eroman
2017/02/14 21:46:36
I guess the downside to my recommendation here is
Ryan Hamilton
2017/02/14 22:18:16
Yeah, I'm totally fine with that 'cause it's two d
|
| + 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_DELAYED, |
| - base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); |
| + NetLogEventType::HTTP_STREAM_JOB_RESUMED, |
| + NetLog::Int64Callback("delay", main_job_wait_time_.InMilliseconds())); |
| main_job_->Resume(); |
| main_job_wait_time_ = base::TimeDelta(); |
| @@ -568,11 +570,7 @@ void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( |
| if (!main_job_->is_waiting()) |
| return; |
| - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| - FROM_HERE, |
| - base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob, |
| - ptr_factory_.GetWeakPtr()), |
| - main_job_wait_time_); |
| + ResumeMainJobLater(main_job_wait_time_); |
| } |
| void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job, |
| @@ -595,12 +593,7 @@ bool HttpStreamFactoryImpl::JobController::ShouldWait(Job* job) { |
| if (main_job_wait_time_.is_zero()) |
| return false; |
| - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| - FROM_HERE, |
| - base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob, |
| - ptr_factory_.GetWeakPtr()), |
| - main_job_wait_time_); |
| - |
| + ResumeMainJobLater(main_job_wait_time_); |
| return true; |
| } |