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

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

Issue 2699433003: Add net-log entries when HttpStream jobs are forced to wait, and when they're delayed and resumed. (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 15 matching lines...) Expand all
26 #include "net/spdy/spdy_session.h" 26 #include "net/spdy/spdy_session.h"
27 #include "url/url_constants.h" 27 #include "url/url_constants.h"
28 28
29 namespace net { 29 namespace net {
30 30
31 // Returns parameters associated with the delay of the HTTP stream job. 31 // Returns parameters associated with the delay of the HTTP stream job.
32 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( 32 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback(
33 base::TimeDelta delay, 33 base::TimeDelta delay,
34 NetLogCaptureMode /* capture_mode */) { 34 NetLogCaptureMode /* capture_mode */) {
35 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 35 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
36 dict->SetInteger("resume_after_ms", static_cast<int>(delay.InMilliseconds())); 36 dict->SetInteger("delay_ms", static_cast<int>(delay.InMilliseconds()));
eroman 2017/02/14 21:18:36 Optional: replace this funciton with NetLog::Int64
37 return std::move(dict); 37 return std::move(dict);
38 } 38 }
39 39
40 std::unique_ptr<base::Value> NetLogJobControllerCallback( 40 std::unique_ptr<base::Value> NetLogJobControllerCallback(
41 const GURL* url, 41 const GURL* url,
42 bool is_preconnect, 42 bool is_preconnect,
43 NetLogCaptureMode /* capture_mode */) { 43 NetLogCaptureMode /* capture_mode */) {
44 auto dict = base::MakeUnique<base::DictionaryValue>(); 44 auto dict = base::MakeUnique<base::DictionaryValue>();
45 dict->SetString("url", url->possibly_invalid_spec()); 45 dict->SetString("url", url->possibly_invalid_spec());
46 dict->SetBoolean("is_preconnect", is_preconnect); 46 dict->SetBoolean("is_preconnect", is_preconnect);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest( 539 void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest(
540 Job* job, 540 Job* job,
541 const ConnectionAttempts& attempts) { 541 const ConnectionAttempts& attempts) {
542 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) 542 if (is_preconnect_ || (job_bound_ && bound_job_ != job))
543 return; 543 return;
544 544
545 DCHECK(request_); 545 DCHECK(request_);
546 request_->AddConnectionAttempts(attempts); 546 request_->AddConnectionAttempts(attempts);
547 } 547 }
548 548
549 void HttpStreamFactoryImpl::JobController::ResumeMainJobLater(
550 const base::TimeDelta& delay) {
551 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_DELAYED,
552 base::Bind(&NetLogHttpStreamJobDelayCallback, delay));
553 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
554 FROM_HERE,
555 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
eroman 2017/02/14 21:18:36 FTR I didn't review this in detail (i.e. wether th
Ryan Hamilton 2017/02/14 21:42:37 *nod* I don't believe I've actually changed any be
556 ptr_factory_.GetWeakPtr()),
557 delay);
558 }
559
549 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { 560 void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
550 main_job_->net_log().AddEvent( 561 main_job_->net_log().AddEvent(
551 NetLogEventType::HTTP_STREAM_JOB_DELAYED, 562 NetLogEventType::HTTP_STREAM_JOB_RESUMED,
552 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); 563 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_));
553 564
554 main_job_->Resume(); 565 main_job_->Resume();
555 main_job_wait_time_ = base::TimeDelta(); 566 main_job_wait_time_ = base::TimeDelta();
556 } 567 }
557 568
558 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( 569 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob(
559 Job* job, 570 Job* job,
560 const base::TimeDelta& delay) { 571 const base::TimeDelta& delay) {
561 DCHECK(job == main_job_.get() || job == alternative_job_.get()); 572 DCHECK(job == main_job_.get() || job == alternative_job_.get());
562 573
563 if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_) 574 if (!main_job_is_blocked_ || job != alternative_job_.get() || !main_job_)
564 return; 575 return;
565 576
566 main_job_is_blocked_ = false; 577 main_job_is_blocked_ = false;
567 578
568 if (!main_job_->is_waiting()) 579 if (!main_job_->is_waiting())
569 return; 580 return;
570 581
571 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 582 ResumeMainJobLater(main_job_wait_time_);
572 FROM_HERE,
573 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
574 ptr_factory_.GetWeakPtr()),
575 main_job_wait_time_);
576 } 583 }
577 584
578 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job, 585 void HttpStreamFactoryImpl::JobController::OnConnectionInitialized(Job* job,
579 int rv) { 586 int rv) {
580 if (rv != OK) { 587 if (rv != OK) {
581 // Resume the main job as there's an error raised in connection 588 // Resume the main job as there's an error raised in connection
582 // initiation. 589 // initiation.
583 return MaybeResumeMainJob(job, main_job_wait_time_); 590 return MaybeResumeMainJob(job, main_job_wait_time_);
584 } 591 }
585 } 592 }
586 593
587 bool HttpStreamFactoryImpl::JobController::ShouldWait(Job* job) { 594 bool HttpStreamFactoryImpl::JobController::ShouldWait(Job* job) {
588 // The alternative job never waits. 595 // The alternative job never waits.
589 if (job == alternative_job_.get()) 596 if (job == alternative_job_.get())
590 return false; 597 return false;
591 598
592 if (main_job_is_blocked_) 599 if (main_job_is_blocked_)
593 return true; 600 return true;
594 601
595 if (main_job_wait_time_.is_zero()) 602 if (main_job_wait_time_.is_zero())
596 return false; 603 return false;
597 604
598 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 605 ResumeMainJobLater(main_job_wait_time_);
599 FROM_HERE,
600 base::Bind(&HttpStreamFactoryImpl::JobController::ResumeMainJob,
601 ptr_factory_.GetWeakPtr()),
602 main_job_wait_time_);
603
604 return true; 606 return true;
605 } 607 }
606 608
607 void HttpStreamFactoryImpl::JobController::SetSpdySessionKey( 609 void HttpStreamFactoryImpl::JobController::SetSpdySessionKey(
608 Job* job, 610 Job* job,
609 const SpdySessionKey& spdy_session_key) { 611 const SpdySessionKey& spdy_session_key) {
610 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) 612 if (is_preconnect_ || (job_bound_ && bound_job_ != job))
611 return; 613 return;
612 614
613 DCHECK(request_); 615 DCHECK(request_);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 return; 1158 return;
1157 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1159 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1158 alternative_job_->Start(request_->stream_type()); 1160 alternative_job_->Start(request_->stream_type());
1159 } 1161 }
1160 1162
1161 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { 1163 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
1162 return !request_ || (job_bound_ && bound_job_ != job); 1164 return !request_ || (job_bound_ && bound_job_ != job);
1163 } 1165 }
1164 1166
1165 } // namespace net 1167 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698