Switch QuicMakeUnique to std::make_unique, part 1: //third_party/quic gfe-relnote: n/a (no functional change) PiperOrigin-RevId: 267662077 Change-Id: Ic63023042eafb77aa80d88749845f841b3078c57
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc index 6df0f7d..31986f0 100644 --- a/quic/core/quic_connection_test.cc +++ b/quic/core/quic_connection_test.cc
@@ -365,20 +365,20 @@ if (use_tagging_decrypter_) { if (framer_.framer()->version().KnowsWhichDecrypterToUse()) { - framer_.framer()->InstallDecrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingDecrypter>()); - framer_.framer()->InstallDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingDecrypter>()); - framer_.framer()->InstallDecrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingDecrypter>()); + framer_.framer()->InstallDecrypter( + ENCRYPTION_INITIAL, std::make_unique<TaggingDecrypter>()); + framer_.framer()->InstallDecrypter( + ENCRYPTION_ZERO_RTT, std::make_unique<TaggingDecrypter>()); + framer_.framer()->InstallDecrypter( + ENCRYPTION_FORWARD_SECURE, std::make_unique<TaggingDecrypter>()); } else { framer_.framer()->SetDecrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingDecrypter>()); + std::make_unique<TaggingDecrypter>()); } } else if (framer_.framer()->version().KnowsWhichDecrypterToUse()) { framer_.framer()->InstallDecrypter( ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<NullDecrypter>(Perspective::IS_SERVER)); + std::make_unique<NullDecrypter>(Perspective::IS_SERVER)); } EXPECT_TRUE(framer_.ProcessPacket(packet)); if (block_on_next_write_) { @@ -610,7 +610,7 @@ notifier_(nullptr) { writer->set_perspective(perspective); SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<NullEncrypter>(perspective)); + std::make_unique<NullEncrypter>(perspective)); SetDataProducer(&producer_); } TestConnection(const TestConnection&) = delete; @@ -686,7 +686,7 @@ StreamSendingState state) { ScopedPacketFlusher flusher(this); DCHECK(encryption_level >= ENCRYPTION_ZERO_RTT); - SetEncrypter(encryption_level, QuicMakeUnique<TaggingEncrypter>(0x01)); + SetEncrypter(encryption_level, std::make_unique<TaggingEncrypter>(0x01)); SetDefaultEncryptionLevel(encryption_level); struct iovec iov; MakeIOVector(data, &iov); @@ -826,7 +826,7 @@ void set_notifier(SimpleSessionNotifier* notifier) { notifier_ = notifier; } void ReturnEffectivePeerAddressForNextPacket(const QuicSocketAddress& addr) { - next_effective_peer_addr_ = QuicMakeUnique<QuicSocketAddress>(addr); + next_effective_peer_addr_ = std::make_unique<QuicSocketAddress>(addr); } bool PtoEnabled() { @@ -968,15 +968,15 @@ for (EncryptionLevel level : {ENCRYPTION_ZERO_RTT, ENCRYPTION_FORWARD_SECURE}) { peer_creator_.SetEncrypter( - level, QuicMakeUnique<NullEncrypter>(peer_framer_.perspective())); + level, std::make_unique<NullEncrypter>(peer_framer_.perspective())); } if (version().handshake_protocol == PROTOCOL_TLS1_3) { connection_.SetEncrypter( ENCRYPTION_INITIAL, - QuicMakeUnique<NullEncrypter>(Perspective::IS_CLIENT)); + std::make_unique<NullEncrypter>(Perspective::IS_CLIENT)); connection_.InstallDecrypter( ENCRYPTION_INITIAL, - QuicMakeUnique<NullDecrypter>(Perspective::IS_CLIENT)); + std::make_unique<NullDecrypter>(Perspective::IS_CLIENT)); } QuicFramerPeer::SetLastSerializedServerConnectionId( QuicConnectionPeer::GetFramer(&connection_), connection_id_); @@ -1040,7 +1040,7 @@ if (connection_.version().KnowsWhichDecrypterToUse()) { connection_.InstallDecrypter( ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<NullDecrypter>(Perspective::IS_CLIENT)); + std::make_unique<NullDecrypter>(Perspective::IS_CLIENT)); } } @@ -1179,17 +1179,17 @@ ENCRYPTION_INITIAL) { peer_framer_.SetEncrypter( QuicPacketCreatorPeer::GetEncryptionLevel(&peer_creator_), - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); // Set the corresponding decrypter. if (connection_.version().KnowsWhichDecrypterToUse()) { connection_.InstallDecrypter( QuicPacketCreatorPeer::GetEncryptionLevel(&peer_creator_), - QuicMakeUnique<StrictTaggingDecrypter>(0x01)); + std::make_unique<StrictTaggingDecrypter>(0x01)); connection_.RemoveDecrypter(ENCRYPTION_INITIAL); } else { connection_.SetDecrypter( QuicPacketCreatorPeer::GetEncryptionLevel(&peer_creator_), - QuicMakeUnique<StrictTaggingDecrypter>(0x01)); + std::make_unique<StrictTaggingDecrypter>(0x01)); } } @@ -1315,7 +1315,7 @@ return; } std::unique_ptr<QuicRstStreamFrame> rst_stream = - QuicMakeUnique<QuicRstStreamFrame>(1, id, error, bytes_written); + std::make_unique<QuicRstStreamFrame>(1, id, error, bytes_written); if (connection_.SendControlFrame(QuicFrame(rst_stream.get()))) { rst_stream.release(); } @@ -3111,9 +3111,9 @@ // Process a data packet to cause the visitor's OnCanWrite to be invoked. EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); peer_framer_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); SetDecrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<StrictTaggingDecrypter>(0x01)); + std::make_unique<StrictTaggingDecrypter>(0x01)); ProcessDataPacket(2); EXPECT_EQ(0u, connection_.NumQueuedPackets()); @@ -4210,7 +4210,7 @@ // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at // the end of the packet. We can test this to check which encrypter was used. connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); QuicByteCount packet_size; EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) .WillOnce(SaveArg<3>(&packet_size)); @@ -4219,7 +4219,7 @@ EXPECT_EQ(0x01010101u, writer_->final_bytes_of_last_packet()); connection_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT); SendStreamDataToPeer(3, "foo", 0, NO_FIN, nullptr); EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); @@ -4247,7 +4247,7 @@ // A TaggingEncrypter puts kTagSize copies of the given byte (0x01 here) at // the end of the packet. We can test this to check which encrypter was used. connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); // Attempt to send a handshake message and have the socket block. EXPECT_CALL(*send_algorithm_, CanSend(_)).WillRepeatedly(Return(true)); @@ -4258,7 +4258,7 @@ // Switch to the new encrypter. connection_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT); // Now become writeable and flush the packets. @@ -4275,7 +4275,7 @@ DropRetransmitsForNullEncryptedPacketAfterForwardSecure) { use_tagging_decrypter(); connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); QuicPacketNumber packet_number; connection_.SendCryptoStreamData(); @@ -4286,7 +4286,7 @@ // Go forward secure. connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); notifier_.NeuterUnencryptedData(); connection_.NeuterUnencryptedPackets(); @@ -4301,13 +4301,13 @@ TEST_P(QuicConnectionTest, RetransmitPacketsWithInitialEncryption) { use_tagging_decrypter(); connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); connection_.SendCryptoDataWithString("foo", 0); connection_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT); SendStreamDataToPeer(2, "bar", 0, NO_FIN, nullptr); @@ -4329,7 +4329,7 @@ const uint8_t tag = 0x07; peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process an encrypted packet which can not yet be decrypted which should // result in the packet being buffered. @@ -4338,10 +4338,10 @@ // Transition to the new encryption state and process another encrypted packet // which should result in the original packet being processed. SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); connection_.SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT); connection_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(2); ProcessDataPacketAtLevel(2, !kHasStopWaiting, ENCRYPTION_ZERO_RTT); @@ -4400,7 +4400,7 @@ const uint8_t tag = 0x07; peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process an encrypted packet which can not yet be decrypted which should // result in the packet being buffered. @@ -4412,11 +4412,11 @@ // which should result in the original packets being processed. EXPECT_FALSE(connection_.GetProcessUndecryptablePacketsAlarm()->IsSet()); SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); EXPECT_TRUE(connection_.GetProcessUndecryptablePacketsAlarm()->IsSet()); connection_.SetDefaultEncryptionLevel(ENCRYPTION_ZERO_RTT); connection_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(100); connection_.GetProcessUndecryptablePacketsAlarm()->Fire(); @@ -5676,9 +5676,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -5716,9 +5716,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -5796,9 +5796,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -5855,9 +5855,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -5992,9 +5992,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -6045,9 +6045,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -6103,9 +6103,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -6167,9 +6167,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -6251,9 +6251,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -6319,9 +6319,9 @@ EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); const uint8_t tag = 0x07; SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(tag)); + std::make_unique<StrictTaggingDecrypter>(tag)); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(tag)); + std::make_unique<TaggingEncrypter>(tag)); // Process a packet from the non-crypto stream. frame1_.stream_id = 3; @@ -6460,9 +6460,9 @@ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); EXPECT_CALL(visitor_, OnStreamFrame(_)); peer_framer_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); SetDecrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<StrictTaggingDecrypter>(0x01)); + std::make_unique<StrictTaggingDecrypter>(0x01)); ProcessDataPacket(1); connection_.SendStreamDataWithString( GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo", @@ -8409,7 +8409,7 @@ } use_tagging_decrypter(); connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); connection_.SendCryptoStreamData(); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); @@ -8447,7 +8447,7 @@ } use_tagging_decrypter(); connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x01)); + std::make_unique<TaggingEncrypter>(0x01)); connection_.SendCryptoStreamData(); EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); @@ -8488,11 +8488,11 @@ ProcessCryptoPacketAtLevel(1000, ENCRYPTION_INITIAL); EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(0x02)); + std::make_unique<StrictTaggingDecrypter>(0x02)); connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); // Receives packet 1000 in application data. ProcessDataPacketAtLevel(1000, false, ENCRYPTION_ZERO_RTT); EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); @@ -8508,7 +8508,7 @@ // Simulates ACK alarm fires and verify two ACKs are flushed. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); connection_.GetAckAlarm()->Fire(); EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); // Receives more packets in application data. @@ -8516,9 +8516,9 @@ EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); peer_framer_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); SetDecrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<StrictTaggingDecrypter>(0x02)); + std::make_unique<StrictTaggingDecrypter>(0x02)); // Verify zero rtt and forward secure packets get acked in the same packet. EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); ProcessDataPacket(1003); @@ -8539,11 +8539,11 @@ ProcessCryptoPacketAtLevel(1000, ENCRYPTION_INITIAL); EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); peer_framer_.SetEncrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); SetDecrypter(ENCRYPTION_ZERO_RTT, - QuicMakeUnique<StrictTaggingDecrypter>(0x02)); + std::make_unique<StrictTaggingDecrypter>(0x02)); connection_.SetEncrypter(ENCRYPTION_INITIAL, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); // Receives packet 1000 in application data. ProcessDataPacketAtLevel(1000, false, ENCRYPTION_ZERO_RTT); EXPECT_TRUE(connection_.GetAckAlarm()->IsSet()); @@ -8555,7 +8555,7 @@ clock_.AdvanceTime(DefaultDelayedAckTime()); EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, - QuicMakeUnique<TaggingEncrypter>(0x02)); + std::make_unique<TaggingEncrypter>(0x02)); connection_.GetAckAlarm()->Fire(); // Verify ACK alarm is not set. EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());