Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 18 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 // Returns parameters associated with the delay of the HTTP stream job. | 30 // Returns parameters associated with the delay of the HTTP stream job. |
| 31 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( | 31 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( |
| 32 base::TimeDelta delay, | 32 base::TimeDelta delay, |
| 33 NetLogCaptureMode /* capture_mode */) { | 33 NetLogCaptureMode /* capture_mode */) { |
| 34 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 34 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 35 dict->SetInteger("resume_after_ms", static_cast<int>(delay.InMilliseconds())); | 35 dict->SetInteger("resume_after_ms", static_cast<int>(delay.InMilliseconds())); |
| 36 return std::move(dict); | 36 return std::move(dict); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Returns parameters associated with the start of a JobController. | |
| 40 std::unique_ptr<base::Value> NetLogJobControllerCallback( | |
| 41 const NetLogSource& source, | |
| 42 bool is_preconnect, | |
| 43 NetLogCaptureMode /* capture_mode */) { | |
| 44 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | |
| 45 if (source.IsValid()) | |
| 46 source.AddToEventParameters(dict.get()); | |
| 47 dict->SetBoolean("is_preconnect", is_preconnect); | |
| 48 return std::move(dict); | |
| 49 } | |
| 50 | |
| 39 HttpStreamFactoryImpl::JobController::JobController( | 51 HttpStreamFactoryImpl::JobController::JobController( |
| 40 HttpStreamFactoryImpl* factory, | 52 HttpStreamFactoryImpl* factory, |
| 41 HttpStreamRequest::Delegate* delegate, | 53 HttpStreamRequest::Delegate* delegate, |
| 42 HttpNetworkSession* session, | 54 HttpNetworkSession* session, |
| 43 JobFactory* job_factory) | 55 JobFactory* job_factory, |
| 56 bool is_preconnect, | |
| 57 const NetLogWithSource& net_log) | |
|
mmenke
2017/01/25 19:32:17
Calling this net_log and having it be different fr
eroman
2017/01/25 19:55:27
Strongly agreed -- I found this quite confusing wh
xunjieli
2017/01/25 21:41:49
Done.
xunjieli
2017/01/25 21:41:49
Done. Great idea. That's neat!
| |
| 44 : factory_(factory), | 58 : factory_(factory), |
| 45 session_(session), | 59 session_(session), |
| 46 job_factory_(job_factory), | 60 job_factory_(job_factory), |
| 47 request_(nullptr), | 61 request_(nullptr), |
| 48 delegate_(delegate), | 62 delegate_(delegate), |
| 49 is_preconnect_(false), | 63 is_preconnect_(is_preconnect), |
| 50 alternative_job_failed_(false), | 64 alternative_job_failed_(false), |
| 51 job_bound_(false), | 65 job_bound_(false), |
| 52 main_job_is_blocked_(false), | 66 main_job_is_blocked_(false), |
| 53 bound_job_(nullptr), | 67 bound_job_(nullptr), |
| 54 can_start_alternative_proxy_job_(false), | 68 can_start_alternative_proxy_job_(false), |
| 69 net_log_( | |
| 70 NetLogWithSource::Make(session->net_log(), | |
| 71 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)), | |
| 55 ptr_factory_(this) { | 72 ptr_factory_(this) { |
| 56 DCHECK(factory); | 73 DCHECK(factory); |
| 74 if (net_log.source().IsValid()) { | |
|
mmenke
2017/01/25 19:32:17
Not needed - AddEvent checks if the NetLogWithSour
xunjieli
2017/01/25 21:41:49
Done. Thanks! I didn't realized that AddEvent() ch
| |
| 75 net_log.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, | |
| 76 net_log_.source().ToEventParametersCallback()); | |
|
Zhongyi Shi
2017/01/20 22:42:10
I am unfamiliar with NetLog, why do we need |net_l
xunjieli
2017/01/23 14:24:24
Yes, this is for linking the caller of JobControll
| |
| 77 } | |
| 78 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, | |
| 79 base::Bind(&NetLogJobControllerCallback, net_log.source(), | |
| 80 is_preconnect)); | |
| 57 } | 81 } |
| 58 | 82 |
| 59 HttpStreamFactoryImpl::JobController::~JobController() { | 83 HttpStreamFactoryImpl::JobController::~JobController() { |
| 60 main_job_.reset(); | 84 main_job_.reset(); |
| 61 alternative_job_.reset(); | 85 alternative_job_.reset(); |
| 62 bound_job_ = nullptr; | 86 bound_job_ = nullptr; |
| 87 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); | |
| 63 } | 88 } |
| 64 | 89 |
| 65 bool HttpStreamFactoryImpl::JobController::for_websockets() { | 90 bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| 66 return factory_->for_websockets_; | 91 return factory_->for_websockets_; |
| 67 } | 92 } |
| 68 | 93 |
| 69 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( | 94 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( |
| 70 const HttpRequestInfo& request_info, | 95 const HttpRequestInfo& request_info, |
| 71 HttpStreamRequest::Delegate* delegate, | 96 HttpStreamRequest::Delegate* delegate, |
| 72 WebSocketHandshakeStreamBase::CreateHelper* | 97 WebSocketHandshakeStreamBase::CreateHelper* |
| 73 websocket_handshake_stream_create_helper, | 98 websocket_handshake_stream_create_helper, |
| 74 const NetLogWithSource& net_log, | |
| 75 HttpStreamRequest::StreamType stream_type, | 99 HttpStreamRequest::StreamType stream_type, |
| 76 RequestPriority priority, | 100 RequestPriority priority, |
| 77 const SSLConfig& server_ssl_config, | 101 const SSLConfig& server_ssl_config, |
| 78 const SSLConfig& proxy_ssl_config) { | 102 const SSLConfig& proxy_ssl_config) { |
| 79 DCHECK(factory_); | 103 DCHECK(factory_); |
| 80 DCHECK(!request_); | 104 DCHECK(!request_); |
| 81 | 105 |
| 82 request_ = new Request(request_info.url, this, delegate, | 106 request_ = new Request(request_info.url, this, delegate, |
| 83 websocket_handshake_stream_create_helper, net_log, | 107 websocket_handshake_stream_create_helper, &net_log_, |
| 84 stream_type); | 108 stream_type); |
|
mmenke
2017/01/25 19:32:17
Should the request really be using the Controller'
xunjieli
2017/01/25 21:41:49
Done.
| |
| 85 | 109 |
| 86 CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, | 110 CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, |
| 87 delegate, stream_type, net_log); | 111 delegate, stream_type); |
| 88 | 112 |
| 89 return request_; | 113 return request_; |
| 90 } | 114 } |
| 91 | 115 |
| 92 void HttpStreamFactoryImpl::JobController::Preconnect( | 116 void HttpStreamFactoryImpl::JobController::Preconnect( |
| 93 int num_streams, | 117 int num_streams, |
| 94 const HttpRequestInfo& request_info, | 118 const HttpRequestInfo& request_info, |
| 95 const SSLConfig& server_ssl_config, | 119 const SSLConfig& server_ssl_config, |
| 96 const SSLConfig& proxy_ssl_config) { | 120 const SSLConfig& proxy_ssl_config) { |
| 97 DCHECK(!main_job_); | 121 DCHECK(!main_job_); |
| 98 DCHECK(!alternative_job_); | 122 DCHECK(!alternative_job_); |
|
mmenke
2017/01/25 19:32:17
DCHECK(is_preconnect_);?
eroman
2017/01/25 19:55:27
+1, I had same comment.
xunjieli
2017/01/25 21:41:49
Done.
| |
| 99 | 123 |
| 100 is_preconnect_ = true; | |
| 101 HostPortPair destination(HostPortPair::FromURL(request_info.url)); | 124 HostPortPair destination(HostPortPair::FromURL(request_info.url)); |
| 102 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); | 125 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); |
| 103 | 126 |
| 104 const AlternativeService alternative_service = GetAlternativeServiceFor( | 127 const AlternativeService alternative_service = GetAlternativeServiceFor( |
| 105 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); | 128 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); |
| 106 | 129 |
| 107 if (alternative_service.protocol != kProtoUnknown) { | 130 if (alternative_service.protocol != kProtoUnknown) { |
| 108 if (session_->params().quic_disable_preconnect_if_0rtt && | 131 if (session_->params().quic_disable_preconnect_if_0rtt && |
| 109 alternative_service.protocol == kProtoQUIC && | 132 alternative_service.protocol == kProtoQUIC && |
| 110 session_->quic_stream_factory()->ZeroRTTEnabledFor(QuicServerId( | 133 session_->quic_stream_factory()->ZeroRTTEnabledFor(QuicServerId( |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 DCHECK(!is_preconnect_); | 450 DCHECK(!is_preconnect_); |
| 428 | 451 |
| 429 bool is_job_orphaned = IsJobOrphaned(job); | 452 bool is_job_orphaned = IsJobOrphaned(job); |
| 430 | 453 |
| 431 // Cache these values in case the job gets deleted. | 454 // Cache these values in case the job gets deleted. |
| 432 const SSLConfig used_ssl_config = job->server_ssl_config(); | 455 const SSLConfig used_ssl_config = job->server_ssl_config(); |
| 433 const ProxyInfo used_proxy_info = job->proxy_info(); | 456 const ProxyInfo used_proxy_info = job->proxy_info(); |
| 434 const bool was_alpn_negotiated = job->was_alpn_negotiated(); | 457 const bool was_alpn_negotiated = job->was_alpn_negotiated(); |
| 435 const NextProto negotiated_protocol = job->negotiated_protocol(); | 458 const NextProto negotiated_protocol = job->negotiated_protocol(); |
| 436 const bool using_spdy = job->using_spdy(); | 459 const bool using_spdy = job->using_spdy(); |
| 437 const NetLogWithSource net_log = job->net_log(); | |
| 438 | 460 |
| 439 // Cache this so we can still use it if the JobController is deleted. | 461 // Cache this so we can still use it if the JobController is deleted. |
| 440 HttpStreamFactoryImpl* factory = factory_; | 462 HttpStreamFactoryImpl* factory = factory_; |
| 441 | 463 |
| 442 // Notify |request_|. | 464 // Notify |request_|. |
| 443 if (!is_preconnect_ && !is_job_orphaned) { | 465 if (!is_preconnect_ && !is_job_orphaned) { |
| 444 if (job->job_type() == MAIN && alternative_job_failed_) | 466 if (job->job_type() == MAIN && alternative_job_failed_) |
| 445 ReportBrokenAlternativeService(); | 467 ReportBrokenAlternativeService(); |
| 446 | 468 |
| 447 DCHECK(request_); | 469 DCHECK(request_); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 471 DCHECK(stream); | 493 DCHECK(stream); |
| 472 delegate_->OnStreamReady(used_ssl_config, used_proxy_info, | 494 delegate_->OnStreamReady(used_ssl_config, used_proxy_info, |
| 473 stream.release()); | 495 stream.release()); |
| 474 } | 496 } |
| 475 } | 497 } |
| 476 | 498 |
| 477 // Notify |factory_|. |request_| and |bounded_job_| might be deleted already. | 499 // Notify |factory_|. |request_| and |bounded_job_| might be deleted already. |
| 478 if (spdy_session && spdy_session->IsAvailable()) { | 500 if (spdy_session && spdy_session->IsAvailable()) { |
| 479 factory->OnNewSpdySessionReady(spdy_session, direct, used_ssl_config, | 501 factory->OnNewSpdySessionReady(spdy_session, direct, used_ssl_config, |
| 480 used_proxy_info, was_alpn_negotiated, | 502 used_proxy_info, was_alpn_negotiated, |
| 481 negotiated_protocol, using_spdy, net_log); | 503 negotiated_protocol, using_spdy); |
| 482 } | 504 } |
| 483 if (is_job_orphaned) { | 505 if (is_job_orphaned) { |
| 484 OnOrphanedJobComplete(job); | 506 OnOrphanedJobComplete(job); |
| 485 } | 507 } |
| 486 } | 508 } |
| 487 | 509 |
| 488 void HttpStreamFactoryImpl::JobController::OnPreconnectsComplete(Job* job) { | 510 void HttpStreamFactoryImpl::JobController::OnPreconnectsComplete(Job* job) { |
| 489 DCHECK_EQ(main_job_.get(), job); | 511 DCHECK_EQ(main_job_.get(), job); |
| 490 main_job_.reset(); | 512 main_job_.reset(); |
| 491 factory_->OnPreconnectsCompleteInternal(); | 513 factory_->OnPreconnectsCompleteInternal(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 509 Job* job, | 531 Job* job, |
| 510 const ConnectionAttempts& attempts) { | 532 const ConnectionAttempts& attempts) { |
| 511 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 533 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
| 512 return; | 534 return; |
| 513 | 535 |
| 514 DCHECK(request_); | 536 DCHECK(request_); |
| 515 request_->AddConnectionAttempts(attempts); | 537 request_->AddConnectionAttempts(attempts); |
| 516 } | 538 } |
| 517 | 539 |
| 518 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { | 540 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { |
| 519 main_job_->net_log().AddEvent( | 541 net_log_.AddEvent( |
| 520 NetLogEventType::HTTP_STREAM_JOB_DELAYED, | 542 NetLogEventType::HTTP_STREAM_JOB_DELAYED, |
| 521 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); | 543 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); |
| 522 | 544 |
| 523 main_job_->Resume(); | 545 main_job_->Resume(); |
| 524 main_job_wait_time_ = base::TimeDelta(); | 546 main_job_wait_time_ = base::TimeDelta(); |
| 525 } | 547 } |
| 526 | 548 |
| 527 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( | 549 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( |
| 528 Job* job, | 550 Job* job, |
| 529 const base::TimeDelta& delay) { | 551 const base::TimeDelta& delay) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 DCHECK(base::ContainsKey(request_set, request_)); | 631 DCHECK(base::ContainsKey(request_set, request_)); |
| 610 request_set.erase(request_); | 632 request_set.erase(request_); |
| 611 if (request_set.empty()) | 633 if (request_set.empty()) |
| 612 spdy_session_request_map.erase(*spdy_session_key); | 634 spdy_session_request_map.erase(*spdy_session_key); |
| 613 request_->ResetSpdySessionKey(); | 635 request_->ResetSpdySessionKey(); |
| 614 } | 636 } |
| 615 } | 637 } |
| 616 | 638 |
| 617 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( | 639 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( |
| 618 Job* job) const { | 640 Job* job) const { |
| 619 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 641 return &net_log_; |
|
eroman
2017/01/25 19:55:27
does this still need to check for |bound_job_ != j
xunjieli
2017/01/25 21:41:48
No. The check is not necessary. Before the change,
| |
| 620 return nullptr; | |
| 621 DCHECK(request_); | |
| 622 return &request_->net_log(); | |
| 623 } | 642 } |
| 624 | 643 |
| 625 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( | 644 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( |
| 626 const base::TimeDelta& delay) { | 645 const base::TimeDelta& delay) { |
| 627 if (main_job_is_blocked_) | 646 if (main_job_is_blocked_) |
| 628 main_job_wait_time_ = delay; | 647 main_job_wait_time_ = delay; |
| 629 } | 648 } |
| 630 | 649 |
| 631 WebSocketHandshakeStreamBase::CreateHelper* HttpStreamFactoryImpl:: | 650 WebSocketHandshakeStreamBase::CreateHelper* HttpStreamFactoryImpl:: |
| 632 JobController::websocket_handshake_stream_create_helper() { | 651 JobController::websocket_handshake_stream_create_helper() { |
| 633 DCHECK(request_); | 652 DCHECK(request_); |
| 634 return request_->websocket_handshake_stream_create_helper(); | 653 return request_->websocket_handshake_stream_create_helper(); |
| 635 } | 654 } |
| 636 | 655 |
| 637 void HttpStreamFactoryImpl::JobController::CreateJobs( | 656 void HttpStreamFactoryImpl::JobController::CreateJobs( |
| 638 const HttpRequestInfo& request_info, | 657 const HttpRequestInfo& request_info, |
| 639 RequestPriority priority, | 658 RequestPriority priority, |
| 640 const SSLConfig& server_ssl_config, | 659 const SSLConfig& server_ssl_config, |
| 641 const SSLConfig& proxy_ssl_config, | 660 const SSLConfig& proxy_ssl_config, |
| 642 HttpStreamRequest::Delegate* delegate, | 661 HttpStreamRequest::Delegate* delegate, |
| 643 HttpStreamRequest::StreamType stream_type, | 662 HttpStreamRequest::StreamType stream_type) { |
| 644 const NetLogWithSource& net_log) { | |
| 645 DCHECK(!main_job_); | 663 DCHECK(!main_job_); |
| 646 DCHECK(!alternative_job_); | 664 DCHECK(!alternative_job_); |
| 647 HostPortPair destination(HostPortPair::FromURL(request_info.url)); | 665 HostPortPair destination(HostPortPair::FromURL(request_info.url)); |
| 648 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); | 666 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); |
| 649 | 667 |
| 650 main_job_.reset(job_factory_->CreateJob( | 668 main_job_.reset(job_factory_->CreateJob( |
| 651 this, MAIN, session_, request_info, priority, server_ssl_config, | 669 this, MAIN, session_, request_info, priority, server_ssl_config, |
| 652 proxy_ssl_config, destination, origin_url, net_log.net_log())); | 670 proxy_ssl_config, destination, origin_url, net_log_.net_log())); |
| 653 AttachJob(main_job_.get()); | 671 AttachJob(main_job_.get()); |
| 654 | 672 |
| 655 // Create an alternative job if alternative service is set up for this domain. | 673 // Create an alternative job if alternative service is set up for this domain. |
| 656 const AlternativeService alternative_service = | 674 const AlternativeService alternative_service = |
| 657 GetAlternativeServiceFor(request_info, delegate, stream_type); | 675 GetAlternativeServiceFor(request_info, delegate, stream_type); |
| 658 | 676 |
| 659 if (alternative_service.protocol != kProtoUnknown) { | 677 if (alternative_service.protocol != kProtoUnknown) { |
| 660 // Never share connection with other jobs for FTP requests. | 678 // Never share connection with other jobs for FTP requests. |
| 661 DVLOG(1) << "Selected alternative service (host: " | 679 DVLOG(1) << "Selected alternative service (host: " |
| 662 << alternative_service.host_port_pair().host() | 680 << alternative_service.host_port_pair().host() |
| 663 << " port: " << alternative_service.host_port_pair().port() << ")"; | 681 << " port: " << alternative_service.host_port_pair().port() << ")"; |
| 664 | 682 |
| 665 DCHECK(!request_info.url.SchemeIs(url::kFtpScheme)); | 683 DCHECK(!request_info.url.SchemeIs(url::kFtpScheme)); |
| 666 HostPortPair alternative_destination(alternative_service.host_port_pair()); | 684 HostPortPair alternative_destination(alternative_service.host_port_pair()); |
| 667 ignore_result( | 685 ignore_result( |
| 668 ApplyHostMappingRules(request_info.url, &alternative_destination)); | 686 ApplyHostMappingRules(request_info.url, &alternative_destination)); |
| 669 | 687 |
| 670 alternative_job_.reset(job_factory_->CreateJob( | 688 alternative_job_.reset(job_factory_->CreateJob( |
| 671 this, ALTERNATIVE, session_, request_info, priority, server_ssl_config, | 689 this, ALTERNATIVE, session_, request_info, priority, server_ssl_config, |
| 672 proxy_ssl_config, alternative_destination, origin_url, | 690 proxy_ssl_config, alternative_destination, origin_url, |
| 673 alternative_service, net_log.net_log())); | 691 alternative_service, net_log_.net_log())); |
| 674 AttachJob(alternative_job_.get()); | 692 AttachJob(alternative_job_.get()); |
| 675 | 693 |
| 676 main_job_is_blocked_ = true; | 694 main_job_is_blocked_ = true; |
| 677 alternative_job_->Start(request_->stream_type()); | 695 alternative_job_->Start(request_->stream_type()); |
| 678 } else { | 696 } else { |
| 679 can_start_alternative_proxy_job_ = true; | 697 can_start_alternative_proxy_job_ = true; |
| 680 } | 698 } |
| 681 // Even if |alternative_job| has already finished, it will not have notified | 699 // Even if |alternative_job| has already finished, it will not have notified |
| 682 // the request yet, since we defer that to the next iteration of the | 700 // the request yet, since we defer that to the next iteration of the |
| 683 // MessageLoop, so starting |main_job_| is always safe. | 701 // MessageLoop, so starting |main_job_| is always safe. |
| 684 main_job_->Start(request_->stream_type()); | 702 main_job_->Start(request_->stream_type()); |
| 685 } | 703 } |
| 686 | 704 |
| 687 void HttpStreamFactoryImpl::JobController::AttachJob(Job* job) { | 705 void HttpStreamFactoryImpl::JobController::AttachJob(Job* job) { |
| 688 DCHECK(job); | 706 DCHECK(job); |
| 689 factory_->request_map_[job] = request_; | 707 factory_->request_map_[job] = request_; |
| 690 } | 708 } |
| 691 | 709 |
| 692 void HttpStreamFactoryImpl::JobController::BindJob(Job* job) { | 710 void HttpStreamFactoryImpl::JobController::BindJob(Job* job) { |
| 693 DCHECK(request_); | 711 DCHECK(request_); |
| 694 DCHECK(job); | 712 DCHECK(job); |
| 695 DCHECK(job == alternative_job_.get() || job == main_job_.get()); | 713 DCHECK(job == alternative_job_.get() || job == main_job_.get()); |
| 696 DCHECK(!job_bound_); | 714 DCHECK(!job_bound_); |
| 697 DCHECK(!bound_job_); | 715 DCHECK(!bound_job_); |
| 698 | 716 |
| 699 job_bound_ = true; | 717 job_bound_ = true; |
| 700 bound_job_ = job; | 718 bound_job_ = job; |
| 701 factory_->request_map_.erase(job); | 719 factory_->request_map_.erase(job); |
| 702 | 720 |
| 703 request_->net_log().AddEvent( | 721 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_JOB, |
| 704 NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_JOB, | 722 job->net_log().source().ToEventParametersCallback()); |
| 705 job->net_log().source().ToEventParametersCallback()); | |
| 706 job->net_log().AddEvent( | |
| 707 NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_REQUEST, | |
| 708 request_->net_log().source().ToEventParametersCallback()); | |
| 709 | |
| 710 OrphanUnboundJob(); | 723 OrphanUnboundJob(); |
| 711 } | 724 } |
| 712 | 725 |
| 713 void HttpStreamFactoryImpl::JobController::CancelJobs() { | 726 void HttpStreamFactoryImpl::JobController::CancelJobs() { |
| 714 DCHECK(request_); | 727 DCHECK(request_); |
| 715 RemoveRequestFromSpdySessionRequestMap(); | 728 RemoveRequestFromSpdySessionRequestMap(); |
| 716 if (job_bound_) | 729 if (job_bound_) |
| 717 return; | 730 return; |
| 718 if (alternative_job_) { | 731 if (alternative_job_) { |
| 719 factory_->request_map_.erase(alternative_job_.get()); | 732 factory_->request_map_.erase(alternative_job_.get()); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 return; | 1110 return; |
| 1098 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1111 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1099 alternative_job_->Start(request_->stream_type()); | 1112 alternative_job_->Start(request_->stream_type()); |
| 1100 } | 1113 } |
| 1101 | 1114 |
| 1102 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1115 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1103 return !request_ || (job_bound_ && bound_job_ != job); | 1116 return !request_ || (job_bound_ && bound_job_ != job); |
| 1104 } | 1117 } |
| 1105 | 1118 |
| 1106 } // namespace net | 1119 } // namespace net |
| OLD | NEW |