Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(870)

Side by Side Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 2693043008: Resume the main job immediately when QUIC job fails, not wait for the head start timer to exprie (Closed)
Patch Set: sync with master Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_stream_factory_impl_job_controller.h" 5 #include "net/http/http_stream_factory_impl_job_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 bool is_preconnect) 47 bool is_preconnect)
48 : factory_(factory), 48 : factory_(factory),
49 session_(session), 49 session_(session),
50 job_factory_(job_factory), 50 job_factory_(job_factory),
51 request_(nullptr), 51 request_(nullptr),
52 delegate_(delegate), 52 delegate_(delegate),
53 is_preconnect_(is_preconnect), 53 is_preconnect_(is_preconnect),
54 alternative_job_net_error_(OK), 54 alternative_job_net_error_(OK),
55 job_bound_(false), 55 job_bound_(false),
56 main_job_is_blocked_(false), 56 main_job_is_blocked_(false),
57 main_job_is_resumed_(false),
57 bound_job_(nullptr), 58 bound_job_(nullptr),
58 can_start_alternative_proxy_job_(false), 59 can_start_alternative_proxy_job_(false),
59 privacy_mode_(PRIVACY_MODE_DISABLED), 60 privacy_mode_(PRIVACY_MODE_DISABLED),
60 net_log_( 61 net_log_(
61 NetLogWithSource::Make(session->net_log(), 62 NetLogWithSource::Make(session->net_log(),
62 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)), 63 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)),
63 ptr_factory_(this) { 64 ptr_factory_(this) {
64 DCHECK(factory); 65 DCHECK(factory);
65 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, 66 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER,
66 base::Bind(&NetLogJobControllerCallback, 67 base::Bind(&NetLogJobControllerCallback,
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_DELAYED, 543 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_DELAYED,
543 NetLog::Int64Callback("delay", delay.InMilliseconds())); 544 NetLog::Int64Callback("delay", delay.InMilliseconds()));
544 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 545 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
545 FROM_HERE, 546 FROM_HERE,
546 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob, 547 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
547 ptr_factory_.GetWeakPtr()), 548 ptr_factory_.GetWeakPtr()),
548 delay); 549 delay);
549 } 550 }
550 551
551 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { 552 void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
553 if (main_job_is_resumed_)
554 return;
555
556 main_job_is_resumed_ = true;
552 main_job_->net_log().AddEvent( 557 main_job_->net_log().AddEvent(
553 NetLogEventType::HTTP_STREAM_JOB_RESUMED, 558 NetLogEventType::HTTP_STREAM_JOB_RESUMED,
554 NetLog::Int64Callback("delay", main_job_wait_time_.InMilliseconds())); 559 NetLog::Int64Callback("delay", main_job_wait_time_.InMilliseconds()));
555 560
556 main_job_->Resume(); 561 main_job_->Resume();
557 main_job_wait_time_ = base::TimeDelta(); 562 main_job_wait_time_ = base::TimeDelta();
558 } 563 }
559 564
560 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( 565 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob(
561 Job* job, 566 Job* job,
562 const base::TimeDelta& delay) { 567 const base::TimeDelta& delay) {
568 DCHECK(delay == base::TimeDelta() || delay == main_job_wait_time_);
563 DCHECK(job == main_job_.get() || job == alternative_job_.get()); 569 DCHECK(job == main_job_.get() || job == alternative_job_.get());
564 570
565 if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_) 571 if (job != alternative_job_.get() || !main_job_)
566 return; 572 return;
567 573
568 main_job_is_blocked_ = false; 574 main_job_is_blocked_ = false;
569 575
570 if (!main_job_->is_waiting()) 576 if (!main_job_->is_waiting()) {
577 // There are two cases where the main job is not in WAIT state:
578 // 1) The main job hasn't got to waiting state, do not yet post a task to
579 // resume since that will happen in ShouldWait().
580 // 2) The main job has passed waiting state, so the main job does not need
581 // to be resumed.
571 return; 582 return;
583 }
584
585 main_job_wait_time_ = delay;
Ryan Hamilton 2017/02/15 14:53:55 Does this need to happen before the early return o
572 586
573 ResumeMainJobLater(main_job_wait_time_); 587 ResumeMainJobLater(main_job_wait_time_);
574 } 588 }
575 589
576 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job, 590 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job,
577 int rv) { 591 int rv) {
578 if (rv != OK) { 592 if (rv != OK) {
579 // Resume the main job as there's an error raised in connection 593 // Resume the main job as there's an error raised in connection
580 // initiation. 594 // initiation.
581 return MaybeResumeMainJob(job, main_job_wait_time_); 595 return MaybeResumeMainJob(job, main_job_wait_time_);
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 return; 1163 return;
1150 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1164 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1151 alternative_job_->Start(request_->stream_type()); 1165 alternative_job_->Start(request_->stream_type());
1152 } 1166 }
1153 1167
1154 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { 1168 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
1155 return !request_ || (job_bound_ && bound_job_ != job); 1169 return !request_ || (job_bound_ && bound_job_ != job);
1156 } 1170 }
1157 1171
1158 } // namespace net 1172 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.h ('k') | net/http/http_stream_factory_impl_job_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698