LSC: Add std:: qualifications to all references to std::string and std::basic_string.
Adding these qualifications will make google3 C++ more portable, allow the global using std::string declarations in the google3 copy of the C++ standard library to be deleted, and bring google3 C++ in line with how the rest of the world uses C++. This completes the work started in go/lsc-add-std and go/std-type-qualification.
LSC documentation: go/lsc-std-string
Tested:
tap_presubmit: http://test/OCL:296219821:BASE:296205992:1582238469429:4f5b2b3
Some tests failed; test failures are believed to be unrelated to this CL
PiperOrigin-RevId: 296825017
Change-Id: I2b41071f7f9cc790308a6c95270659dcd57e3a27
diff --git a/quic/qbone/platform/ip_range.cc b/quic/qbone/platform/ip_range.cc
index 03ad640..04198d0 100644
--- a/quic/qbone/platform/ip_range.cc
+++ b/quic/qbone/platform/ip_range.cc
@@ -74,9 +74,9 @@
return !(*this == other);
}
-bool IpRange::FromString(const string& range) {
+bool IpRange::FromString(const std::string& range) {
size_t slash_pos = range.find('/');
- if (slash_pos == string::npos) {
+ if (slash_pos == std::string::npos) {
return false;
}
QuicIpAddress prefix;
diff --git a/quic/qbone/platform/ip_range.h b/quic/qbone/platform/ip_range.h
index cc84bb2..c9f1f34 100644
--- a/quic/qbone/platform/ip_range.h
+++ b/quic/qbone/platform/ip_range.h
@@ -24,10 +24,10 @@
// Parses range that looks like "10.0.0.1/8". Tailing bits will be set to zero
// after prefix_length. Return false if the parsing failed.
- bool FromString(const string& range);
+ bool FromString(const std::string& range);
// Returns the string representation of this object.
- string ToString() const {
+ std::string ToString() const {
if (IsInitialized()) {
return quiche::QuicheStrCat(prefix_.ToString(), "/", prefix_length_);
}
diff --git a/quic/qbone/platform/mock_netlink.h b/quic/qbone/platform/mock_netlink.h
index 5c1e7bc..e9f5d68 100644
--- a/quic/qbone/platform/mock_netlink.h
+++ b/quic/qbone/platform/mock_netlink.h
@@ -12,7 +12,7 @@
class MockNetlink : public NetlinkInterface {
public:
- MOCK_METHOD2(GetLinkInfo, bool(const string&, LinkInfo*));
+ MOCK_METHOD2(GetLinkInfo, bool(const std::string&, LinkInfo*));
MOCK_METHOD4(GetAddresses,
bool(int, uint8_t, std::vector<AddressInfo>*, int*));
diff --git a/quic/qbone/platform/netlink.cc b/quic/qbone/platform/netlink.cc
index 307d2bc..719551d 100644
--- a/quic/qbone/platform/netlink.cc
+++ b/quic/qbone/platform/netlink.cc
@@ -75,7 +75,7 @@
class LinkInfoParser : public NetlinkParserInterface {
public:
- LinkInfoParser(string interface_name, Netlink::LinkInfo* link_info)
+ LinkInfoParser(std::string interface_name, Netlink::LinkInfo* link_info)
: interface_name_(std::move(interface_name)), link_info_(link_info) {}
void Run(struct nlmsghdr* netlink_message) override {
@@ -101,7 +101,7 @@
size_t hardware_address_length = 0;
char broadcast_address[kHwAddrSize];
size_t broadcast_address_length = 0;
- string name;
+ std::string name;
// loop through the attributes
struct rtattr* rta;
@@ -131,8 +131,8 @@
break;
}
case IFLA_IFNAME: {
- name =
- string(reinterpret_cast<char*>(RTA_DATA(rta)), RTA_PAYLOAD(rta));
+ name = std::string(reinterpret_cast<char*>(RTA_DATA(rta)),
+ RTA_PAYLOAD(rta));
// The name maybe a 0 terminated c string.
name = name.substr(0, name.find('\0'));
break;
@@ -163,14 +163,15 @@
bool found_link() { return found_link_; }
private:
- const string interface_name_;
+ const std::string interface_name_;
Netlink::LinkInfo* const link_info_;
bool found_link_ = false;
};
} // namespace
-bool Netlink::GetLinkInfo(const string& interface_name, LinkInfo* link_info) {
+bool Netlink::GetLinkInfo(const std::string& interface_name,
+ LinkInfo* link_info) {
auto message = LinkMessage::New(RtnetlinkMessage::Operation::GET,
NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST,
seq_, getpid(), nullptr);
diff --git a/quic/qbone/platform/netlink.h b/quic/qbone/platform/netlink.h
index 591da0f..6c85658 100644
--- a/quic/qbone/platform/netlink.h
+++ b/quic/qbone/platform/netlink.h
@@ -38,7 +38,8 @@
//
// This is a synchronous communication. That should not be a problem since the
// kernel should answer immediately.
- bool GetLinkInfo(const string& interface_name, LinkInfo* link_info) override;
+ bool GetLinkInfo(const std::string& interface_name,
+ LinkInfo* link_info) override;
// Gets the addresses for the given interface referred by the given
// interface_index.
diff --git a/quic/qbone/platform/netlink_interface.h b/quic/qbone/platform/netlink_interface.h
index 447c8b2..1b1ba11 100644
--- a/quic/qbone/platform/netlink_interface.h
+++ b/quic/qbone/platform/netlink_interface.h
@@ -36,7 +36,7 @@
// Gets the link information for the interface referred by the given
// interface_name.
- virtual bool GetLinkInfo(const string& interface_name,
+ virtual bool GetLinkInfo(const std::string& interface_name,
LinkInfo* link_info) = 0;
// Address information reported back from GetAddresses.
diff --git a/quic/qbone/platform/netlink_test.cc b/quic/qbone/platform/netlink_test.cc
index d6a4adf..f8d0f19 100644
--- a/quic/qbone/platform/netlink_test.cc
+++ b/quic/qbone/platform/netlink_test.cc
@@ -57,10 +57,11 @@
EXPECT_GE(msg->msg_iovlen, 1);
EXPECT_GE(msg->msg_iov[0].iov_len, sizeof(struct nlmsghdr));
- string buf;
+ std::string buf;
for (int i = 0; i < msg->msg_iovlen; i++) {
- buf.append(string(reinterpret_cast<char*>(msg->msg_iov[i].iov_base),
- msg->msg_iov[i].iov_len));
+ buf.append(
+ std::string(reinterpret_cast<char*>(msg->msg_iov[i].iov_base),
+ msg->msg_iov[i].iov_len));
}
auto* netlink_message =
@@ -130,7 +131,7 @@
}
void CreateIfinfomsg(struct nlmsghdr* netlink_message,
- const string& interface_name,
+ const std::string& interface_name,
uint16_t type,
int index,
unsigned int flags,
diff --git a/quic/qbone/platform/rtnetlink_message_test.cc b/quic/qbone/platform/rtnetlink_message_test.cc
index b129237..64931c7 100644
--- a/quic/qbone/platform/rtnetlink_message_test.cc
+++ b/quic/qbone/platform/rtnetlink_message_test.cc
@@ -48,7 +48,7 @@
auto message = LinkMessage::New(RtnetlinkMessage::Operation::NEW, flags, seq,
pid, &interface_info_header);
- string device_name = "device0";
+ std::string device_name = "device0";
message.AppendAttribute(IFLA_IFNAME, device_name.c_str(), device_name.size());
// One rtattr appended.
@@ -81,8 +81,9 @@
auto* rta = reinterpret_cast<struct rtattr*>(iov[1].iov_base);
EXPECT_EQ(IFLA_IFNAME, rta->rta_type);
EXPECT_EQ(RTA_LENGTH(device_name.size()), rta->rta_len);
- EXPECT_THAT(device_name, StrEq(string(reinterpret_cast<char*>(RTA_DATA(rta)),
- RTA_PAYLOAD(rta))));
+ EXPECT_THAT(device_name,
+ StrEq(std::string(reinterpret_cast<char*>(RTA_DATA(rta)),
+ RTA_PAYLOAD(rta))));
}
TEST(RtnetlinkMessageTest, AddressMessageCanBeCreatedForGetOperation) {
@@ -158,9 +159,9 @@
auto* rta = reinterpret_cast<struct rtattr*>(iov[1].iov_base);
EXPECT_EQ(IFA_ADDRESS, rta->rta_type);
EXPECT_EQ(RTA_LENGTH(ip.ToPackedString().size()), rta->rta_len);
- EXPECT_THAT(
- ip.ToPackedString(),
- StrEq(string(reinterpret_cast<char*>(RTA_DATA(rta)), RTA_PAYLOAD(rta))));
+ EXPECT_THAT(ip.ToPackedString(),
+ StrEq(std::string(reinterpret_cast<char*>(RTA_DATA(rta)),
+ RTA_PAYLOAD(rta))));
}
TEST(RtnetlinkMessageTest, RouteMessageCanBeCreatedFromNewOperation) {
@@ -219,9 +220,9 @@
auto* rta = reinterpret_cast<struct rtattr*>(iov[1].iov_base);
EXPECT_EQ(RTA_PREFSRC, rta->rta_type);
EXPECT_EQ(RTA_LENGTH(preferred_source.ToPackedString().size()), rta->rta_len);
- EXPECT_THAT(
- preferred_source.ToPackedString(),
- StrEq(string(reinterpret_cast<char*>(RTA_DATA(rta)), RTA_PAYLOAD(rta))));
+ EXPECT_THAT(preferred_source.ToPackedString(),
+ StrEq(std::string(reinterpret_cast<char*>(RTA_DATA(rta)),
+ RTA_PAYLOAD(rta))));
}
} // namespace
diff --git a/quic/qbone/qbone_client_test.cc b/quic/qbone/qbone_client_test.cc
index e6cbd02..bdc86e7 100644
--- a/quic/qbone/qbone_client_test.cc
+++ b/quic/qbone/qbone_client_test.cc
@@ -32,11 +32,11 @@
namespace test {
namespace {
-string TestPacketIn(const string& body) {
+std::string TestPacketIn(const std::string& body) {
return PrependIPv6HeaderForTest(body, 5);
}
-string TestPacketOut(const string& body) {
+std::string TestPacketOut(const std::string& body) {
return PrependIPv6HeaderForTest(body, 4);
}
@@ -44,17 +44,17 @@
public:
void WritePacketToNetwork(const char* packet, size_t size) override {
QuicWriterMutexLock lock(&mu_);
- data_.push_back(string(packet, size));
+ data_.push_back(std::string(packet, size));
}
- std::vector<string> data() {
+ std::vector<std::string> data() {
QuicWriterMutexLock lock(&mu_);
return data_;
}
private:
QuicMutex mu_;
- std::vector<string> data_;
+ std::vector<std::string> data_;
};
// A subclass of a qbone session that will own the connection passed in.
@@ -153,7 +153,7 @@
&writer_);
}
- std::vector<string> data() { return writer_.data(); }
+ std::vector<std::string> data() { return writer_.data(); }
void WaitForDataSize(int n) {
while (data().size() != n) {
@@ -184,7 +184,7 @@
~QboneTestClient() override {}
- void SendData(const string& data) {
+ void SendData(const std::string& data) {
qbone_session()->ProcessPacketFromNetwork(data);
}
@@ -200,7 +200,7 @@
}
}
- std::vector<string> data() { return qbone_writer_.data(); }
+ std::vector<std::string> data() { return qbone_writer_.data(); }
private:
DataSavingQbonePacketWriter qbone_writer_;
@@ -234,8 +234,8 @@
->session_map()
.begin()
->second.get());
- string long_data(QboneConstants::kMaxQbonePacketBytes - sizeof(ip6_hdr) - 1,
- 'A');
+ std::string long_data(
+ QboneConstants::kMaxQbonePacketBytes - sizeof(ip6_hdr) - 1, 'A');
// Pretend the server gets data.
server_thread.Schedule([&server_session, &long_data]() {
server_session->ProcessPacketFromNetwork(
diff --git a/quic/qbone/qbone_control_stream.cc b/quic/qbone/qbone_control_stream.cc
index 225d02f..31a5070 100644
--- a/quic/qbone/qbone_control_stream.cc
+++ b/quic/qbone/qbone_control_stream.cc
@@ -38,7 +38,7 @@
if (buffer_.size() < pending_message_size_) {
return;
}
- string tmp = buffer_.substr(0, pending_message_size_);
+ std::string tmp = buffer_.substr(0, pending_message_size_);
buffer_.erase(0, pending_message_size_);
pending_message_size_ = 0;
OnMessage(tmp);
@@ -46,7 +46,7 @@
}
bool QboneControlStreamBase::SendMessage(const proto2::Message& proto) {
- string tmp;
+ std::string tmp;
if (!proto.SerializeToString(&tmp)) {
QUIC_BUG << "Failed to serialize QboneControlRequest";
return false;
diff --git a/quic/qbone/qbone_control_stream.h b/quic/qbone/qbone_control_stream.h
index 85f8dee..0f4127b 100644
--- a/quic/qbone/qbone_control_stream.h
+++ b/quic/qbone/qbone_control_stream.h
@@ -20,12 +20,12 @@
void OnDataAvailable() override;
protected:
- virtual void OnMessage(const string& data) = 0;
+ virtual void OnMessage(const std::string& data) = 0;
bool SendMessage(const proto2::Message& proto);
private:
uint16_t pending_message_size_;
- string buffer_;
+ std::string buffer_;
};
template <class T>
@@ -48,7 +48,7 @@
bool SendRequest(const Outgoing& request) { return SendMessage(request); }
protected:
- void OnMessage(const string& data) override {
+ void OnMessage(const std::string& data) override {
Incoming request;
if (!request.ParseFromString(data)) {
QUIC_LOG(ERROR) << "Failed to parse incoming request";
diff --git a/quic/qbone/qbone_packet_exchanger.cc b/quic/qbone/qbone_packet_exchanger.cc
index d06376d..ded41a2 100644
--- a/quic/qbone/qbone_packet_exchanger.cc
+++ b/quic/qbone/qbone_packet_exchanger.cc
@@ -11,7 +11,7 @@
bool QbonePacketExchanger::ReadAndDeliverPacket(
QboneClientInterface* qbone_client) {
bool blocked = false;
- string error;
+ std::string error;
std::unique_ptr<QuicData> packet = ReadPacket(&blocked, &error);
if (packet == nullptr) {
if (!blocked) {
@@ -26,7 +26,7 @@
void QbonePacketExchanger::WritePacketToNetwork(const char* packet,
size_t size) {
bool blocked = false;
- string error;
+ std::string error;
if (packet_queue_.empty() && !write_blocked_) {
if (WritePacket(packet, size, &blocked, &error)) {
return;
@@ -53,7 +53,7 @@
write_blocked_ = false;
while (!packet_queue_.empty()) {
bool blocked = false;
- string error;
+ std::string error;
if (WritePacket(packet_queue_.front()->data(),
packet_queue_.front()->length(), &blocked, &error)) {
packet_queue_.pop_front();
diff --git a/quic/qbone/qbone_packet_exchanger.h b/quic/qbone/qbone_packet_exchanger.h
index 8620a49..afdfc2e 100644
--- a/quic/qbone/qbone_packet_exchanger.h
+++ b/quic/qbone/qbone_packet_exchanger.h
@@ -19,8 +19,8 @@
class Visitor {
public:
virtual ~Visitor() {}
- virtual void OnReadError(const string& error) {}
- virtual void OnWriteError(const string& error) {}
+ virtual void OnReadError(const std::string& error) {}
+ virtual void OnWriteError(const std::string& error) {}
};
// Does not take ownership of visitor.
QbonePacketExchanger(Visitor* visitor, size_t max_pending_packets)
@@ -53,7 +53,7 @@
// there is no packet to read, b) the read failed. In the former case, blocked
// is set to true. error contains the error message.
virtual std::unique_ptr<QuicData> ReadPacket(bool* blocked,
- string* error) = 0;
+ std::string* error) = 0;
// The actual implementation that writes a packet to the local network.
// Returns true if the write succeeds. blocked will be set to true if the
@@ -62,7 +62,7 @@
virtual bool WritePacket(const char* packet,
size_t size,
bool* blocked,
- string* error) = 0;
+ std::string* error) = 0;
std::list<std::unique_ptr<QuicData>> packet_queue_;
diff --git a/quic/qbone/qbone_packet_exchanger_test.cc b/quic/qbone/qbone_packet_exchanger_test.cc
index f572177..1f38910 100644
--- a/quic/qbone/qbone_packet_exchanger_test.cc
+++ b/quic/qbone/qbone_packet_exchanger_test.cc
@@ -19,8 +19,8 @@
class MockVisitor : public QbonePacketExchanger::Visitor {
public:
- MOCK_METHOD1(OnReadError, void(const string&));
- MOCK_METHOD1(OnWriteError, void(const string&));
+ MOCK_METHOD1(OnReadError, void(const std::string&));
+ MOCK_METHOD1(OnWriteError, void(const std::string&));
};
class FakeQbonePacketExchanger : public QbonePacketExchanger {
@@ -37,23 +37,24 @@
// Sets the error to be returned by ReadPacket when the list of packets is
// empty. If error is empty string, blocked is set by ReadPacket.
- void SetReadError(const string& error) { read_error_ = error; }
+ void SetReadError(const std::string& error) { read_error_ = error; }
// Force WritePacket to fail with the given status. WritePacket returns true
// when blocked == true and error is empty.
- void ForceWriteFailure(bool blocked, const string& error) {
+ void ForceWriteFailure(bool blocked, const std::string& error) {
write_blocked_ = blocked;
write_error_ = error;
}
// Packets that have been successfully written by WritePacket.
- const std::vector<string>& packets_written() const {
+ const std::vector<std::string>& packets_written() const {
return packets_written_;
}
private:
// Implements QbonePacketExchanger::ReadPacket.
- std::unique_ptr<QuicData> ReadPacket(bool* blocked, string* error) override {
+ std::unique_ptr<QuicData> ReadPacket(bool* blocked,
+ std::string* error) override {
*blocked = false;
if (packets_to_be_read_.empty()) {
@@ -71,7 +72,7 @@
bool WritePacket(const char* packet,
size_t size,
bool* blocked,
- string* error) override {
+ std::string* error) override {
*blocked = false;
if (write_blocked_ || !write_error_.empty()) {
@@ -80,16 +81,16 @@
return false;
}
- packets_written_.push_back(string(packet, size));
+ packets_written_.push_back(std::string(packet, size));
return true;
}
- string read_error_;
+ std::string read_error_;
std::list<std::unique_ptr<QuicData>> packets_to_be_read_;
- string write_error_;
+ std::string write_error_;
bool write_blocked_ = false;
- std::vector<string> packets_written_;
+ std::vector<std::string> packets_written_;
};
TEST(QbonePacketExchangerTest,
@@ -98,7 +99,7 @@
FakeQbonePacketExchanger exchanger(&visitor, kMaxPendingPackets);
StrictMock<MockQboneClient> client;
- string packet = "data";
+ std::string packet = "data";
exchanger.AddPacketToBeRead(
std::make_unique<QuicData>(packet.data(), packet.length()));
EXPECT_CALL(client, ProcessPacketFromNetwork(StrEq("data")));
@@ -113,7 +114,7 @@
MockQboneClient client;
// Force read error.
- string io_error = "I/O error";
+ std::string io_error = "I/O error";
exchanger.SetReadError(io_error);
EXPECT_CALL(visitor, OnReadError(StrEq(io_error))).Times(1);
@@ -136,7 +137,7 @@
FakeQbonePacketExchanger exchanger(&visitor, kMaxPendingPackets);
MockQboneClient client;
- string packet = "data";
+ std::string packet = "data";
exchanger.WritePacketToNetwork(packet.data(), packet.length());
ASSERT_EQ(exchanger.packets_written().size(), 1);
@@ -151,7 +152,7 @@
// Force write to be blocked so that packets are queued.
exchanger.ForceWriteFailure(true, "");
- std::vector<string> packets = {"packet0", "packet1"};
+ std::vector<std::string> packets = {"packet0", "packet1"};
for (int i = 0; i < packets.size(); i++) {
exchanger.WritePacketToNetwork(packets[i].data(), packets[i].length());
}
@@ -178,7 +179,7 @@
// Force write to be blocked so that packets are queued.
exchanger.ForceWriteFailure(true, "");
- std::vector<string> packets = {"packet0", "packet1"};
+ std::vector<std::string> packets = {"packet0", "packet1"};
for (int i = 0; i < packets.size(); i++) {
exchanger.WritePacketToNetwork(packets[i].data(), packets[i].length());
}
@@ -202,7 +203,7 @@
}
TEST(QbonePacketExchangerTest, WritePacketToNetworkDropsPacketIfQueueIfFull) {
- std::vector<string> packets = {"packet0", "packet1", "packet2"};
+ std::vector<std::string> packets = {"packet0", "packet1", "packet2"};
size_t queue_size = packets.size() - 1;
MockVisitor visitor;
// exchanger has smaller queue than number of packets.
@@ -230,10 +231,10 @@
MockVisitor visitor;
FakeQbonePacketExchanger exchanger(&visitor, kMaxPendingPackets);
MockQboneClient client;
- string packet = "data";
+ std::string packet = "data";
// Write error is delivered to visitor during WritePacketToNetwork.
- string io_error = "I/O error";
+ std::string io_error = "I/O error";
exchanger.ForceWriteFailure(false, io_error);
EXPECT_CALL(visitor, OnWriteError(StrEq(io_error))).Times(1);
exchanger.WritePacketToNetwork(packet.data(), packet.length());
@@ -243,7 +244,7 @@
exchanger.ForceWriteFailure(true, "");
exchanger.WritePacketToNetwork(packet.data(), packet.length());
- string sys_error = "sys error";
+ std::string sys_error = "sys error";
exchanger.ForceWriteFailure(false, sys_error);
EXPECT_CALL(visitor, OnWriteError(StrEq(sys_error))).Times(1);
exchanger.SetWritable();
diff --git a/quic/qbone/qbone_packet_processor.cc b/quic/qbone/qbone_packet_processor.cc
index 9475e27..ef78efa 100644
--- a/quic/qbone/qbone_packet_processor.cc
+++ b/quic/qbone/qbone_packet_processor.cc
@@ -60,7 +60,8 @@
return ProcessingResult::OK;
}
-void QbonePacketProcessor::ProcessPacket(string* packet, Direction direction) {
+void QbonePacketProcessor::ProcessPacket(std::string* packet,
+ Direction direction) {
if (QUIC_PREDICT_FALSE(!IsValid())) {
QUIC_BUG << "QuicPacketProcessor is invoked in an invalid state.";
stats_->OnPacketDroppedSilently(direction);
@@ -106,7 +107,7 @@
}
QbonePacketProcessor::ProcessingResult
-QbonePacketProcessor::ProcessIPv6HeaderAndFilter(string* packet,
+QbonePacketProcessor::ProcessIPv6HeaderAndFilter(std::string* packet,
Direction direction,
uint8_t* transport_protocol,
char** transport_data,
@@ -154,7 +155,7 @@
}
QbonePacketProcessor::ProcessingResult QbonePacketProcessor::ProcessIPv6Header(
- string* packet,
+ std::string* packet,
Direction direction,
uint8_t* transport_protocol,
char** transport_data,
diff --git a/quic/qbone/qbone_packet_processor.h b/quic/qbone/qbone_packet_processor.h
index e163566..130770d 100644
--- a/quic/qbone/qbone_packet_processor.h
+++ b/quic/qbone/qbone_packet_processor.h
@@ -143,7 +143,7 @@
// Accepts an IPv6 packet and handles it accordingly by either forwarding it,
// replying with an ICMP packet or silently dropping it. |packet| will be
// modified in the process, by having the TTL field decreased.
- void ProcessPacket(string* packet, Direction direction);
+ void ProcessPacket(std::string* packet, Direction direction);
void set_filter(std::unique_ptr<Filter> filter) {
filter_ = std::move(filter);
@@ -160,7 +160,7 @@
// Processes the header and returns what should be done with the packet.
// After that, calls an external packet filter if registered. TTL of the
// packet may be decreased in the process.
- ProcessingResult ProcessIPv6HeaderAndFilter(string* packet,
+ ProcessingResult ProcessIPv6HeaderAndFilter(std::string* packet,
Direction direction,
uint8_t* transport_protocol,
char** transport_data,
@@ -188,7 +188,7 @@
private:
// Performs basic sanity and permission checks on the packet, and decreases
// the TTL.
- ProcessingResult ProcessIPv6Header(string* packet,
+ ProcessingResult ProcessIPv6Header(std::string* packet,
Direction direction,
uint8_t* transport_protocol,
char** transport_data,
diff --git a/quic/qbone/qbone_packet_processor_test.cc b/quic/qbone/qbone_packet_processor_test.cc
index 8258917..77fb5d5 100644
--- a/quic/qbone/qbone_packet_processor_test.cc
+++ b/quic/qbone/qbone_packet_processor_test.cc
@@ -146,12 +146,12 @@
}
void SendPacketFromClient(quiche::QuicheStringPiece packet) {
- string packet_buffer(packet.data(), packet.size());
+ std::string packet_buffer(packet.data(), packet.size());
processor_->ProcessPacket(&packet_buffer, Direction::FROM_OFF_NETWORK);
}
void SendPacketFromNetwork(quiche::QuicheStringPiece packet) {
- string packet_buffer(packet.data(), packet.size());
+ std::string packet_buffer(packet.data(), packet.size());
processor_->ProcessPacket(&packet_buffer, Direction::FROM_NETWORK);
}
@@ -174,14 +174,14 @@
TEST_F(QbonePacketProcessorTest, RandomGarbage) {
EXPECT_CALL(stats_, OnPacketDroppedSilently(Direction::FROM_OFF_NETWORK));
- SendPacketFromClient(string(1280, 'a'));
+ SendPacketFromClient(std::string(1280, 'a'));
EXPECT_CALL(stats_, OnPacketDroppedSilently(Direction::FROM_NETWORK));
- SendPacketFromNetwork(string(1280, 'a'));
+ SendPacketFromNetwork(std::string(1280, 'a'));
}
TEST_F(QbonePacketProcessorTest, RandomGarbageWithCorrectLengthFields) {
- string packet(40, 'a');
+ std::string packet(40, 'a');
packet[4] = 0;
packet[5] = 0;
@@ -215,7 +215,7 @@
}
TEST_F(QbonePacketProcessorTest, TtlExpired) {
- string packet(kReferenceNetworkPacket);
+ std::string packet(kReferenceNetworkPacket);
packet[7] = 1;
EXPECT_CALL(stats_, OnPacketDroppedWithIcmp(Direction::FROM_NETWORK));
@@ -224,7 +224,7 @@
}
TEST_F(QbonePacketProcessorTest, UnknownProtocol) {
- string packet(kReferenceNetworkPacket);
+ std::string packet(kReferenceNetworkPacket);
packet[6] = IPPROTO_SCTP;
EXPECT_CALL(stats_, OnPacketDroppedWithIcmp(Direction::FROM_NETWORK));
diff --git a/quic/qbone/qbone_packet_processor_test_tools.cc b/quic/qbone/qbone_packet_processor_test_tools.cc
index 9f9b623..97655e0 100644
--- a/quic/qbone/qbone_packet_processor_test_tools.cc
+++ b/quic/qbone/qbone_packet_processor_test_tools.cc
@@ -8,7 +8,7 @@
namespace quic {
-string PrependIPv6HeaderForTest(const string& body, int hops) {
+std::string PrependIPv6HeaderForTest(const std::string& body, int hops) {
ip6_hdr header;
memset(&header, 0, sizeof(header));
@@ -19,7 +19,7 @@
header.ip6_src = in6addr_loopback;
header.ip6_dst = in6addr_loopback;
- string packet(sizeof(header) + body.size(), '\0');
+ std::string packet(sizeof(header) + body.size(), '\0');
memcpy(&packet[0], &header, sizeof(header));
memcpy(&packet[sizeof(header)], body.data(), body.size());
return packet;
diff --git a/quic/qbone/qbone_packet_processor_test_tools.h b/quic/qbone/qbone_packet_processor_test_tools.h
index 78dd92d..809b542 100644
--- a/quic/qbone/qbone_packet_processor_test_tools.h
+++ b/quic/qbone/qbone_packet_processor_test_tools.h
@@ -31,7 +31,7 @@
MOCK_METHOD1(OnPacketDeferred, void(QbonePacketProcessor::Direction));
};
-string PrependIPv6HeaderForTest(const string& body, int hops);
+std::string PrependIPv6HeaderForTest(const std::string& body, int hops);
} // namespace quic
diff --git a/quic/qbone/qbone_server_session.cc b/quic/qbone/qbone_server_session.cc
index 53511ad..6561f57 100644
--- a/quic/qbone/qbone_server_session.cc
+++ b/quic/qbone/qbone_server_session.cc
@@ -19,7 +19,7 @@
const QuicSocketAddress& client_address,
const QuicSocketAddress& peer_address,
const QuicSocketAddress& self_address,
- string* error_details) const {
+ std::string* error_details) const {
quiche::QuicheStringPiece alpn;
chlo.GetStringPiece(quic::kALPN, &alpn);
if (alpn != QboneConstants::kQboneAlpn) {
@@ -74,14 +74,14 @@
void QboneServerSession::ProcessPacketFromNetwork(
quiche::QuicheStringPiece packet) {
- string buffer = string(packet);
+ std::string buffer = std::string(packet);
processor_.ProcessPacket(&buffer,
QbonePacketProcessor::Direction::FROM_NETWORK);
}
void QboneServerSession::ProcessPacketFromPeer(
quiche::QuicheStringPiece packet) {
- string buffer = string(packet);
+ std::string buffer = std::string(packet);
processor_.ProcessPacket(&buffer,
QbonePacketProcessor::Direction::FROM_OFF_NETWORK);
}
diff --git a/quic/qbone/qbone_server_session.h b/quic/qbone/qbone_server_session.h
index d6ef596..e4ff4dd 100644
--- a/quic/qbone/qbone_server_session.h
+++ b/quic/qbone/qbone_server_session.h
@@ -26,7 +26,7 @@
const QuicSocketAddress& client_address,
const QuicSocketAddress& peer_address,
const QuicSocketAddress& self_address,
- string* error_details) const override;
+ std::string* error_details) const override;
};
class QUIC_EXPORT_PRIVATE QboneServerSession
diff --git a/quic/qbone/qbone_session_test.cc b/quic/qbone/qbone_session_test.cc
index 05a0d72..1c85c0b 100644
--- a/quic/qbone/qbone_session_test.cc
+++ b/quic/qbone/qbone_session_test.cc
@@ -36,11 +36,11 @@
using ::testing::NiceMock;
using ::testing::Not;
-string TestPacketIn(const string& body) {
+std::string TestPacketIn(const std::string& body) {
return PrependIPv6HeaderForTest(body, 5);
}
-string TestPacketOut(const string& body) {
+std::string TestPacketOut(const std::string& body) {
return PrependIPv6HeaderForTest(body, 4);
}
@@ -52,8 +52,8 @@
// ProofSource override.
void GetProof(const QuicSocketAddress& server_address,
- const string& hostname,
- const string& server_config,
+ const std::string& hostname,
+ const std::string& server_config,
QuicTransportVersion transport_version,
quiche::QuicheStringPiece chlo_hash,
std::unique_ptr<Callback> callback) override {
@@ -69,11 +69,11 @@
QuicReferenceCountedPointer<Chain> GetCertChain(
const QuicSocketAddress& server_address,
- const string& hostname) override {
+ const std::string& hostname) override {
if (!success_) {
return QuicReferenceCountedPointer<Chain>();
}
- std::vector<string> certs;
+ std::vector<std::string> certs;
certs.push_back("Required to establish handshake");
return QuicReferenceCountedPointer<ProofSource::Chain>(
new ProofSource::Chain(certs));
@@ -81,7 +81,7 @@
void ComputeTlsSignature(
const QuicSocketAddress& server_address,
- const string& hostname,
+ const std::string& hostname,
uint16_t signature_algorithm,
quiche::QuicheStringPiece in,
std::unique_ptr<SignatureCallback> callback) override {
@@ -101,28 +101,28 @@
// ProofVerifier override
QuicAsyncStatus VerifyProof(
- const string& hostname,
+ const std::string& hostname,
const uint16_t port,
- const string& server_config,
+ const std::string& server_config,
QuicTransportVersion transport_version,
quiche::QuicheStringPiece chlo_hash,
- const std::vector<string>& certs,
- const string& cert_sct,
- const string& signature,
+ const std::vector<std::string>& certs,
+ const std::string& cert_sct,
+ const std::string& signature,
const ProofVerifyContext* context,
- string* error_details,
+ std::string* error_details,
std::unique_ptr<ProofVerifyDetails>* verify_details,
std::unique_ptr<ProofVerifierCallback> callback) override {
return success_ ? QUIC_SUCCESS : QUIC_FAILURE;
}
QuicAsyncStatus VerifyCertChain(
- const string& hostname,
- const std::vector<string>& certs,
+ const std::string& hostname,
+ const std::vector<std::string>& certs,
const std::string& ocsp_response,
const std::string& cert_sct,
const ProofVerifyContext* context,
- string* error_details,
+ std::string* error_details,
std::unique_ptr<ProofVerifyDetails>* details,
std::unique_ptr<ProofVerifierCallback> callback) override {
return success_ ? QUIC_SUCCESS : QUIC_FAILURE;
@@ -140,13 +140,13 @@
class DataSavingQbonePacketWriter : public QbonePacketWriter {
public:
void WritePacketToNetwork(const char* packet, size_t size) override {
- data_.push_back(string(packet, size));
+ data_.push_back(std::string(packet, size));
}
- const std::vector<string>& data() { return data_; }
+ const std::vector<std::string>& data() { return data_; }
private:
- std::vector<string> data_;
+ std::vector<std::string> data_;
};
template <class T>
@@ -355,18 +355,18 @@
runner_.Run();
}
- void ExpectICMPTooBigResponse(const std::vector<string>& written_packets,
+ void ExpectICMPTooBigResponse(const std::vector<std::string>& written_packets,
const int mtu,
- const string& packet) {
+ const std::string& packet) {
auto* header = reinterpret_cast<const ip6_hdr*>(packet.data());
icmp6_hdr icmp_header{};
icmp_header.icmp6_type = ICMP6_PACKET_TOO_BIG;
icmp_header.icmp6_mtu = mtu;
- string expected;
+ std::string expected;
CreateIcmpPacket(header->ip6_dst, header->ip6_src, icmp_header, packet,
[&expected](quiche::QuicheStringPiece icmp_packet) {
- expected = string(icmp_packet);
+ expected = std::string(icmp_packet);
});
EXPECT_THAT(written_packets, Contains(expected));
@@ -409,8 +409,8 @@
// Try to send long payloads that are larger than the QUIC MTU but
// smaller than the QBONE max size.
// This should trigger the non-ephemeral stream code path.
- string long_data(QboneConstants::kMaxQbonePacketBytes - sizeof(ip6_hdr) - 1,
- 'A');
+ std::string long_data(
+ QboneConstants::kMaxQbonePacketBytes - sizeof(ip6_hdr) - 1, 'A');
QUIC_LOG(INFO) << "Sending server -> client long data";
server_peer_->ProcessPacketFromNetwork(TestPacketIn(long_data));
runner_.Run();
diff --git a/quic/qbone/qbone_stream.h b/quic/qbone/qbone_stream.h
index 6a86e4d..c2fb20a 100644
--- a/quic/qbone/qbone_stream.h
+++ b/quic/qbone/qbone_stream.h
@@ -47,7 +47,7 @@
void OnDataAvailable() override;
private:
- string buffer_;
+ std::string buffer_;
QboneSessionBase* session_;
};
diff --git a/quic/qbone/qbone_stream_test.cc b/quic/qbone/qbone_stream_test.cc
index dcd80bd..06dbd34 100644
--- a/quic/qbone/qbone_stream_test.cc
+++ b/quic/qbone/qbone_stream_test.cc
@@ -180,7 +180,7 @@
// Read an entire string.
TEST_F(QboneReadOnlyStreamTest, ReadDataWhole) {
- string packet = "Stuff";
+ std::string packet = "Stuff";
CreateReliableQuicStream();
QuicStreamFrame frame(kStreamId, true, 0, packet);
EXPECT_CALL(*session_, ProcessPacketFromPeer("Stuff"));
@@ -190,7 +190,7 @@
// Test buffering.
TEST_F(QboneReadOnlyStreamTest, ReadBuffered) {
CreateReliableQuicStream();
- string packet = "Stuf";
+ std::string packet = "Stuf";
{
QuicStreamFrame frame(kStreamId, false, 0, packet);
stream_->OnStreamFrame(frame);
@@ -207,7 +207,7 @@
TEST_F(QboneReadOnlyStreamTest, ReadOutOfOrder) {
CreateReliableQuicStream();
- string packet = "f";
+ std::string packet = "f";
{
QuicStreamFrame frame(kStreamId, true, 4, packet);
stream_->OnStreamFrame(frame);
@@ -230,7 +230,7 @@
// Test buffering too many bytes.
TEST_F(QboneReadOnlyStreamTest, ReadBufferedTooLarge) {
CreateReliableQuicStream();
- string packet = "0123456789";
+ std::string packet = "0123456789";
int iterations = (QboneConstants::kMaxQbonePacketBytes / packet.size()) + 2;
EXPECT_CALL(*session_,
SendRstStream(kStreamId, QUIC_BAD_APPLICATION_PAYLOAD, _));