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

Side by Side Diff: net/quic/quic_stream_factory.cc

Issue 1793273004: Revert of Implement QUIC-based net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@basecl
Patch Set: Created 4 years, 9 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
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic/quic_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "base/win/windows_version.h" 54 #include "base/win/windows_version.h"
55 #endif 55 #endif
56 56
57 #if defined(USE_OPENSSL) 57 #if defined(USE_OPENSSL)
58 #include <openssl/aead.h> 58 #include <openssl/aead.h>
59 #include "crypto/openssl_util.h" 59 #include "crypto/openssl_util.h"
60 #else 60 #else
61 #include "base/cpu.h" 61 #include "base/cpu.h"
62 #endif 62 #endif
63 63
64 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
65 #include "net/http/bidirectional_stream_job.h"
66 #include "net/quic/bidirectional_stream_quic_impl.h"
67 #endif
68
69 using std::min; 64 using std::min;
70 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; 65 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle;
71 66
72 namespace net { 67 namespace net {
73 68
74 namespace { 69 namespace {
75 70
76 enum CreateSessionFailure { 71 enum CreateSessionFailure {
77 CREATION_ERROR_CONNECTING_SOCKET, 72 CREATION_ERROR_CONNECTING_SOCKET,
78 CREATION_ERROR_SETTING_RECEIVE_BUFFER, 73 CREATION_ERROR_SETTING_RECEIVE_BUFFER,
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 factory_->CancelRequest(this); 506 factory_->CancelRequest(this);
512 } 507 }
513 508
514 int QuicStreamRequest::Request(const HostPortPair& host_port_pair, 509 int QuicStreamRequest::Request(const HostPortPair& host_port_pair,
515 PrivacyMode privacy_mode, 510 PrivacyMode privacy_mode,
516 int cert_verify_flags, 511 int cert_verify_flags,
517 const GURL& url, 512 const GURL& url,
518 base::StringPiece method, 513 base::StringPiece method,
519 const BoundNetLog& net_log, 514 const BoundNetLog& net_log,
520 const CompletionCallback& callback) { 515 const CompletionCallback& callback) {
516 DCHECK(!stream_);
521 DCHECK(callback_.is_null()); 517 DCHECK(callback_.is_null());
522 DCHECK(factory_); 518 DCHECK(factory_);
523 origin_host_ = url.host(); 519 origin_host_ = url.host();
524 privacy_mode_ = privacy_mode; 520 privacy_mode_ = privacy_mode;
525
526 int rv = factory_->Create(host_port_pair, privacy_mode, cert_verify_flags, 521 int rv = factory_->Create(host_port_pair, privacy_mode, cert_verify_flags,
527 url, method, net_log, this); 522 url, method, net_log, this);
528 if (rv == ERR_IO_PENDING) { 523 if (rv == ERR_IO_PENDING) {
529 host_port_pair_ = host_port_pair; 524 host_port_pair_ = host_port_pair;
530 net_log_ = net_log; 525 net_log_ = net_log;
531 callback_ = callback; 526 callback_ = callback;
532 } else { 527 } else {
533 factory_ = nullptr; 528 factory_ = nullptr;
534 } 529 }
535 if (rv == OK) 530 if (rv == OK)
536 DCHECK(session_); 531 DCHECK(stream_);
537 return rv; 532 return rv;
538 } 533 }
539 534
540 void QuicStreamRequest::SetSession(QuicChromiumClientSession* session) { 535 void QuicStreamRequest::set_stream(scoped_ptr<QuicHttpStream> stream) {
541 DCHECK(session); 536 DCHECK(stream);
542 session_ = session->GetWeakPtr(); 537 stream_ = std::move(stream);
543 } 538 }
544 539
545 void QuicStreamRequest::OnRequestComplete(int rv) { 540 void QuicStreamRequest::OnRequestComplete(int rv) {
546 factory_ = nullptr; 541 factory_ = nullptr;
547 callback_.Run(rv); 542 callback_.Run(rv);
548 } 543 }
549 544
550 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const { 545 base::TimeDelta QuicStreamRequest::GetTimeDelayForWaitingJob() const {
551 if (!factory_) 546 if (!factory_)
552 return base::TimeDelta(); 547 return base::TimeDelta();
553 return factory_->GetTimeDelayForWaitingJob( 548 return factory_->GetTimeDelayForWaitingJob(
554 QuicServerId(host_port_pair_, privacy_mode_)); 549 QuicServerId(host_port_pair_, privacy_mode_));
555 } 550 }
556 551
557 scoped_ptr<QuicHttpStream> QuicStreamRequest::CreateStream() { 552 scoped_ptr<QuicHttpStream> QuicStreamRequest::ReleaseStream() {
558 if (!session_) 553 DCHECK(stream_);
559 return nullptr; 554 return std::move(stream_);
560 return make_scoped_ptr(new QuicHttpStream(session_));
561 } 555 }
562 556
563 #if BUILDFLAG(ENABLE_BIDIRECTIONAL_STREAM)
564 scoped_ptr<BidirectionalStreamJob>
565 QuicStreamRequest::CreateBidirectionalStreamJob() {
566 if (!session_)
567 return nullptr;
568 return make_scoped_ptr(new BidirectionalStreamQuicImpl(session_));
569 }
570 #endif
571
572 QuicStreamFactory::QuicStreamFactory( 557 QuicStreamFactory::QuicStreamFactory(
573 HostResolver* host_resolver, 558 HostResolver* host_resolver,
574 ClientSocketFactory* client_socket_factory, 559 ClientSocketFactory* client_socket_factory,
575 base::WeakPtr<HttpServerProperties> http_server_properties, 560 base::WeakPtr<HttpServerProperties> http_server_properties,
576 CertVerifier* cert_verifier, 561 CertVerifier* cert_verifier,
577 CTPolicyEnforcer* ct_policy_enforcer, 562 CTPolicyEnforcer* ct_policy_enforcer,
578 ChannelIDService* channel_id_service, 563 ChannelIDService* channel_id_service,
579 TransportSecurityState* transport_security_state, 564 TransportSecurityState* transport_security_state,
580 CTVerifier* cert_transparency_verifier, 565 CTVerifier* cert_transparency_verifier,
581 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, 566 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 const BoundNetLog& net_log, 773 const BoundNetLog& net_log,
789 QuicStreamRequest* request) { 774 QuicStreamRequest* request) {
790 // Enforce session affinity for promised streams. 775 // Enforce session affinity for promised streams.
791 QuicClientPromisedInfo* promised = 776 QuicClientPromisedInfo* promised =
792 push_promise_index_.GetPromised(url.spec()); 777 push_promise_index_.GetPromised(url.spec());
793 if (promised) { 778 if (promised) {
794 QuicChromiumClientSession* session = 779 QuicChromiumClientSession* session =
795 static_cast<QuicChromiumClientSession*>(promised->session()); 780 static_cast<QuicChromiumClientSession*>(promised->session());
796 DCHECK(session); 781 DCHECK(session);
797 if (session->server_id().privacy_mode() == privacy_mode) { 782 if (session->server_id().privacy_mode() == privacy_mode) {
798 request->SetSession(session); 783 request->set_stream(CreateFromSession(session));
799 ++num_push_streams_created_; 784 ++num_push_streams_created_;
800 return OK; 785 return OK;
801 } 786 }
802 // This should happen extremely rarely (if ever), but if somehow a 787 // This should happen extremely rarely (if ever), but if somehow a
803 // request comes in with a mismatched privacy mode, consider the 788 // request comes in with a mismatched privacy mode, consider the
804 // promise borked. 789 // promise borked.
805 promised->Cancel(); 790 promised->Cancel();
806 } 791 }
807 792
808 QuicServerId server_id(host_port_pair, privacy_mode); 793 QuicServerId server_id(host_port_pair, privacy_mode);
809 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks. 794 // TODO(rtenneti): crbug.com/498823 - delete active_sessions_.empty() checks.
810 if (!active_sessions_.empty()) { 795 if (!active_sessions_.empty()) {
811 SessionMap::iterator it = active_sessions_.find(server_id); 796 SessionMap::iterator it = active_sessions_.find(server_id);
812 if (it != active_sessions_.end()) { 797 if (it != active_sessions_.end()) {
813 QuicChromiumClientSession* session = it->second; 798 QuicChromiumClientSession* session = it->second;
814 if (!session->CanPool(url.host(), privacy_mode)) 799 if (!session->CanPool(url.host(), privacy_mode))
815 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; 800 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
816 request->SetSession(session); 801 request->set_stream(CreateFromSession(session));
817 return OK; 802 return OK;
818 } 803 }
819 } 804 }
820 805
821 if (HasActiveJob(server_id)) { 806 if (HasActiveJob(server_id)) {
822 active_requests_[request] = server_id; 807 active_requests_[request] = server_id;
823 job_requests_map_[server_id].insert(request); 808 job_requests_map_[server_id].insert(request);
824 return ERR_IO_PENDING; 809 return ERR_IO_PENDING;
825 } 810 }
826 811
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // related changes. 847 // related changes.
863 if (active_sessions_.empty()) 848 if (active_sessions_.empty())
864 return ERR_QUIC_PROTOCOL_ERROR; 849 return ERR_QUIC_PROTOCOL_ERROR;
865 SessionMap::iterator it = active_sessions_.find(server_id); 850 SessionMap::iterator it = active_sessions_.find(server_id);
866 DCHECK(it != active_sessions_.end()); 851 DCHECK(it != active_sessions_.end());
867 if (it == active_sessions_.end()) 852 if (it == active_sessions_.end())
868 return ERR_QUIC_PROTOCOL_ERROR; 853 return ERR_QUIC_PROTOCOL_ERROR;
869 QuicChromiumClientSession* session = it->second; 854 QuicChromiumClientSession* session = it->second;
870 if (!session->CanPool(url.host(), privacy_mode)) 855 if (!session->CanPool(url.host(), privacy_mode))
871 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; 856 return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN;
872 request->SetSession(session); 857 request->set_stream(CreateFromSession(session));
873 } 858 }
874 return rv; 859 return rv;
875 } 860 }
876 861
877 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id, 862 void QuicStreamFactory::CreateAuxilaryJob(const QuicServerId server_id,
878 int cert_verify_flags, 863 int cert_verify_flags,
879 bool server_and_origin_have_same_host, 864 bool server_and_origin_have_same_host,
880 bool is_post, 865 bool is_post,
881 const BoundNetLog& net_log) { 866 const BoundNetLog& net_log) {
882 Job* aux_job = new Job( 867 Job* aux_job = new Job(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 RequestSet::iterator old_request_it = request_it; 925 RequestSet::iterator old_request_it = request_it;
941 ++request_it; 926 ++request_it;
942 // Remove request from containers so that OnRequestComplete() is not 927 // Remove request from containers so that OnRequestComplete() is not
943 // called later again on the same request. 928 // called later again on the same request.
944 job_requests_map_[server_id].erase(old_request_it); 929 job_requests_map_[server_id].erase(old_request_it);
945 active_requests_.erase(request); 930 active_requests_.erase(request);
946 // Notify request of certificate error. 931 // Notify request of certificate error.
947 request->OnRequestComplete(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN); 932 request->OnRequestComplete(ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN);
948 continue; 933 continue;
949 } 934 }
950 request->SetSession(session); 935 request->set_stream(CreateFromSession(session));
951 ++request_it; 936 ++request_it;
952 } 937 }
953 } 938 }
954 939
955 while (!job_requests_map_[server_id].empty()) { 940 while (!job_requests_map_[server_id].empty()) {
956 RequestSet::iterator it = job_requests_map_[server_id].begin(); 941 RequestSet::iterator it = job_requests_map_[server_id].begin();
957 QuicStreamRequest* request = *it; 942 QuicStreamRequest* request = *it;
958 job_requests_map_[server_id].erase(it); 943 job_requests_map_[server_id].erase(it);
959 active_requests_.erase(request); 944 active_requests_.erase(request);
960 // Even though we're invoking callbacks here, we don't need to worry 945 // Even though we're invoking callbacks here, we don't need to worry
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 // Since the session was active, there's no longer an 1736 // Since the session was active, there's no longer an
1752 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 1737 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
1753 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 1738 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
1754 // it as recently broken, which means that 0-RTT will be disabled but we'll 1739 // it as recently broken, which means that 0-RTT will be disabled but we'll
1755 // still race. 1740 // still race.
1756 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 1741 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
1757 alternative_service); 1742 alternative_service);
1758 } 1743 }
1759 1744
1760 } // namespace net 1745 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698