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

Unified 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: Fix compilation 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_stream_factory.cc
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index ea30b2e16e087c9c686e53ac1e0c9b936b17ffe7..040c563b0a0fe0cf407d3a94dbf1052ac76a3597 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -100,6 +100,26 @@ QuicConfig InitializeQuicConfig(bool enable_pacing,
return config;
}
+class ClientPacketWriterFactory : public QuicConnection::PacketWriterFactory {
wtc 2014/08/13 21:01:34 Note: I picked the "ClientPacketWriterFactory" nam
dmz 2014/08/14 17:22:42 I probably would have gone with DefaultPacketWrite
wtc 2014/08/14 20:05:00 Ah, I now also prefer "Default" because this facto
dmz 2014/08/14 21:24:51 Done.
+ public:
+ explicit ClientPacketWriterFactory(DatagramClientSocket* socket)
+ : socket_(socket) {}
+ virtual ~ClientPacketWriterFactory() {}
+
+ virtual QuicPacketWriter* Create(QuicConnection* connection) const OVERRIDE;
+
+ private:
+ DatagramClientSocket* socket_;
+};
+
+QuicPacketWriter* ClientPacketWriterFactory::Create(
+ QuicConnection* connection) const {
+ scoped_ptr<QuicDefaultPacketWriter> writer(
+ new QuicDefaultPacketWriter(socket_));
+ writer->SetConnection(connection);
+ return writer.release();
+}
+
} // namespace
QuicStreamFactory::IpAliasKey::IpAliasKey() {}
@@ -822,8 +842,7 @@ int QuicStreamFactory::CreateSession(
return rv;
}
- scoped_ptr<QuicDefaultPacketWriter> writer(
- new QuicDefaultPacketWriter(socket.get()));
+ ClientPacketWriterFactory packet_writer_factory(socket.get());
if (!helper_.get()) {
helper_.reset(new QuicConnectionHelper(
@@ -834,11 +853,10 @@ int QuicStreamFactory::CreateSession(
QuicConnection* connection = new QuicConnection(connection_id,
addr,
helper_.get(),
- writer.get(),
- false /* owns_writer */,
+ packet_writer_factory,
+ true /* owns_writer */,
false /* is_server */,
supported_versions_);
- writer->SetConnection(connection);
connection->set_max_packet_length(max_packet_length_);
InitializeCachedStateInCryptoConfig(server_id, server_info);
@@ -860,7 +878,7 @@ int QuicStreamFactory::CreateSession(
}
*session = new QuicClientSession(
- connection, socket.Pass(), writer.Pass(), this,
+ connection, socket.Pass(), this,
quic_crypto_client_stream_factory_, server_info.Pass(), server_id,
config, &crypto_config_,
base::MessageLoop::current()->message_loop_proxy().get(),

Powered by Google App Engine
This is Rietveld 408576698