Refactor GfeQuicCryptoServerStream so parent class owns handshaker
Before this change, GfeQuicCryptoServerStream owns a
GfeQuicCryptoServerHandshaker (which is a
QuicCryptoServerStream::HandshakerDelegate), as well as being a
QuicCryptoServerStream which also owns a HandshakerDelegate. This
restructures those two classes so only QuicCryptoServerStream owns the
handshaker, and GfeQuicCryptoServerStream can provide a different
handshaker.
gfe-relnote: refactor GfeQuicCryptoServerStream and QuicCryptoServerStream, no behavior change, not flag protected
PiperOrigin-RevId: 286504120
Change-Id: Ifd219b1a43e06606a96f2967ff84f07be644e8b6
diff --git a/quic/core/quic_crypto_server_stream.cc b/quic/core/quic_crypto_server_stream.cc
index 02088df..f0f0f64 100644
--- a/quic/core/quic_crypto_server_stream.cc
+++ b/quic/core/quic_crypto_server_stream.cc
@@ -42,81 +42,81 @@
QuicCryptoServerStream::~QuicCryptoServerStream() {}
void QuicCryptoServerStream::CancelOutstandingCallbacks() {
- if (handshaker()) {
- handshaker()->CancelOutstandingCallbacks();
+ if (handshaker_) {
+ handshaker_->CancelOutstandingCallbacks();
}
}
bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID(
std::string* output) const {
- return handshaker()->GetBase64SHA256ClientChannelID(output);
+ return handshaker_->GetBase64SHA256ClientChannelID(output);
}
void QuicCryptoServerStream::SendServerConfigUpdate(
const CachedNetworkParameters* cached_network_params) {
- handshaker()->SendServerConfigUpdate(cached_network_params);
+ handshaker_->SendServerConfigUpdate(cached_network_params);
}
uint8_t QuicCryptoServerStream::NumHandshakeMessages() const {
- return handshaker()->NumHandshakeMessages();
+ return handshaker_->NumHandshakeMessages();
}
uint8_t QuicCryptoServerStream::NumHandshakeMessagesWithServerNonces() const {
- return handshaker()->NumHandshakeMessagesWithServerNonces();
+ return handshaker_->NumHandshakeMessagesWithServerNonces();
}
int QuicCryptoServerStream::NumServerConfigUpdateMessagesSent() const {
- return handshaker()->NumServerConfigUpdateMessagesSent();
+ return handshaker_->NumServerConfigUpdateMessagesSent();
}
const CachedNetworkParameters*
QuicCryptoServerStream::PreviousCachedNetworkParams() const {
- return handshaker()->PreviousCachedNetworkParams();
+ return handshaker_->PreviousCachedNetworkParams();
}
bool QuicCryptoServerStream::ZeroRttAttempted() const {
- return handshaker()->ZeroRttAttempted();
+ return handshaker_->ZeroRttAttempted();
}
void QuicCryptoServerStream::SetPreviousCachedNetworkParams(
CachedNetworkParameters cached_network_params) {
- handshaker()->SetPreviousCachedNetworkParams(cached_network_params);
+ handshaker_->SetPreviousCachedNetworkParams(cached_network_params);
}
bool QuicCryptoServerStream::ShouldSendExpectCTHeader() const {
- return handshaker()->ShouldSendExpectCTHeader();
+ return handshaker_->ShouldSendExpectCTHeader();
}
bool QuicCryptoServerStream::encryption_established() const {
- if (!handshaker()) {
+ if (!handshaker_) {
return false;
}
- return handshaker()->encryption_established();
+ return handshaker_->encryption_established();
}
bool QuicCryptoServerStream::handshake_confirmed() const {
- if (!handshaker()) {
+ if (!handshaker_) {
return false;
}
- return handshaker()->handshake_confirmed();
+ return handshaker_->handshake_confirmed();
}
const QuicCryptoNegotiatedParameters&
QuicCryptoServerStream::crypto_negotiated_params() const {
- return handshaker()->crypto_negotiated_params();
+ return handshaker_->crypto_negotiated_params();
}
CryptoMessageParser* QuicCryptoServerStream::crypto_message_parser() {
- return handshaker()->crypto_message_parser();
+ return handshaker_->crypto_message_parser();
}
void QuicCryptoServerStream::OnPacketDecrypted(EncryptionLevel level) {
- handshaker()->OnPacketDecrypted(level);
+ handshaker_->OnPacketDecrypted(level);
}
size_t QuicCryptoServerStream::BufferSizeLimitForLevel(
EncryptionLevel level) const {
- return handshaker()->BufferSizeLimitForLevel(level);
+ return handshaker_->BufferSizeLimitForLevel(level);
}
void QuicCryptoServerStream::OnSuccessfulVersionNegotiation(
@@ -139,9 +139,28 @@
}
}
+void QuicCryptoServerStream::set_handshaker(
+ std::unique_ptr<QuicCryptoServerStream::HandshakerDelegate> handshaker) {
+ CHECK(!handshaker_);
+ handshaker_ = std::move(handshaker);
+}
+
QuicCryptoServerStream::HandshakerDelegate* QuicCryptoServerStream::handshaker()
const {
return handshaker_.get();
}
+const QuicCryptoServerConfig* QuicCryptoServerStream::crypto_config() const {
+ return crypto_config_;
+}
+
+QuicCompressedCertsCache* QuicCryptoServerStream::compressed_certs_cache()
+ const {
+ return compressed_certs_cache_;
+}
+
+QuicCryptoServerStream::Helper* QuicCryptoServerStream::helper() const {
+ return helper_;
+}
+
} // namespace quic
diff --git a/quic/core/quic_crypto_server_stream.h b/quic/core/quic_crypto_server_stream.h
index d80c495..2e0e723 100644
--- a/quic/core/quic_crypto_server_stream.h
+++ b/quic/core/quic_crypto_server_stream.h
@@ -184,7 +184,16 @@
protected:
// Provided so that subclasses can provide their own handshaker.
- virtual HandshakerDelegate* handshaker() const;
+ // set_handshaker can only be called if this QuicCryptoServerStream's
+ // handshaker hasn't been set yet. If set_handshaker is called outside of
+ // OnSuccessfulVersionNegotiation, then that method must be overridden to not
+ // set a handshaker.
+ void set_handshaker(std::unique_ptr<HandshakerDelegate> handshaker);
+ HandshakerDelegate* handshaker() const;
+
+ const QuicCryptoServerConfig* crypto_config() const;
+ QuicCompressedCertsCache* compressed_certs_cache() const;
+ Helper* helper() const;
private:
std::unique_ptr<HandshakerDelegate> handshaker_;