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

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

Issue 2707583002: Revert of Resume the main job immediately when QUIC job fails, not wait for the head start timer to exprie (Closed)
Patch Set: 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 JobFactory* job_factory) 43 JobFactory* job_factory)
44 : factory_(factory), 44 : factory_(factory),
45 session_(session), 45 session_(session),
46 job_factory_(job_factory), 46 job_factory_(job_factory),
47 request_(nullptr), 47 request_(nullptr),
48 delegate_(delegate), 48 delegate_(delegate),
49 is_preconnect_(false), 49 is_preconnect_(false),
50 alternative_job_failed_(false), 50 alternative_job_failed_(false),
51 job_bound_(false), 51 job_bound_(false),
52 main_job_is_blocked_(false), 52 main_job_is_blocked_(false),
53 main_job_is_resumed_(false),
54 bound_job_(nullptr), 53 bound_job_(nullptr),
55 can_start_alternative_proxy_job_(false), 54 can_start_alternative_proxy_job_(false),
56 ptr_factory_(this) { 55 ptr_factory_(this) {
57 DCHECK(factory); 56 DCHECK(factory);
58 } 57 }
59 58
60 HttpStreamFactoryImpl::JobController::~JobController() { 59 HttpStreamFactoryImpl::JobController::~JobController() {
61 main_job_.reset(); 60 main_job_.reset();
62 alternative_job_.reset(); 61 alternative_job_.reset();
63 bound_job_ = nullptr; 62 bound_job_ = nullptr;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 Job* job, 509 Job* job,
511 const ConnectionAttempts& attempts) { 510 const ConnectionAttempts& attempts) {
512 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) 511 if (is_preconnect_ || (job_bound_ && bound_job_ != job))
513 return; 512 return;
514 513
515 DCHECK(request_); 514 DCHECK(request_);
516 request_->AddConnectionAttempts(attempts); 515 request_->AddConnectionAttempts(attempts);
517 } 516 }
518 517
519 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { 518 void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
520 if (main_job_is_resumed_)
521 return;
522
523 main_job_is_resumed_ = true;
524 main_job_->net_log().AddEvent( 519 main_job_->net_log().AddEvent(
525 NetLogEventType::HTTP_STREAM_JOB_DELAYED, 520 NetLogEventType::HTTP_STREAM_JOB_DELAYED,
526 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); 521 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_));
527 522
528 main_job_->Resume(); 523 main_job_->Resume();
529 main_job_wait_time_ = base::TimeDelta(); 524 main_job_wait_time_ = base::TimeDelta();
530 } 525 }
531 526
532 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( 527 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob(
533 Job* job, 528 Job* job,
534 const base::TimeDelta& delay) { 529 const base::TimeDelta& delay) {
535 DCHECK(delay == base::TimeDelta() || delay == main_job_wait_time_);
536 DCHECK(job == main_job_.get() || job == alternative_job_.get()); 530 DCHECK(job == main_job_.get() || job == alternative_job_.get());
537 531
538 if (job != alternative_job_.get() || !main_job_) 532 if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_)
539 return; 533 return;
540 534
541 main_job_is_blocked_ = false; 535 main_job_is_blocked_ = false;
542 536
543 if (!main_job_->is_waiting()) { 537 if (!main_job_->is_waiting())
544 // There are two cases where the main job is not in WAIT state:
545 // 1) The main job hasn't got to waiting state, do not yet post a task to
546 // resume since that will happen in ShouldWait().
547 // 2) The main job has passed waiting state, so the main job does not need
548 // to be resumed.
549 return; 538 return;
550 }
551
552 main_job_wait_time_ = delay;
553 539
554 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 540 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
555 FROM_HERE, 541 FROM_HERE,
556 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob, 542 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
557 ptr_factory_.GetWeakPtr()), 543 ptr_factory_.GetWeakPtr()),
558 main_job_wait_time_); 544 main_job_wait_time_);
559 } 545 }
560 546
561 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job, 547 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job,
562 int rv) { 548 int rv) {
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 return; 1097 return;
1112 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1098 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1113 alternative_job_->Start(request_->stream_type()); 1099 alternative_job_->Start(request_->stream_type());
1114 } 1100 }
1115 1101
1116 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { 1102 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
1117 return !request_ || (job_bound_ && bound_job_ != job); 1103 return !request_ || (job_bound_ && bound_job_ != job);
1118 } 1104 }
1119 1105
1120 } // namespace net 1106 } // 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