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

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: More review comments 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..396df5cc80ede89f2ea48d692f068f557f6640ba 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 DefaultPacketWriterFactory : public QuicConnection::PacketWriterFactory {
+ public:
+ explicit DefaultPacketWriterFactory(DatagramClientSocket* socket)
+ : socket_(socket) {}
+ virtual ~DefaultPacketWriterFactory() {}
+
+ virtual QuicPacketWriter* Create(QuicConnection* connection) const OVERRIDE;
+
+ private:
+ DatagramClientSocket* socket_;
+};
+
+QuicPacketWriter* DefaultPacketWriterFactory::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()));
+ DefaultPacketWriterFactory 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