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

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

Issue 467963002: Refactoring: Create per-connection packet writers in QuicDispatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto ToT Created 6 years, 4 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_server_test.cc ('k') | net/quic/test_tools/mock_quic_dispatcher.h » ('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 <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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 config.SetDefaults(); 91 config.SetDefaults();
92 if (enable_time_based_loss_detection) 92 if (enable_time_based_loss_detection)
93 config.SetLossDetectionToSend(kTIME); 93 config.SetLossDetectionToSend(kTIME);
94 config.set_idle_connection_state_lifetime( 94 config.set_idle_connection_state_lifetime(
95 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds), 95 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds),
96 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds)); 96 QuicTime::Delta::FromSeconds(kIdleConnectionTimeoutSeconds));
97 config.SetConnectionOptionsToSend(connection_options); 97 config.SetConnectionOptionsToSend(connection_options);
98 return config; 98 return config;
99 } 99 }
100 100
101 class DefaultPacketWriterFactory : public QuicConnection::PacketWriterFactory {
102 public:
103 explicit DefaultPacketWriterFactory(DatagramClientSocket* socket)
104 : socket_(socket) {}
105 virtual ~DefaultPacketWriterFactory() {}
106
107 virtual QuicPacketWriter* Create(QuicConnection* connection) const OVERRIDE;
108
109 private:
110 DatagramClientSocket* socket_;
111 };
112
113 QuicPacketWriter* DefaultPacketWriterFactory::Create(
114 QuicConnection* connection) const {
115 scoped_ptr<QuicDefaultPacketWriter> writer(
116 new QuicDefaultPacketWriter(socket_));
117 writer->SetConnection(connection);
118 return writer.release();
119 }
120
101 } // namespace 121 } // namespace
102 122
103 QuicStreamFactory::IpAliasKey::IpAliasKey() {} 123 QuicStreamFactory::IpAliasKey::IpAliasKey() {}
104 124
105 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint, 125 QuicStreamFactory::IpAliasKey::IpAliasKey(IPEndPoint ip_endpoint,
106 bool is_https) 126 bool is_https)
107 : ip_endpoint(ip_endpoint), 127 : ip_endpoint(ip_endpoint),
108 is_https(is_https) {} 128 is_https(is_https) {}
109 129
110 QuicStreamFactory::IpAliasKey::~IpAliasKey() {} 130 QuicStreamFactory::IpAliasKey::~IpAliasKey() {}
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 831 }
812 // Set a buffer large enough to contain the initial CWND's worth of packet 832 // Set a buffer large enough to contain the initial CWND's worth of packet
813 // to work around the problem with CHLO packets being sent out with the 833 // to work around the problem with CHLO packets being sent out with the
814 // wrong encryption level, when the send buffer is full. 834 // wrong encryption level, when the send buffer is full.
815 rv = socket->SetSendBufferSize(kMaxPacketSize * 20); 835 rv = socket->SetSendBufferSize(kMaxPacketSize * 20);
816 if (rv != OK) { 836 if (rv != OK) {
817 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER); 837 HistogramCreateSessionFailure(CREATION_ERROR_SETTING_SEND_BUFFER);
818 return rv; 838 return rv;
819 } 839 }
820 840
821 scoped_ptr<QuicDefaultPacketWriter> writer( 841 DefaultPacketWriterFactory packet_writer_factory(socket.get());
822 new QuicDefaultPacketWriter(socket.get()));
823 842
824 if (!helper_.get()) { 843 if (!helper_.get()) {
825 helper_.reset(new QuicConnectionHelper( 844 helper_.reset(new QuicConnectionHelper(
826 base::MessageLoop::current()->message_loop_proxy().get(), 845 base::MessageLoop::current()->message_loop_proxy().get(),
827 clock_.get(), random_generator_)); 846 clock_.get(), random_generator_));
828 } 847 }
829 848
830 QuicConnection* connection = new QuicConnection(connection_id, 849 QuicConnection* connection = new QuicConnection(connection_id,
831 addr, 850 addr,
832 helper_.get(), 851 helper_.get(),
833 writer.get(), 852 packet_writer_factory,
834 false /* owns_writer */, 853 true /* owns_writer */,
835 false /* is_server */, 854 false /* is_server */,
836 supported_versions_); 855 supported_versions_);
837 writer->SetConnection(connection);
838 connection->set_max_packet_length(max_packet_length_); 856 connection->set_max_packet_length(max_packet_length_);
839 857
840 InitializeCachedStateInCryptoConfig(server_id, server_info); 858 InitializeCachedStateInCryptoConfig(server_id, server_info);
841 859
842 QuicConfig config = config_; 860 QuicConfig config = config_;
843 config.SetInitialCongestionWindowToSend( 861 config.SetInitialCongestionWindowToSend(
844 server_id.is_https() ? kServerSecureInitialCongestionWindow 862 server_id.is_https() ? kServerSecureInitialCongestionWindow
845 : kServerInecureInitialCongestionWindow); 863 : kServerInecureInitialCongestionWindow);
846 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize); 864 config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize);
847 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize); 865 config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize);
848 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); 866 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize);
849 if (http_server_properties_) { 867 if (http_server_properties_) {
850 const HttpServerProperties::NetworkStats* stats = 868 const HttpServerProperties::NetworkStats* stats =
851 http_server_properties_->GetServerNetworkStats( 869 http_server_properties_->GetServerNetworkStats(
852 server_id.host_port_pair()); 870 server_id.host_port_pair());
853 if (stats != NULL) { 871 if (stats != NULL) {
854 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); 872 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds());
855 } 873 }
856 } 874 }
857 875
858 *session = new QuicClientSession( 876 *session = new QuicClientSession(
859 connection, socket.Pass(), writer.Pass(), this, 877 connection, socket.Pass(), this,
860 quic_crypto_client_stream_factory_, server_info.Pass(), server_id, 878 quic_crypto_client_stream_factory_, server_info.Pass(), server_id,
861 config, &crypto_config_, 879 config, &crypto_config_,
862 base::MessageLoop::current()->message_loop_proxy().get(), 880 base::MessageLoop::current()->message_loop_proxy().get(),
863 net_log.net_log()); 881 net_log.net_log());
864 (*session)->InitializeSession(); 882 (*session)->InitializeSession();
865 all_sessions_[*session] = server_id; // owning pointer 883 all_sessions_[*session] = server_id; // owning pointer
866 return OK; 884 return OK;
867 } 885 }
868 886
869 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const { 887 bool QuicStreamFactory::HasActiveJob(const QuicServerId& key) const {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 http_server_properties_->ClearAlternateProtocol(server); 974 http_server_properties_->ClearAlternateProtocol(server);
957 http_server_properties_->SetAlternateProtocol( 975 http_server_properties_->SetAlternateProtocol(
958 server, alternate.port, alternate.protocol, 1); 976 server, alternate.port, alternate.protocol, 1);
959 DCHECK_EQ(QUIC, 977 DCHECK_EQ(QUIC,
960 http_server_properties_->GetAlternateProtocol(server).protocol); 978 http_server_properties_->GetAlternateProtocol(server).protocol);
961 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( 979 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken(
962 server)); 980 server));
963 } 981 }
964 982
965 } // namespace net 983 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_server_test.cc ('k') | net/quic/test_tools/mock_quic_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698