gfe-relnote: Move QuicCryptoServerStream::Helper::GenerateConnectionIdForReject to QuicDispatcher::GenerateNewServerConnectionId. Refactor only.
This function used to be related to reject, but now it is only used to generate server connection ids when the incoming id length is unexpected by the dispatcher.
PiperOrigin-RevId: 263843315
Change-Id: I5405ad8e5712ced51c8090be6a99aff396f5ab32
diff --git a/quic/core/quic_crypto_server_stream.h b/quic/core/quic_crypto_server_stream.h
index c5e0abc..60a162c 100644
--- a/quic/core/quic_crypto_server_stream.h
+++ b/quic/core/quic_crypto_server_stream.h
@@ -125,12 +125,6 @@
public:
virtual ~Helper() {}
- // Given the current connection_id, generates a new ConnectionId to
- // be returned with a reject.
- virtual QuicConnectionId GenerateConnectionIdForReject(
- QuicTransportVersion version,
- QuicConnectionId connection_id) const = 0;
-
// Returns true if |message|, which was received on |self_address| is
// acceptable according to the visitor's policy. Otherwise, returns false
// and populates |error_details|.
diff --git a/quic/core/quic_crypto_server_stream_test.cc b/quic/core/quic_crypto_server_stream_test.cc
index 238162c..b58d987 100644
--- a/quic/core/quic_crypto_server_stream_test.cc
+++ b/quic/core/quic_crypto_server_stream_test.cc
@@ -90,8 +90,6 @@
server_session_.reset(server_session);
EXPECT_CALL(*server_session_->helper(), CanAcceptClientHello(_, _, _, _, _))
.Times(testing::AnyNumber());
- EXPECT_CALL(*server_session_->helper(), GenerateConnectionIdForReject(_, _))
- .Times(testing::AnyNumber());
crypto_test_utils::SetupCryptoServerConfigForTest(
server_connection_->clock(), server_connection_->random_generator(),
&server_crypto_config_);
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index 4c73dfe..b659bda 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -310,8 +310,7 @@
return it->second;
}
QuicConnectionId new_connection_id =
- session_helper_->GenerateConnectionIdForReject(version.transport_version,
- server_connection_id);
+ GenerateNewServerConnectionId(version, server_connection_id);
DCHECK_EQ(expected_server_connection_id_length_, new_connection_id.length());
// TODO(dschinazi) Prevent connection_id_map_ from growing indefinitely
// before we ship a version that supports variable length connection IDs
@@ -323,6 +322,12 @@
return new_connection_id;
}
+QuicConnectionId QuicDispatcher::GenerateNewServerConnectionId(
+ ParsedQuicVersion /*version*/,
+ QuicConnectionId /*connection_id*/) const {
+ return QuicUtils::CreateRandomConnectionId();
+}
+
bool QuicDispatcher::MaybeDispatchPacket(
const ReceivedPacketInfo& packet_info) {
// Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC.
diff --git a/quic/core/quic_dispatcher.h b/quic/core/quic_dispatcher.h
index 091e727..f7b0450 100644
--- a/quic/core/quic_dispatcher.h
+++ b/quic/core/quic_dispatcher.h
@@ -152,6 +152,11 @@
// otherwise, returns false and the packet needs further processing.
virtual bool MaybeDispatchPacket(const ReceivedPacketInfo& packet_info);
+ // Generate a connection ID with a length that is expected by the dispatcher.
+ virtual QuicConnectionId GenerateNewServerConnectionId(
+ ParsedQuicVersion version,
+ QuicConnectionId connection_id) const;
+
// Values to be returned by ValidityChecks() to indicate what should be done
// with a packet. Fates with greater values are considered to be higher
// priority. ValidityChecks should return fate based on the priority order
diff --git a/quic/core/quic_dispatcher_test.cc b/quic/core/quic_dispatcher_test.cc
index bd30333..b41c57f 100644
--- a/quic/core/quic_dispatcher_test.cc
+++ b/quic/core/quic_dispatcher_test.cc
@@ -118,9 +118,10 @@
version_manager,
QuicMakeUnique<MockQuicConnectionHelper>(),
std::unique_ptr<QuicCryptoServerStream::Helper>(
- new QuicSimpleCryptoServerStreamHelper(random)),
+ new QuicSimpleCryptoServerStreamHelper()),
QuicMakeUnique<MockAlarmFactory>(),
- kQuicDefaultConnectionIdLength) {}
+ kQuicDefaultConnectionIdLength),
+ random_(random) {}
MOCK_METHOD4(CreateQuicSession,
QuicServerSessionBase*(QuicConnectionId connection_id,
@@ -131,6 +132,12 @@
MOCK_METHOD1(ShouldCreateOrBufferPacketForConnection,
bool(const ReceivedPacketInfo& packet_info));
+ QuicConnectionId GenerateNewServerConnectionId(
+ ParsedQuicVersion /*version*/,
+ QuicConnectionId /*connection_id*/) const override {
+ return QuicUtils::CreateRandomConnectionId(random_);
+ }
+
struct TestQuicPerPacketContext : public QuicPerPacketContext {
std::string custom_packet_context;
};
@@ -152,6 +159,8 @@
using QuicDispatcher::SetAllowShortInitialServerConnectionIds;
using QuicDispatcher::writer;
+
+ QuicRandom* random_;
};
// A Connection class which unregisters the session from the dispatcher when
@@ -187,9 +196,7 @@
: QuicDispatcherTest(crypto_test_utils::ProofSourceForTesting()) {}
explicit QuicDispatcherTest(std::unique_ptr<ProofSource> proof_source)
- :
-
- version_manager_(AllSupportedVersions()),
+ : version_manager_(AllSupportedVersions()),
crypto_config_(QuicCryptoServerConfig::TESTING,
QuicRandom::GetInstance(),
std::move(proof_source),