Commit e85c62ce authored by Victor Vasiliev's avatar Victor Vasiliev Committed by Commit Bot

Move QuicConfig initialization logic into quic_context.h

This way, it can be used in QUIC code that does not depend on
QuicStreamFactory.

R=rch@chromium.org

Bug: 1011392
Change-Id: I5d585067012ec7e5c28779080326ebdd1318203a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973171Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726001}
parent 303d5c72
......@@ -11,6 +11,17 @@
namespace net {
namespace {
// The maximum receive window sizes for QUIC sessions and streams.
const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB
const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB
// Set the maximum number of undecryptable packets the connection will store.
const int32_t kMaxUndecryptablePackets = 100;
} // namespace
QuicParams::QuicParams() = default;
QuicParams::QuicParams(const QuicParams& other) = default;
......@@ -28,4 +39,28 @@ QuicContext::QuicContext(
QuicContext::~QuicContext() = default;
quic::QuicConfig InitializeQuicConfig(const QuicParams& params) {
DCHECK_GT(params.idle_connection_timeout, base::TimeDelta());
quic::QuicConfig config;
config.SetIdleNetworkTimeout(
quic::QuicTime::Delta::FromMicroseconds(
params.idle_connection_timeout.InMicroseconds()),
quic::QuicTime::Delta::FromMicroseconds(
params.idle_connection_timeout.InMicroseconds()));
config.set_max_time_before_crypto_handshake(
quic::QuicTime::Delta::FromMicroseconds(
params.max_time_before_crypto_handshake.InMicroseconds()));
config.set_max_idle_time_before_crypto_handshake(
quic::QuicTime::Delta::FromMicroseconds(
params.max_idle_time_before_crypto_handshake.InMicroseconds()));
config.SetConnectionOptionsToSend(params.connection_options);
config.SetClientConnectionOptions(params.client_connection_options);
config.set_max_undecryptable_packets(kMaxUndecryptablePackets);
config.SetInitialSessionFlowControlWindowToSend(
kQuicSessionMaxRecvWindowSize);
config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize);
config.SetBytesForConnectionIdToSend(0);
return config;
}
} // namespace net
......@@ -50,6 +50,12 @@ const int64_t kMaxMigrationsToNonDefaultNetworkOnWriteError = 5;
// degrading per network.
const int64_t kMaxMigrationsToNonDefaultNetworkOnPathDegrading = 5;
// QUIC's socket receive buffer size.
// We should adaptively set this buffer size, but for now, we'll use a size
// that seems large enough to receive data at line rate for most connections,
// and does not consume "too much" memory.
const int32_t kQuicSocketReceiveBufferSize = 1024 * 1024; // 1MB
// Structure containing simple configuration options and experiments for QUIC.
struct NET_EXPORT QuicParams {
QuicParams();
......@@ -189,6 +195,9 @@ class NET_EXPORT_PRIVATE QuicContext {
QuicParams params_;
};
// Initializes QuicConfig based on the specified parameters.
quic::QuicConfig InitializeQuicConfig(const QuicParams& params);
} // namespace net
#endif // NET_QUIC_QUIC_CONTEXT_H_
......@@ -107,19 +107,6 @@ enum class ConnectionStateAfterDNS {
kMaxValue = kCryptoFinishedDnsNoMatch,
};
// The maximum receive window sizes for QUIC sessions and streams.
const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB
const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB
// QUIC's socket receive buffer size.
// We should adaptively set this buffer size, but for now, we'll use a size
// that seems large enough to receive data at line rate for most connections,
// and does not consume "too much" memory.
const int32_t kQuicSocketReceiveBufferSize = 1024 * 1024; // 1MB
// Set the maximum number of undecryptable packets the connection will store.
const int32_t kMaxUndecryptablePackets = 100;
base::Value NetLogQuicStreamFactoryJobParams(
const quic::QuicServerId* server_id) {
base::DictionaryValue dict;
......@@ -196,25 +183,6 @@ void SetInitialRttEstimate(base::TimeDelta estimate,
config->SetInitialRoundTripTimeUsToSend(estimate.InMicroseconds());
}
quic::QuicConfig InitializeQuicConfig(const QuicParams& params) {
DCHECK_GT(params.idle_connection_timeout, base::TimeDelta());
quic::QuicConfig config;
config.SetIdleNetworkTimeout(
quic::QuicTime::Delta::FromMicroseconds(
params.idle_connection_timeout.InMicroseconds()),
quic::QuicTime::Delta::FromMicroseconds(
params.idle_connection_timeout.InMicroseconds()));
config.set_max_time_before_crypto_handshake(
quic::QuicTime::Delta::FromMicroseconds(
params.max_time_before_crypto_handshake.InMicroseconds()));
config.set_max_idle_time_before_crypto_handshake(
quic::QuicTime::Delta::FromMicroseconds(
params.max_idle_time_before_crypto_handshake.InMicroseconds()));
config.SetConnectionOptionsToSend(params.connection_options);
config.SetClientConnectionOptions(params.client_connection_options);
return config;
}
// An implementation of quic::QuicCryptoClientConfig::ServerIdFilter that wraps
// an |origin_filter|.
class ServerIdOriginFilter
......@@ -1931,11 +1899,6 @@ int QuicStreamFactory::CreateSession(
connection->SetMaxPacketLength(params_.max_packet_length);
quic::QuicConfig config = config_;
config.set_max_undecryptable_packets(kMaxUndecryptablePackets);
config.SetInitialSessionFlowControlWindowToSend(
kQuicSessionMaxRecvWindowSize);
config.SetInitialStreamFlowControlWindowToSend(kQuicStreamMaxRecvWindowSize);
config.SetBytesForConnectionIdToSend(0);
ConfigureInitialRttEstimate(
server_id, key.session_key().network_isolation_key(), &config);
if (quic_version.transport_version <= quic::QUIC_VERSION_43 &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment