Replace QuicString with std::string, pass 1
This replaces QuicString with std::string in all of the "QUIC proper". I will
delete QuicString once all code using it is gone.
gfe-relnote: n/a (no functional change)
PiperOrigin-RevId: 237872023
Change-Id: I82de62c9855516b15039734d05155917e68ff4ee
diff --git a/quic/quartc/counting_packet_filter.h b/quic/quartc/counting_packet_filter.h
index 0f67008..9df006c 100644
--- a/quic/quartc/counting_packet_filter.h
+++ b/quic/quartc/counting_packet_filter.h
@@ -17,7 +17,7 @@
class CountingPacketFilter : public simulator::PacketFilter {
public:
CountingPacketFilter(simulator::Simulator* simulator,
- const QuicString& name,
+ const std::string& name,
simulator::Endpoint* endpoint)
: PacketFilter(simulator, name, endpoint) {}
diff --git a/quic/quartc/quartc_crypto_helpers.cc b/quic/quartc/quartc_crypto_helpers.cc
index 865fec4..93023e7 100644
--- a/quic/quartc/quartc_crypto_helpers.cc
+++ b/quic/quartc/quartc_crypto_helpers.cc
@@ -10,8 +10,8 @@
namespace quic {
void DummyProofSource::GetProof(const QuicSocketAddress& server_address,
- const QuicString& hostname,
- const QuicString& server_config,
+ const std::string& hostname,
+ const std::string& server_config,
QuicTransportVersion transport_version,
QuicStringPiece chlo_hash,
std::unique_ptr<Callback> callback) {
@@ -25,8 +25,8 @@
QuicReferenceCountedPointer<DummyProofSource::Chain>
DummyProofSource::GetCertChain(const QuicSocketAddress& server_address,
- const QuicString& hostname) {
- std::vector<QuicString> certs;
+ const std::string& hostname) {
+ std::vector<std::string> certs;
certs.push_back(kDummyCertName);
return QuicReferenceCountedPointer<ProofSource::Chain>(
new ProofSource::Chain(certs));
@@ -34,7 +34,7 @@
void DummyProofSource::ComputeTlsSignature(
const QuicSocketAddress& server_address,
- const QuicString& hostname,
+ const std::string& hostname,
uint16_t signature_algorithm,
QuicStringPiece in,
std::unique_ptr<SignatureCallback> callback) {
@@ -42,26 +42,26 @@
}
QuicAsyncStatus InsecureProofVerifier::VerifyProof(
- const QuicString& hostname,
+ const std::string& hostname,
const uint16_t port,
- const QuicString& server_config,
+ const std::string& server_config,
QuicTransportVersion transport_version,
QuicStringPiece chlo_hash,
- const std::vector<QuicString>& certs,
- const QuicString& cert_sct,
- const QuicString& signature,
+ const std::vector<std::string>& certs,
+ const std::string& cert_sct,
+ const std::string& signature,
const ProofVerifyContext* context,
- QuicString* error_details,
+ std::string* error_details,
std::unique_ptr<ProofVerifyDetails>* verify_details,
std::unique_ptr<ProofVerifierCallback> callback) {
return QUIC_SUCCESS;
}
QuicAsyncStatus InsecureProofVerifier::VerifyCertChain(
- const QuicString& hostname,
- const std::vector<QuicString>& certs,
+ const std::string& hostname,
+ const std::vector<std::string>& certs,
const ProofVerifyContext* context,
- QuicString* error_details,
+ std::string* error_details,
std::unique_ptr<ProofVerifyDetails>* details,
std::unique_ptr<ProofVerifierCallback> callback) {
return QUIC_SUCCESS;
@@ -86,7 +86,7 @@
const QuicSocketAddress& client_address,
const QuicSocketAddress& peer_address,
const QuicSocketAddress& self_address,
- QuicString* error_details) const {
+ std::string* error_details) const {
return true;
}
@@ -114,7 +114,7 @@
char source_address_token_secret[kInputKeyingMaterialLength];
random->RandBytes(source_address_token_secret, kInputKeyingMaterialLength);
auto config = QuicMakeUnique<QuicCryptoServerConfig>(
- QuicString(source_address_token_secret, kInputKeyingMaterialLength),
+ std::string(source_address_token_secret, kInputKeyingMaterialLength),
random, QuicMakeUnique<DummyProofSource>(), KeyExchangeSource::Default(),
TlsServerHandshaker::CreateSslCtx());
@@ -155,7 +155,7 @@
const QuicData& data = message->GetSerialized();
crypto_server_config.serialized_crypto_config =
- QuicString(data.data(), data.length());
+ std::string(data.data(), data.length());
return crypto_server_config;
}
diff --git a/quic/quartc/quartc_crypto_helpers.h b/quic/quartc/quartc_crypto_helpers.h
index 2b280b5..c53a58e 100644
--- a/quic/quartc/quartc_crypto_helpers.h
+++ b/quic/quartc/quartc_crypto_helpers.h
@@ -26,7 +26,7 @@
struct CryptoServerConfig {
std::unique_ptr<QuicCryptoServerConfig> config;
- QuicString serialized_crypto_config;
+ std::string serialized_crypto_config;
};
// Length of HKDF input keying material, equal to its number of bytes.
@@ -43,19 +43,19 @@
// ProofSource overrides.
void GetProof(const QuicSocketAddress& server_address,
- const QuicString& hostname,
- const QuicString& server_config,
+ const std::string& hostname,
+ const std::string& server_config,
QuicTransportVersion transport_version,
QuicStringPiece chlo_hash,
std::unique_ptr<Callback> callback) override;
QuicReferenceCountedPointer<Chain> GetCertChain(
const QuicSocketAddress& server_address,
- const QuicString& hostname) override;
+ const std::string& hostname) override;
void ComputeTlsSignature(
const QuicSocketAddress& server_address,
- const QuicString& hostname,
+ const std::string& hostname,
uint16_t signature_algorithm,
QuicStringPiece in,
std::unique_ptr<SignatureCallback> callback) override;
@@ -71,24 +71,24 @@
// ProofVerifier overrides.
QuicAsyncStatus VerifyProof(
- const QuicString& hostname,
+ const std::string& hostname,
const uint16_t port,
- const QuicString& server_config,
+ const std::string& server_config,
QuicTransportVersion transport_version,
QuicStringPiece chlo_hash,
- const std::vector<QuicString>& certs,
- const QuicString& cert_sct,
- const QuicString& signature,
+ const std::vector<std::string>& certs,
+ const std::string& cert_sct,
+ const std::string& signature,
const ProofVerifyContext* context,
- QuicString* error_details,
+ std::string* error_details,
std::unique_ptr<ProofVerifyDetails>* verify_details,
std::unique_ptr<ProofVerifierCallback> callback) override;
QuicAsyncStatus VerifyCertChain(
- const QuicString& hostname,
- const std::vector<QuicString>& certs,
+ const std::string& hostname,
+ const std::vector<std::string>& certs,
const ProofVerifyContext* context,
- QuicString* error_details,
+ std::string* error_details,
std::unique_ptr<ProofVerifyDetails>* details,
std::unique_ptr<ProofVerifierCallback> callback) override;
@@ -106,7 +106,7 @@
const QuicSocketAddress& client_address,
const QuicSocketAddress& peer_address,
const QuicSocketAddress& self_address,
- QuicString* error_details) const override;
+ std::string* error_details) const override;
};
std::unique_ptr<QuicCryptoClientConfig> CreateCryptoClientConfig(
diff --git a/quic/quartc/quartc_dispatcher.h b/quic/quartc/quartc_dispatcher.h
index e660107..26b52ac 100644
--- a/quic/quartc/quartc_dispatcher.h
+++ b/quic/quartc/quartc_dispatcher.h
@@ -57,7 +57,7 @@
// Members owned by QuartcDispatcher but not QuicDispatcher.
std::unique_ptr<QuicConfig> owned_quic_config_;
std::unique_ptr<QuicCryptoServerConfig> owned_crypto_config_;
- QuicString crypto_config_;
+ std::string crypto_config_;
// Delegate invoked when the dispatcher creates a new session.
Delegate* delegate_;
diff --git a/quic/quartc/quartc_endpoint.h b/quic/quartc/quartc_endpoint.h
index ee856ea..abf056a 100644
--- a/quic/quartc/quartc_endpoint.h
+++ b/quic/quartc/quartc_endpoint.h
@@ -43,7 +43,7 @@
// Called if the endpoint fails to establish a session after a call to
// Connect. (The most likely cause is a network idle timeout.)
virtual void OnConnectError(QuicErrorCode error,
- const QuicString& error_details) = 0;
+ const std::string& error_details) = 0;
};
virtual ~QuartcEndpoint() = default;
@@ -97,7 +97,7 @@
QuartcEndpoint::Delegate* delegate_;
// Server config. If valid, used to perform a 0-RTT connection.
- const QuicString serialized_server_config_;
+ const std::string serialized_server_config_;
// Version manager. May be injected to control version negotiation in tests.
std::unique_ptr<QuicVersionManager> version_manager_;
diff --git a/quic/quartc/quartc_factory.h b/quic/quartc/quartc_factory.h
index 5496387..d568f52 100644
--- a/quic/quartc/quartc_factory.h
+++ b/quic/quartc/quartc_factory.h
@@ -28,7 +28,7 @@
struct QuartcSessionConfig {
// If a pre-shared cryptographic key is available for this session, specify it
// here. This value will only be used if non-empty.
- QuicString pre_shared_key;
+ std::string pre_shared_key;
// The maximum size of the packet can be written with the packet writer.
// 1200 bytes by default.
diff --git a/quic/quartc/quartc_fakes.h b/quic/quartc/quartc_fakes.h
index 16ff9c7..1719065 100644
--- a/quic/quartc/quartc_fakes.h
+++ b/quic/quartc/quartc_fakes.h
@@ -29,7 +29,7 @@
}
void OnConnectError(QuicErrorCode error,
- const QuicString& error_details) override {
+ const std::string& error_details) override {
LOG(FATAL) << "Unexpected error during QuartcEndpoint::Connect(); error="
<< error << ", error_details=" << error_details;
}
@@ -62,7 +62,7 @@
// Called when connection closes locally, or remotely by peer.
void OnConnectionClosed(QuicErrorCode error_code,
- const QuicString& error_details,
+ const std::string& error_details,
ConnectionCloseSource source) override {
connected_ = false;
}
@@ -84,7 +84,7 @@
QuartcStream* last_incoming_stream() { return last_incoming_stream_; }
// Returns all received messages.
- const std::vector<QuicString>& incoming_messages() {
+ const std::vector<std::string>& incoming_messages() {
return incoming_messages_;
}
@@ -94,7 +94,7 @@
private:
QuartcStream* last_incoming_stream_;
- std::vector<QuicString> incoming_messages_;
+ std::vector<std::string> incoming_messages_;
bool connected_ = true;
QuartcStream::Delegate* stream_delegate_;
QuicTime writable_time_ = QuicTime::Zero();
@@ -110,8 +110,8 @@
bool fin) override {
size_t bytes_consumed = 0;
for (size_t i = 0; i < iov_length; ++i) {
- received_data_[stream->id()] +=
- QuicString(static_cast<const char*>(iov[i].iov_base), iov[i].iov_len);
+ received_data_[stream->id()] += std::string(
+ static_cast<const char*>(iov[i].iov_base), iov[i].iov_len);
bytes_consumed += iov[i].iov_len;
}
return bytes_consumed;
@@ -124,12 +124,12 @@
void OnBufferChanged(QuartcStream* stream) override {}
bool has_data() { return !received_data_.empty(); }
- std::map<QuicStreamId, QuicString> data() { return received_data_; }
+ std::map<QuicStreamId, std::string> data() { return received_data_; }
QuicRstStreamErrorCode stream_error(QuicStreamId id) { return errors_[id]; }
private:
- std::map<QuicStreamId, QuicString> received_data_;
+ std::map<QuicStreamId, std::string> received_data_;
std::map<QuicStreamId, QuicRstStreamErrorCode> errors_;
};
diff --git a/quic/quartc/quartc_session.cc b/quic/quartc/quartc_session.cc
index 8fa8e96..e5b6952 100644
--- a/quic/quartc/quartc_session.cc
+++ b/quic/quartc/quartc_session.cc
@@ -41,7 +41,7 @@
GetNextOutgoingBidirectionalStreamId(), QuicStream::kDefaultPriority));
}
-bool QuartcSession::SendOrQueueMessage(QuicString message) {
+bool QuartcSession::SendOrQueueMessage(std::string message) {
if (!CanSendMessage()) {
QUIC_LOG(ERROR) << "Quic session does not support SendMessage";
return false;
@@ -182,14 +182,14 @@
}
void QuartcSession::OnConnectionClosed(QuicErrorCode error,
- const QuicString& error_details,
+ const std::string& error_details,
ConnectionCloseSource source) {
QuicSession::OnConnectionClosed(error, error_details, source);
DCHECK(session_delegate_);
session_delegate_->OnConnectionClosed(error, error_details, source);
}
-void QuartcSession::CloseConnection(const QuicString& details) {
+void QuartcSession::CloseConnection(const std::string& details) {
connection_->CloseConnection(
QuicErrorCode::QUIC_CONNECTION_CANCELLED, details,
ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK);
@@ -324,7 +324,7 @@
if (!server_config_.empty()) {
QuicCryptoServerConfig::ConfigOptions options;
- QuicString error;
+ std::string error;
QuicWallTime now = clock()->WallNow();
QuicCryptoClientConfig::CachedState::ServerConfigState result =
client_crypto_config_->LookupOrCreate(server_id)->SetServerConfig(
@@ -334,7 +334,7 @@
if (result == QuicCryptoClientConfig::CachedState::SERVER_CONFIG_VALID) {
DCHECK_EQ(error, "");
client_crypto_config_->LookupOrCreate(server_id)->SetProof(
- std::vector<QuicString>{kDummyCertName}, /*cert_sct=*/"",
+ std::vector<std::string>{kDummyCertName}, /*cert_sct=*/"",
/*chlo_hash=*/"", /*signature=*/"anything");
} else {
LOG(DFATAL) << "Unable to set server config, error=" << error;
diff --git a/quic/quartc/quartc_session.h b/quic/quartc/quartc_session.h
index 7efa186..35df8b6 100644
--- a/quic/quartc/quartc_session.h
+++ b/quic/quartc/quartc_session.h
@@ -48,7 +48,7 @@
// support SendMessage API. Other unexpected errors during send will not be
// returned, because messages can be sent later if connection is congestion
// controlled.
- bool SendOrQueueMessage(QuicString message);
+ bool SendOrQueueMessage(std::string message);
// Returns largest message payload acceptable in SendQuartcMessage.
QuicPacketLength GetLargestMessagePayload() const {
@@ -69,7 +69,7 @@
void OnCanWrite() override;
void OnConnectionClosed(QuicErrorCode error,
- const QuicString& error_details,
+ const std::string& error_details,
ConnectionCloseSource source) override;
// QuartcSession methods.
@@ -84,7 +84,7 @@
//
// Cleans up the underlying QuicConnection's state. Closing the connection
// makes it safe to delete the QuartcSession.
- void CloseConnection(const QuicString& details);
+ void CloseConnection(const std::string& details);
// If the given stream is still open, sends a reset frame to cancel it.
// Note: This method cancels a stream by QuicStreamId rather than by pointer
@@ -122,7 +122,7 @@
// Called when the connection is closed. This means all of the streams will
// be closed and no new streams can be created.
virtual void OnConnectionClosed(QuicErrorCode error_code,
- const QuicString& error_details,
+ const std::string& error_details,
ConnectionCloseSource source) = 0;
// Called when message (sent as SendMessage) is received.
@@ -189,7 +189,7 @@
// Queue of pending messages sent by SendQuartcMessage that were not sent
// yet or blocked by congestion control. Messages are queued in the order
// of sent by SendOrQueueMessage().
- QuicDeque<QuicString> send_message_queue_;
+ QuicDeque<std::string> send_message_queue_;
};
class QuartcClientSession : public QuartcSession,
@@ -242,7 +242,7 @@
// Client perspective crypto stream.
std::unique_ptr<QuicCryptoClientStream> crypto_stream_;
- const QuicString server_config_;
+ const std::string server_config_;
};
class QuartcServerSession : public QuartcSession {
diff --git a/quic/quartc/quartc_session_test.cc b/quic/quartc/quartc_session_test.cc
index fad4a8f..fc80c8b 100644
--- a/quic/quartc/quartc_session_test.cc
+++ b/quic/quartc/quartc_session_test.cc
@@ -208,7 +208,7 @@
// Send messages from peer 1 to peer 2 until required number of messages
// are queued in unsent message queue.
- std::vector<QuicString> sent_messages;
+ std::vector<std::string> sent_messages;
while (peer_sending->send_message_queue_size() < queue_size) {
sent_messages.push_back(
QuicStrCat("Sending message, index=", sent_messages.size()));
@@ -229,13 +229,13 @@
ASSERT_TRUE(client_peer_->CanSendMessage());
// Send message of maximum allowed length.
- QuicString message_max_long =
- QuicString(server_peer_->GetLargestMessagePayload(), 'A');
+ std::string message_max_long =
+ std::string(server_peer_->GetLargestMessagePayload(), 'A');
ASSERT_TRUE(server_peer_->SendOrQueueMessage(message_max_long));
// Send long message which should fail.
- QuicString message_too_long =
- QuicString(server_peer_->GetLargestMessagePayload() + 1, 'B');
+ std::string message_too_long =
+ std::string(server_peer_->GetLargestMessagePayload() + 1, 'B');
ASSERT_FALSE(server_peer_->SendOrQueueMessage(message_too_long));
// Wait for peer 2 to receive message.
diff --git a/quic/quartc/quartc_stream_test.cc b/quic/quartc/quartc_stream_test.cc
index edb0ee0..6fa1076 100644
--- a/quic/quartc/quartc_stream_test.cc
+++ b/quic/quartc/quartc_stream_test.cc
@@ -53,7 +53,7 @@
public:
MockQuicSession(QuicConnection* connection,
const QuicConfig& config,
- QuicString* write_buffer)
+ std::string* write_buffer)
: QuicSession(connection,
nullptr /*visitor*/,
config,
@@ -121,7 +121,7 @@
private:
// Stores written data from ReliableQuicStreamAdapter.
- QuicString* write_buffer_;
+ std::string* write_buffer_;
// Whether data is written to write_buffer_.
bool writable_ = true;
};
@@ -164,7 +164,7 @@
class MockQuartcStreamDelegate : public QuartcStream::Delegate {
public:
- MockQuartcStreamDelegate(QuicStreamId id, QuicString* read_buffer)
+ MockQuartcStreamDelegate(QuicStreamId id, std::string* read_buffer)
: id_(id), read_buffer_(read_buffer) {}
void OnBufferChanged(QuartcStream* stream) override {
@@ -199,7 +199,7 @@
protected:
QuicStreamId id_;
// Data read by the QuicStream.
- QuicString* read_buffer_;
+ std::string* read_buffer_;
// Whether the QuicStream is closed.
bool closed_ = false;
@@ -258,9 +258,9 @@
std::unique_ptr<MockQuartcStreamDelegate> mock_stream_delegate_;
std::unique_ptr<MockQuicSession> session_;
// Data written by the ReliableQuicStreamAdapterTest.
- QuicString write_buffer_;
+ std::string write_buffer_;
// Data read by the ReliableQuicStreamAdapterTest.
- QuicString read_buffer_;
+ std::string read_buffer_;
std::unique_ptr<QuicAlarmFactory> alarm_factory_;
std::unique_ptr<QuicConnection> connection_;
// Used to implement the QuicConnectionHelperInterface.
diff --git a/quic/quartc/simulated_packet_transport.cc b/quic/quartc/simulated_packet_transport.cc
index 5c0d374..8e82d98 100644
--- a/quic/quartc/simulated_packet_transport.cc
+++ b/quic/quartc/simulated_packet_transport.cc
@@ -10,8 +10,8 @@
SimulatedQuartcPacketTransport::SimulatedQuartcPacketTransport(
Simulator* simulator,
- const QuicString& name,
- const QuicString& peer_name,
+ const std::string& name,
+ const std::string& peer_name,
QuicByteCount queue_capacity)
: Endpoint(simulator, name),
peer_name_(peer_name),
@@ -34,7 +34,7 @@
last_packet_number_ = info.packet_number;
auto packet = QuicMakeUnique<Packet>();
- packet->contents = QuicString(buffer, buf_len);
+ packet->contents = std::string(buffer, buf_len);
packet->size = buf_len;
packet->tx_timestamp = clock_->Now();
packet->source = name();
diff --git a/quic/quartc/simulated_packet_transport.h b/quic/quartc/simulated_packet_transport.h
index 1b190a0..5216bbb 100644
--- a/quic/quartc/simulated_packet_transport.h
+++ b/quic/quartc/simulated_packet_transport.h
@@ -23,8 +23,8 @@
public Queue::ListenerInterface {
public:
SimulatedQuartcPacketTransport(Simulator* simulator,
- const QuicString& name,
- const QuicString& peer_name,
+ const std::string& name,
+ const std::string& peer_name,
QuicByteCount queue_capacity);
// QuartcPacketTransport methods.
@@ -67,7 +67,7 @@
QuicPacketNumber last_packet_number() { return last_packet_number_; }
private:
- QuicString peer_name_;
+ std::string peer_name_;
Delegate* delegate_ = nullptr;
Queue egress_queue_;
QuicPacketNumber last_packet_number_;
diff --git a/quic/quartc/simulated_packet_transport_test.cc b/quic/quartc/simulated_packet_transport_test.cc
index 3fbd18b..cae966f 100644
--- a/quic/quartc/simulated_packet_transport_test.cc
+++ b/quic/quartc/simulated_packet_transport_test.cc
@@ -36,7 +36,7 @@
void OnTransportCanWrite() override {
while (!packets_to_send_.empty()) {
- const QuicString& packet = packets_to_send_.front();
+ const std::string& packet = packets_to_send_.front();
if (transport_->Write(packet.data(), packet.size(),
QuartcPacketTransport::PacketInfo()) <
static_cast<int>(packet.size())) {
@@ -51,20 +51,20 @@
packets_received_.emplace_back(data, data_len);
}
- void AddPacketToSend(const QuicString& packet) {
+ void AddPacketToSend(const std::string& packet) {
packets_to_send_.push(packet);
}
size_t packets_to_send() { return packets_to_send_.size(); }
- const std::vector<QuicString>& packets_received() {
+ const std::vector<std::string>& packets_received() {
return packets_received_;
}
int write_blocked_count() { return write_blocked_count_; }
private:
QuartcPacketTransport* const transport_ = nullptr;
- std::queue<QuicString> packets_to_send_;
- std::vector<QuicString> packets_received_;
+ std::queue<std::string> packets_to_send_;
+ std::vector<std::string> packets_received_;
int write_blocked_count_ = 0;
};
@@ -105,8 +105,8 @@
};
TEST_F(SimulatedPacketTransportTest, OneWayTransmission) {
- QuicString packet_1(kDefaultPacketSize, 'a');
- QuicString packet_2(kDefaultPacketSize, 'b');
+ std::string packet_1(kDefaultPacketSize, 'a');
+ std::string packet_2(kDefaultPacketSize, 'b');
client_delegate_.AddPacketToSend(packet_1);
client_delegate_.AddPacketToSend(packet_2);
@@ -120,10 +120,10 @@
}
TEST_F(SimulatedPacketTransportTest, TwoWayTransmission) {
- QuicString packet_1(kDefaultPacketSize, 'a');
- QuicString packet_2(kDefaultPacketSize, 'b');
- QuicString packet_3(kDefaultPacketSize, 'c');
- QuicString packet_4(kDefaultPacketSize, 'd');
+ std::string packet_1(kDefaultPacketSize, 'a');
+ std::string packet_2(kDefaultPacketSize, 'b');
+ std::string packet_3(kDefaultPacketSize, 'c');
+ std::string packet_4(kDefaultPacketSize, 'd');
client_delegate_.AddPacketToSend(packet_1);
client_delegate_.AddPacketToSend(packet_2);
@@ -144,9 +144,9 @@
TEST_F(SimulatedPacketTransportTest, TestWriteBlocked) {
// Add 10 packets beyond what fits in the egress queue.
- std::vector<QuicString> packets;
+ std::vector<std::string> packets;
for (unsigned int i = 0; i < kDefaultQueueLength + 10; ++i) {
- packets.push_back(QuicString(kDefaultPacketSize, 'a' + i));
+ packets.push_back(std::string(kDefaultPacketSize, 'a' + i));
client_delegate_.AddPacketToSend(packets.back());
}