gfe-relnote: Use HandshakerDelegateInterface in QUIC handshakers. Abstract keys installation, keys discarding, default encryption level change and mark handshake complete to HandshakerDelegateInterface. Protected by gfe2_reloadable_flag_quic_use_handshaker_delegate.
The final goal is remove session pointer from handshakers.
PiperOrigin-RevId: 282826263
Change-Id: I9b379ccfcebd174df1850f7df45069d388460173
diff --git a/quic/core/http/quic_spdy_client_session_base.cc b/quic/core/http/quic_spdy_client_session_base.cc
index aef68c8..0150be8 100644
--- a/quic/core/http/quic_spdy_client_session_base.cc
+++ b/quic/core/http/quic_spdy_client_session_base.cc
@@ -48,6 +48,15 @@
}
}
+void QuicSpdyClientSessionBase::SetDefaultEncryptionLevel(
+ quic::EncryptionLevel level) {
+ QuicSpdySession::SetDefaultEncryptionLevel(level);
+ if (level == ENCRYPTION_FORWARD_SECURE && max_allowed_push_id() > 0 &&
+ VersionUsesHttp3(transport_version())) {
+ SendMaxPushId();
+ }
+}
+
void QuicSpdyClientSessionBase::OnInitialHeadersComplete(
QuicStreamId stream_id,
const SpdyHeaderBlock& response_headers) {
diff --git a/quic/core/http/quic_spdy_client_session_base.h b/quic/core/http/quic_spdy_client_session_base.h
index aec5e75..b208abd 100644
--- a/quic/core/http/quic_spdy_client_session_base.h
+++ b/quic/core/http/quic_spdy_client_session_base.h
@@ -52,6 +52,7 @@
// Override base class to set FEC policy before any data is sent by client.
void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override;
+ void SetDefaultEncryptionLevel(quic::EncryptionLevel level) override;
// Called by |headers_stream_| when push promise headers have been
// completely received.
diff --git a/quic/core/http/quic_spdy_session.cc b/quic/core/http/quic_spdy_session.cc
index dfb8028..6bf2f1d 100644
--- a/quic/core/http/quic_spdy_session.cc
+++ b/quic/core/http/quic_spdy_session.cc
@@ -630,6 +630,11 @@
SendInitialData();
}
+void QuicSpdySession::SetDefaultEncryptionLevel(quic::EncryptionLevel level) {
+ QuicSession::SetDefaultEncryptionLevel(level);
+ SendInitialData();
+}
+
// True if there are open HTTP requests.
bool QuicSpdySession::ShouldKeepConnectionAlive() const {
if (!VersionUsesHttp3(transport_version())) {
diff --git a/quic/core/http/quic_spdy_session.h b/quic/core/http/quic_spdy_session.h
index 6bbf2ed..50ec602 100644
--- a/quic/core/http/quic_spdy_session.h
+++ b/quic/core/http/quic_spdy_session.h
@@ -313,6 +313,7 @@
QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener);
void OnCryptoHandshakeEvent(CryptoHandshakeEvent event) override;
+ void SetDefaultEncryptionLevel(quic::EncryptionLevel level) override;
bool supports_push_promise() { return supports_push_promise_; }
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index 3178beb..27717ab 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -99,9 +99,14 @@
}
EXPECT_THAT(error, IsQuicNoError());
session()->OnConfigNegotiated();
- session()->connection()->SetDefaultEncryptionLevel(
- ENCRYPTION_FORWARD_SECURE);
- session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
+ if (session()->use_handshake_delegate()) {
+ session()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
+ session()->DiscardOldEncryptionKey(ENCRYPTION_INITIAL);
+ } else {
+ session()->connection()->SetDefaultEncryptionLevel(
+ ENCRYPTION_FORWARD_SECURE);
+ session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
+ }
}
// QuicCryptoStream implementation
@@ -116,6 +121,7 @@
CryptoMessageParser* crypto_message_parser() override {
return QuicCryptoHandshaker::crypto_message_parser();
}
+ void OnPacketDecrypted(EncryptionLevel /*level*/) override {}
MOCK_METHOD0(OnCanWrite, void());
diff --git a/quic/core/http/quic_spdy_stream_test.cc b/quic/core/http/quic_spdy_stream_test.cc
index 74ad6ef..73177dc 100644
--- a/quic/core/http/quic_spdy_stream_test.cc
+++ b/quic/core/http/quic_spdy_stream_test.cc
@@ -245,8 +245,13 @@
EXPECT_CALL(*session_, WritevData(qpack_encoder_stream,
qpack_encoder_stream->id(), 1, 0, _));
}
- static_cast<QuicSession*>(session_.get())
- ->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_ESTABLISHED);
+ if (session_->use_handshake_delegate()) {
+ static_cast<QuicSession*>(session_.get())
+ ->SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT);
+ } else {
+ static_cast<QuicSession*>(session_.get())
+ ->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_ESTABLISHED);
+ }
}
QuicHeaderList ProcessHeaders(bool fin, const SpdyHeaderBlock& headers) {