gfe-relnote: (n/a) Remove some unnecessary dynamic_casts from QUIC. No behavior change, not protected.
PiperOrigin-RevId: 241741824
Change-Id: Icb921e0f4e51a05da88a3149713683729b67afdd
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index 980ef82..190c0ed 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -498,28 +498,24 @@
// Get the max allowed stream ID, this should succeed.
EXPECT_NE(nullptr,
session_.GetOrCreateDynamicStream(
- QuicSessionPeer::v99_streamid_manager(
- dynamic_cast<QuicSession*>(&session_))
+ QuicSessionPeer::v99_streamid_manager(&session_)
->actual_max_allowed_incoming_bidirectional_stream_id()));
EXPECT_NE(
nullptr,
session_.GetOrCreateDynamicStream(
- QuicSessionPeer::v99_streamid_manager(
- dynamic_cast<QuicSession*>(&session_))
+ QuicSessionPeer::v99_streamid_manager(&session_)
->actual_max_allowed_incoming_unidirectional_stream_id()));
EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(1);
// Get the (max allowed stream ID)++, this should fail.
EXPECT_EQ(nullptr,
session_.GetOrCreateDynamicStream(
- QuicSessionPeer::v99_streamid_manager(
- dynamic_cast<QuicSession*>(&session_))
+ QuicSessionPeer::v99_streamid_manager(&session_)
->actual_max_allowed_incoming_bidirectional_stream_id() +
IdDelta()));
EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(1);
EXPECT_EQ(nullptr,
session_.GetOrCreateDynamicStream(
- QuicSessionPeer::v99_streamid_manager(
- dynamic_cast<QuicSession*>(&session_))
+ QuicSessionPeer::v99_streamid_manager(&session_)
->actual_max_allowed_incoming_unidirectional_stream_id() +
IdDelta()));
} else {
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index 89757de..f227190 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -84,11 +84,7 @@
debug_delegate_(nullptr),
network_change_visitor_(nullptr),
initial_congestion_window_(kInitialCongestionWindow),
- loss_algorithm_(
- unacked_packets_.use_uber_loss_algorithm()
- ? dynamic_cast<LossDetectionInterface*>(&uber_loss_algorithm_)
- : dynamic_cast<LossDetectionInterface*>(
- &general_loss_algorithm_)),
+ loss_algorithm_(GetInitialLossAlgorithm()),
general_loss_algorithm_(loss_type),
uber_loss_algorithm_(loss_type),
consecutive_rto_count_(0),
@@ -120,6 +116,13 @@
SetSendAlgorithm(congestion_control_type);
}
+LossDetectionInterface* QuicSentPacketManager::GetInitialLossAlgorithm() {
+ if (unacked_packets_.use_uber_loss_algorithm()) {
+ return &uber_loss_algorithm_;
+ }
+ return &general_loss_algorithm_;
+}
+
QuicSentPacketManager::~QuicSentPacketManager() {}
void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) {
diff --git a/quic/core/quic_sent_packet_manager.h b/quic/core/quic_sent_packet_manager.h
index c3c227e..c892126 100644
--- a/quic/core/quic_sent_packet_manager.h
+++ b/quic/core/quic_sent_packet_manager.h
@@ -502,6 +502,9 @@
// Sets the initial RTT of the connection.
void SetInitialRtt(QuicTime::Delta rtt);
+ // Should only be called from constructor.
+ LossDetectionInterface* GetInitialLossAlgorithm();
+
// Called when handshake is confirmed to remove the retransmittable frames
// from all packets of HANDSHAKE_DATA packet number space to ensure they don't
// get retransmitted and will eventually be removed from unacked packets map.