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 "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 void HttpStreamFactoryImpl::JobController::SetSpdySessionKey( | 508 void HttpStreamFactoryImpl::JobController::SetSpdySessionKey( |
509 Job* job, | 509 Job* job, |
510 const SpdySessionKey& spdy_session_key) { | 510 const SpdySessionKey& spdy_session_key) { |
511 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 511 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
512 return; | 512 return; |
513 | 513 |
514 DCHECK(request_); | 514 DCHECK(request_); |
515 if (!request_->HasSpdySessionKey()) { | 515 if (!request_->HasSpdySessionKey()) { |
516 RequestSet& request_set = | 516 RequestSet& request_set = |
517 factory_->spdy_session_request_map_[spdy_session_key]; | 517 factory_->spdy_session_request_map_[spdy_session_key]; |
518 DCHECK(!ContainsKey(request_set, request_)); | 518 DCHECK(!base::ContainsKey(request_set, request_)); |
519 request_set.insert(request_); | 519 request_set.insert(request_); |
520 request_->SetSpdySessionKey(spdy_session_key); | 520 request_->SetSpdySessionKey(spdy_session_key); |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 void HttpStreamFactoryImpl::JobController:: | 524 void HttpStreamFactoryImpl::JobController:: |
525 RemoveRequestFromSpdySessionRequestMapForJob(Job* job) { | 525 RemoveRequestFromSpdySessionRequestMapForJob(Job* job) { |
526 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 526 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
527 return; | 527 return; |
528 DCHECK(request_); | 528 DCHECK(request_); |
529 | 529 |
530 RemoveRequestFromSpdySessionRequestMap(); | 530 RemoveRequestFromSpdySessionRequestMap(); |
531 } | 531 } |
532 | 532 |
533 void HttpStreamFactoryImpl::JobController:: | 533 void HttpStreamFactoryImpl::JobController:: |
534 RemoveRequestFromSpdySessionRequestMap() { | 534 RemoveRequestFromSpdySessionRequestMap() { |
535 const SpdySessionKey* spdy_session_key = request_->spdy_session_key(); | 535 const SpdySessionKey* spdy_session_key = request_->spdy_session_key(); |
536 if (spdy_session_key) { | 536 if (spdy_session_key) { |
537 SpdySessionRequestMap& spdy_session_request_map = | 537 SpdySessionRequestMap& spdy_session_request_map = |
538 factory_->spdy_session_request_map_; | 538 factory_->spdy_session_request_map_; |
539 DCHECK(ContainsKey(spdy_session_request_map, *spdy_session_key)); | 539 DCHECK(base::ContainsKey(spdy_session_request_map, *spdy_session_key)); |
540 RequestSet& request_set = spdy_session_request_map[*spdy_session_key]; | 540 RequestSet& request_set = spdy_session_request_map[*spdy_session_key]; |
541 DCHECK(ContainsKey(request_set, request_)); | 541 DCHECK(base::ContainsKey(request_set, request_)); |
542 request_set.erase(request_); | 542 request_set.erase(request_); |
543 if (request_set.empty()) | 543 if (request_set.empty()) |
544 spdy_session_request_map.erase(*spdy_session_key); | 544 spdy_session_request_map.erase(*spdy_session_key); |
545 request_->ResetSpdySessionKey(); | 545 request_->ResetSpdySessionKey(); |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 const BoundNetLog* HttpStreamFactoryImpl::JobController::GetNetLog( | 549 const BoundNetLog* HttpStreamFactoryImpl::JobController::GetNetLog( |
550 Job* job) const { | 550 Job* job) const { |
551 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 551 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 } | 743 } |
744 } | 744 } |
745 | 745 |
746 // The QUIC whitelist is not needed in QUIC versions after 30. | 746 // The QUIC whitelist is not needed in QUIC versions after 30. |
747 if (!whitelist_needed) | 747 if (!whitelist_needed) |
748 return true; | 748 return true; |
749 | 749 |
750 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) | 750 if (session_->params().transport_security_state->IsGooglePinnedHost(host)) |
751 return true; | 751 return true; |
752 | 752 |
753 return ContainsKey(session_->params().quic_host_whitelist, | 753 return base::ContainsKey(session_->params().quic_host_whitelist, |
754 base::ToLowerASCII(host)); | 754 base::ToLowerASCII(host)); |
755 } | 755 } |
756 | 756 |
757 AlternativeService | 757 AlternativeService |
758 HttpStreamFactoryImpl::JobController::GetAlternativeServiceFor( | 758 HttpStreamFactoryImpl::JobController::GetAlternativeServiceFor( |
759 const HttpRequestInfo& request_info, | 759 const HttpRequestInfo& request_info, |
760 HttpStreamRequest::Delegate* delegate, | 760 HttpStreamRequest::Delegate* delegate, |
761 HttpStreamRequest::StreamType stream_type) { | 761 HttpStreamRequest::StreamType stream_type) { |
762 AlternativeService alternative_service = | 762 AlternativeService alternative_service = |
763 GetAlternativeServiceForInternal(request_info, delegate, stream_type); | 763 GetAlternativeServiceForInternal(request_info, delegate, stream_type); |
764 AlternativeServiceType type; | 764 AlternativeServiceType type; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 first_alternative_service = alternative_service; | 889 first_alternative_service = alternative_service; |
890 } | 890 } |
891 | 891 |
892 // Ask delegate to mark QUIC as broken for the origin. | 892 // Ask delegate to mark QUIC as broken for the origin. |
893 if (quic_advertised && quic_all_broken && delegate != nullptr) | 893 if (quic_advertised && quic_all_broken && delegate != nullptr) |
894 delegate->OnQuicBroken(); | 894 delegate->OnQuicBroken(); |
895 | 895 |
896 return first_alternative_service; | 896 return first_alternative_service; |
897 } | 897 } |
898 } | 898 } |
OLD | NEW |