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

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: Always post task to resume the main job if it's in wait state, only execute resume main job once 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 bool is_preconnect) 56 bool is_preconnect)
57 : factory_(factory), 57 : factory_(factory),
58 session_(session), 58 session_(session),
59 job_factory_(job_factory), 59 job_factory_(job_factory),
60 request_(nullptr), 60 request_(nullptr),
61 delegate_(delegate), 61 delegate_(delegate),
62 is_preconnect_(is_preconnect), 62 is_preconnect_(is_preconnect),
63 alternative_job_net_error_(OK), 63 alternative_job_net_error_(OK),
64 job_bound_(false), 64 job_bound_(false),
65 main_job_is_blocked_(false), 65 main_job_is_blocked_(false),
66 main_job_is_resumed_(false),
66 bound_job_(nullptr), 67 bound_job_(nullptr),
67 can_start_alternative_proxy_job_(false), 68 can_start_alternative_proxy_job_(false),
68 privacy_mode_(PRIVACY_MODE_DISABLED), 69 privacy_mode_(PRIVACY_MODE_DISABLED),
69 net_log_( 70 net_log_(
70 NetLogWithSource::Make(session->net_log(), 71 NetLogWithSource::Make(session->net_log(),
71 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)), 72 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)),
72 ptr_factory_(this) { 73 ptr_factory_(this) {
73 DCHECK(factory); 74 DCHECK(factory);
74 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, 75 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER,
75 base::Bind(&NetLogJobControllerCallback, 76 base::Bind(&NetLogJobControllerCallback,
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 Job* job, 541 Job* job,
541 const ConnectionAttempts& attempts) { 542 const ConnectionAttempts& attempts) {
542 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) 543 if (is_preconnect_ || (job_bound_ && bound_job_ != job))
543 return; 544 return;
544 545
545 DCHECK(request_); 546 DCHECK(request_);
546 request_->AddConnectionAttempts(attempts); 547 request_->AddConnectionAttempts(attempts);
547 } 548 }
548 549
549 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { 550 void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
551 if (main_job_is_resumed_)
552 return;
553
554 main_job_is_resumed_ = true;
550 main_job_->net_log().AddEvent( 555 main_job_->net_log().AddEvent(
551 NetLogEventType::HTTP_STREAM_JOB_DELAYED, 556 NetLogEventType::HTTP_STREAM_JOB_DELAYED,
552 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); 557 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_));
553 558
554 main_job_->Resume(); 559 main_job_->Resume();
555 main_job_wait_time_ = base::TimeDelta(); 560 main_job_wait_time_ = base::TimeDelta();
556 } 561 }
557 562
558 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( 563 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob(
559 Job* job, 564 Job* job,
560 const base::TimeDelta& delay) { 565 const base::TimeDelta& delay) {
566 DCHECK(delay == base::TimeDelta() || delay == main_job_wait_time_);
561 DCHECK(job == main_job_.get() || job == alternative_job_.get()); 567 DCHECK(job == main_job_.get() || job == alternative_job_.get());
562 568
563 if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_) 569 if (job != alternative_job_.get() || !main_job_)
564 return; 570 return;
565 571
566 main_job_is_blocked_ = false; 572 if (main_job_is_blocked_)
573 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.
567 574
568 if (!main_job_->is_waiting()) 575 if (!main_job_->is_waiting()) {
576 // There are two cases where the main job is not in WAIT state:
577 // 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.
578 // 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.
569 return; 579 return;
580 }
581
582 main_job_wait_time_ = delay;
570 583
571 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 584 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
572 FROM_HERE, 585 FROM_HERE,
573 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob, 586 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
574 ptr_factory_.GetWeakPtr()), 587 ptr_factory_.GetWeakPtr()),
575 main_job_wait_time_); 588 main_job_wait_time_);
576 } 589 }
577 590
578 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job, 591 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job,
579 int rv) { 592 int rv) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 return; 1169 return;
1157 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1170 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1158 alternative_job_->Start(request_->stream_type()); 1171 alternative_job_->Start(request_->stream_type());
1159 } 1172 }
1160 1173
1161 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { 1174 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
1162 return !request_ || (job_bound_ && bound_job_ != job); 1175 return !request_ || (job_bound_ && bound_job_ != job);
1163 } 1176 }
1164 1177
1165 } // namespace net 1178 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698