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

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

Issue 602763004: QUIC - Used Quic and IP Address in prefs persistent store. It is (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@persist_global
Patch Set: Created 6 years, 2 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') | no next file » | 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 <set> 7 #include <set>
8 8
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // TODO: This should be tested and optimized, and even better, suggest a window 64 // TODO: This should be tested and optimized, and even better, suggest a window
65 // that corresponds to historical bandwidth and min-RTT. 65 // that corresponds to historical bandwidth and min-RTT.
66 // Larger initial congestion windows can, if we don't overshoot, reduce latency 66 // Larger initial congestion windows can, if we don't overshoot, reduce latency
67 // by avoiding the RTT needed for slow start to double (and re-double) from a 67 // by avoiding the RTT needed for slow start to double (and re-double) from a
68 // default of 10. 68 // default of 10.
69 // We match SPDY's use of 32 when secure (since we'd compete with SPDY). 69 // We match SPDY's use of 32 when secure (since we'd compete with SPDY).
70 const int32 kServerSecureInitialCongestionWindow = 32; 70 const int32 kServerSecureInitialCongestionWindow = 32;
71 // Be conservative, and just use double a typical TCP ICWND for HTTP. 71 // Be conservative, and just use double a typical TCP ICWND for HTTP.
72 const int32 kServerInecureInitialCongestionWindow = 20; 72 const int32 kServerInecureInitialCongestionWindow = 20;
73 73
74 const char kDummyHostname[] = "quic.global.props";
75 const uint16 kDummyPort = 0;
76
74 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { 77 void HistogramCreateSessionFailure(enum CreateSessionFailure error) {
75 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, 78 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error,
76 CREATION_ERROR_MAX); 79 CREATION_ERROR_MAX);
77 } 80 }
78 81
79 bool IsEcdsaSupported() { 82 bool IsEcdsaSupported() {
80 #if defined(OS_WIN) 83 #if defined(OS_WIN)
81 if (base::win::GetVersion() < base::win::VERSION_VISTA) 84 if (base::win::GetVersion() < base::win::VERSION_VISTA)
82 return false; 85 return false;
83 #endif 86 #endif
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); 521 crypto_config_.AddCanonicalSuffix(".googlevideo.com");
519 crypto_config_.SetProofVerifier( 522 crypto_config_.SetProofVerifier(
520 new ProofVerifierChromium(cert_verifier, transport_security_state)); 523 new ProofVerifierChromium(cert_verifier, transport_security_state));
521 crypto_config_.SetChannelIDSource( 524 crypto_config_.SetChannelIDSource(
522 new ChannelIDSourceChromium(channel_id_service)); 525 new ChannelIDSourceChromium(channel_id_service));
523 base::CPU cpu; 526 base::CPU cpu;
524 if (cpu.has_aesni() && cpu.has_avx()) 527 if (cpu.has_aesni() && cpu.has_avx())
525 crypto_config_.PreferAesGcm(); 528 crypto_config_.PreferAesGcm();
526 if (!IsEcdsaSupported()) 529 if (!IsEcdsaSupported())
527 crypto_config_.DisableEcdsa(); 530 crypto_config_.DisableEcdsa();
531 if (http_server_properties_) {
532 // TODO(rtenneti): Delete host_port_pair and persist data in globals.
533 HostPortPair host_port_pair(kDummyHostname, kDummyPort);
534 if (http_server_properties_->GetSupportsQuic(host_port_pair).used_quic)
535 require_confirmation_ = false;
Ryan Hamilton 2014/09/25 20:59:42 This does not appear to be using the IP address. D
ramant (doing other things) 2014/09/26 00:04:05 Done.
536 }
528 } 537 }
529 538
530 QuicStreamFactory::~QuicStreamFactory() { 539 QuicStreamFactory::~QuicStreamFactory() {
531 CloseAllSessions(ERR_ABORTED); 540 CloseAllSessions(ERR_ABORTED);
532 while (!all_sessions_.empty()) { 541 while (!all_sessions_.empty()) {
533 delete all_sessions_.begin()->first; 542 delete all_sessions_.begin()->first;
534 all_sessions_.erase(all_sessions_.begin()); 543 all_sessions_.erase(all_sessions_.begin());
535 } 544 }
536 STLDeleteValues(&active_jobs_); 545 STLDeleteValues(&active_jobs_);
537 } 546 }
538 547
548 void QuicStreamFactory::set_require_confirmation(bool require_confirmation) {
549 require_confirmation_ = require_confirmation;
550 if (http_server_properties_) {
551 // TODO(rtenneti): Delete host_port_pair and persist data in globals.
552 HostPortPair host_port_pair(kDummyHostname, kDummyPort);
553 http_server_properties_->SetSupportsQuic(
554 host_port_pair, !require_confirmation, local_address_.ToString());
555 }
556 }
557
539 int QuicStreamFactory::Create(const HostPortPair& host_port_pair, 558 int QuicStreamFactory::Create(const HostPortPair& host_port_pair,
540 bool is_https, 559 bool is_https,
541 PrivacyMode privacy_mode, 560 PrivacyMode privacy_mode,
542 base::StringPiece method, 561 base::StringPiece method,
543 const BoundNetLog& net_log, 562 const BoundNetLog& net_log,
544 QuicStreamRequest* request) { 563 QuicStreamRequest* request) {
545 QuicServerId server_id(host_port_pair, is_https, privacy_mode); 564 QuicServerId server_id(host_port_pair, is_https, privacy_mode);
546 if (HasActiveSession(server_id)) { 565 if (HasActiveSession(server_id)) {
547 request->set_stream(CreateIfSessionExists(server_id, net_log)); 566 request->set_stream(CreateIfSessionExists(server_id, net_log));
548 return OK; 567 return OK;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 session_aliases_[session].insert(server_id); 628 session_aliases_[session].insert(server_id);
610 return true; 629 return true;
611 } 630 }
612 } 631 }
613 return false; 632 return false;
614 } 633 }
615 634
616 void QuicStreamFactory::OnJobComplete(Job* job, int rv) { 635 void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
617 if (rv == OK) { 636 if (rv == OK) {
618 if (!always_require_handshake_confirmation_) 637 if (!always_require_handshake_confirmation_)
619 require_confirmation_ = false; 638 set_require_confirmation(false);
620 639
621 // Create all the streams, but do not notify them yet. 640 // Create all the streams, but do not notify them yet.
622 for (RequestSet::iterator it = job_requests_map_[job].begin(); 641 for (RequestSet::iterator it = job_requests_map_[job].begin();
623 it != job_requests_map_[job].end() ; ++it) { 642 it != job_requests_map_[job].end() ; ++it) {
624 DCHECK(HasActiveSession(job->server_id())); 643 DCHECK(HasActiveSession(job->server_id()));
625 (*it)->set_stream(CreateIfSessionExists(job->server_id(), 644 (*it)->set_stream(CreateIfSessionExists(job->server_id(),
626 (*it)->net_log())); 645 (*it)->net_log()));
627 } 646 }
628 } 647 }
629 while (!job_requests_map_[job].empty()) { 648 while (!job_requests_map_[job].empty()) {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 784 }
766 return list; 785 return list;
767 } 786 }
768 787
769 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() { 788 void QuicStreamFactory::ClearCachedStatesInCryptoConfig() {
770 crypto_config_.ClearCachedStates(); 789 crypto_config_.ClearCachedStates();
771 } 790 }
772 791
773 void QuicStreamFactory::OnIPAddressChanged() { 792 void QuicStreamFactory::OnIPAddressChanged() {
774 CloseAllSessions(ERR_NETWORK_CHANGED); 793 CloseAllSessions(ERR_NETWORK_CHANGED);
775 require_confirmation_ = true; 794 set_require_confirmation(true);
776 } 795 }
777 796
778 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { 797 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) {
779 CloseAllSessions(ERR_CERT_DATABASE_CHANGED); 798 CloseAllSessions(ERR_CERT_DATABASE_CHANGED);
780 } 799 }
781 800
782 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) { 801 void QuicStreamFactory::OnCACertChanged(const X509Certificate* cert) {
783 // We should flush the sessions if we removed trust from a 802 // We should flush the sessions if we removed trust from a
784 // cert, because a previously trusted server may have become 803 // cert, because a previously trusted server may have become
785 // untrusted. 804 // untrusted.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 869 }
851 // Set a buffer large enough to contain the initial CWND's worth of packet 870 // Set a buffer large enough to contain the initial CWND's worth of packet
852 // to work around the problem with CHLO packets being sent out with the 871 // to work around the problem with CHLO packets being sent out with the
853 // wrong encryption level, when the send buffer is full. 872 // wrong encryption level, when the send buffer is full.
854 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); 873 rv = socket->SetSendBufferSize(kMaxPacketSize * 20);
855 if (rv != OK) { 874 if (rv != OK) {
856 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); 875 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER);
857 return rv; 876 return rv;
858 } 877 }
859 878
879 socket->GetLocalAddress(&local_address_);
860 DefaultPacketWriterFactory packet_writer_factory(socket.get()); 880 DefaultPacketWriterFactory packet_writer_factory(socket.get());
861 881
862 if (!helper_.get()) { 882 if (!helper_.get()) {
863 helper_.reset(new QuicConnectionHelper( 883 helper_.reset(new QuicConnectionHelper(
864 base::MessageLoop::current()->message_loop_proxy().get(), 884 base::MessageLoop::current()->message_loop_proxy().get(),
865 clock_.get(), random_generator_)); 885 clock_.get(), random_generator_));
866 } 886 }
867 887
868 QuicConnection* connection = new QuicConnection(connection_id, 888 QuicConnection* connection = new QuicConnection(connection_id,
869 addr, 889 addr,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 http_server_properties_->ClearAlternateProtocol(server); 1023 http_server_properties_->ClearAlternateProtocol(server);
1004 http_server_properties_->SetAlternateProtocol( 1024 http_server_properties_->SetAlternateProtocol(
1005 server, alternate.port, alternate.protocol, 1); 1025 server, alternate.port, alternate.protocol, 1);
1006 DCHECK_EQ(QUIC, 1026 DCHECK_EQ(QUIC,
1007 http_server_properties_->GetAlternateProtocol(server).protocol); 1027 http_server_properties_->GetAlternateProtocol(server).protocol);
1008 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( 1028 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken(
1009 server)); 1029 server));
1010 } 1030 }
1011 1031
1012 } // namespace net 1032 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698