Commit bd9c35c6 authored by skyostil's avatar skyostil Committed by Commit bot

remoting: Use stl utilities from the base namespace

The utilities in base/stl_util.h have been moved from the global
into the base namespace. This patch updates the call sites accordingly.

No functional changes.

BUG=636301

Review-Url: https://codereview.chromium.org/2230193002
Cr-Commit-Position: refs/heads/master@{#411604}
parent 5ed1e83b
......@@ -47,7 +47,7 @@ std::unique_ptr<BufferedSocketWriter> BufferedSocketWriter::CreateForSocket(
BufferedSocketWriter::BufferedSocketWriter() : weak_factory_(this) {}
BufferedSocketWriter::~BufferedSocketWriter() {
STLDeleteElements(&queue_);
base::STLDeleteElements(&queue_);
}
void BufferedSocketWriter::Start(
......
......@@ -102,7 +102,8 @@ void JniDisplayHandler::SetCursorShape(
// the data out of the buffer without mutating it, and doesn't keep any
// reference to the buffer afterwards. Unfortunately, there seems to be no way
// to create a read-only ByteBuffer from a pointer-to-const.
char* data = string_as_array(const_cast<std::string*>(&cursor_shape.data()));
char* data =
base::string_as_array(const_cast<std::string*>(&cursor_shape.data()));
int cursor_total_bytes =
cursor_shape.width() * cursor_shape.height() * kBytesPerPixel;
......
......@@ -107,13 +107,13 @@ std::unique_ptr<AudioPacket> AudioDecoderOpus::Decode(
int buffer_pos = 0;
for (int i = 0; i < packet->data_size(); ++i) {
int16_t* pcm_buffer =
reinterpret_cast<int16_t*>(string_as_array(decoded_data) + buffer_pos);
int16_t* pcm_buffer = reinterpret_cast<int16_t*>(
base::string_as_array(decoded_data) + buffer_pos);
CHECK_LE(buffer_pos + max_frame_bytes,
static_cast<int>(decoded_data->size()));
std::string* frame = packet->mutable_data(i);
unsigned char* frame_data =
reinterpret_cast<unsigned char*>(string_as_array(frame));
reinterpret_cast<unsigned char*>(base::string_as_array(frame));
int result = opus_decode(decoder_, frame_data, frame->size(),
pcm_buffer, max_frame_samples, 0);
if (result < 0) {
......
......@@ -198,7 +198,7 @@ std::unique_ptr<AudioPacket> AudioEncoderOpus::Encode(
// Encode.
unsigned char* buffer =
reinterpret_cast<unsigned char*>(string_as_array(data));
reinterpret_cast<unsigned char*>(base::string_as_array(data));
int result = opus_encode(encoder_, pcm_buffer, kFrameSamples,
buffer, data->length());
if (result < 0) {
......
......@@ -19,7 +19,8 @@ namespace remoting {
static uint8_t* GetPacketOutputBuffer(VideoPacket* packet, size_t size) {
packet->mutable_data()->resize(size);
return reinterpret_cast<uint8_t*>(string_as_array(packet->mutable_data()));
return reinterpret_cast<uint8_t*>(
base::string_as_array(packet->mutable_data()));
}
VideoEncoderVerbatim::VideoEncoderVerbatim() {}
......
......@@ -277,7 +277,7 @@ It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
std::string message_json(length, '\0');
read_result = output_read_file_.ReadAtCurrentPos(
string_as_array(&message_json), length);
base::string_as_array(&message_json), length);
if (read_result != static_cast<int>(length)) {
LOG(ERROR) << "Message size (" << read_result
<< ") doesn't match the header (" << length << ").";
......
......@@ -161,8 +161,8 @@ void AudioPipeReader::DoCapture() {
data.resize(pos + bytes_to_read);
while (pos < data.size()) {
int read_result =
pipe_.ReadAtCurrentPos(string_as_array(&data) + pos, data.size() - pos);
int read_result = pipe_.ReadAtCurrentPos(base::string_as_array(&data) + pos,
data.size() - pos);
if (read_result > 0) {
pos += read_result;
} else {
......
......@@ -111,8 +111,8 @@ void NativeMessagingReader::Core::ReadMessage() {
}
std::string message_json(message_length, '\0');
read_result = read_stream_.ReadAtCurrentPos(string_as_array(&message_json),
message_length);
read_result = read_stream_.ReadAtCurrentPos(
base::string_as_array(&message_json), message_length);
if (read_result != static_cast<int>(message_length)) {
LOG(ERROR) << "Failed to read message body, read returned "
<< read_result;
......
......@@ -48,7 +48,7 @@ TEST_F(NativeMessagingWriterTest, GoodMessage) {
int read = read_file_.ReadAtCurrentPos(reinterpret_cast<char*>(&length), 4);
EXPECT_EQ(4, read);
std::string content(length, '\0');
read = read_file_.ReadAtCurrentPos(string_as_array(&content), length);
read = read_file_.ReadAtCurrentPos(base::string_as_array(&content), length);
EXPECT_EQ(static_cast<int>(length), read);
// |content| should now contain serialized |message|.
......@@ -80,7 +80,7 @@ TEST_F(NativeMessagingWriterTest, SecondMessage) {
read = read_file_.ReadAtCurrentPos(reinterpret_cast<char*>(&length), 4);
EXPECT_EQ(4, read) << "i = " << i;
content.resize(length);
read = read_file_.ReadAtCurrentPos(string_as_array(&content), length);
read = read_file_.ReadAtCurrentPos(base::string_as_array(&content), length);
EXPECT_EQ(static_cast<int>(length), read) << "i = " << i;
}
......
......@@ -86,8 +86,8 @@ void SecurityKeyMessageReader::ReadMessage() {
}
std::string message_data(total_message_size_bytes, '\0');
read_result = read_stream_.ReadAtCurrentPos(string_as_array(&message_data),
total_message_size_bytes);
read_result = read_stream_.ReadAtCurrentPos(
base::string_as_array(&message_data), total_message_size_bytes);
// The static cast is safe as we know the value is smaller than max int.
if (read_result != static_cast<int>(total_message_size_bytes)) {
LOG(ERROR) << "Failed to read message: " << read_result;
......
......@@ -77,7 +77,8 @@ void SecurityKeyMessageReaderImpl::ReadMessage() {
}
std::string message_data(message_length_bytes, '\0');
if (!ReadFromStream(string_as_array(&message_data), message_data.size())) {
if (!ReadFromStream(base::string_as_array(&message_data),
message_data.size())) {
NotifyError();
return;
}
......
......@@ -66,16 +66,16 @@ SecurityKeyMessageWriterImplTest::~SecurityKeyMessageWriterImplTest() {}
std::string SecurityKeyMessageWriterImplTest::ReadMessage(
int payload_length_bytes) {
std::string message_header(SecurityKeyMessage::kHeaderSizeBytes, '\0');
read_file_.ReadAtCurrentPos(string_as_array(&message_header),
read_file_.ReadAtCurrentPos(base::string_as_array(&message_header),
SecurityKeyMessage::kHeaderSizeBytes);
std::string message_type(SecurityKeyMessage::kMessageTypeSizeBytes, '\0');
read_file_.ReadAtCurrentPos(string_as_array(&message_type),
read_file_.ReadAtCurrentPos(base::string_as_array(&message_type),
SecurityKeyMessage::kMessageTypeSizeBytes);
std::string message_data(payload_length_bytes, '\0');
if (payload_length_bytes) {
read_file_.ReadAtCurrentPos(string_as_array(&message_data),
read_file_.ReadAtCurrentPos(base::string_as_array(&message_data),
payload_length_bytes);
}
......@@ -173,8 +173,8 @@ TEST_F(SecurityKeyMessageWriterImplTest, WriteMultipleMessages) {
// Retrieve and verify the message type.
std::string message_type(length, '\0');
int bytes_read =
read_file_.ReadAtCurrentPos(string_as_array(&message_type), length);
int bytes_read = read_file_.ReadAtCurrentPos(
base::string_as_array(&message_type), length);
ASSERT_EQ(length, bytes_read);
SecurityKeyMessageType type =
......
......@@ -418,7 +418,7 @@ Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
std::string message_json(length, '\0');
read_result = output_read_file_.ReadAtCurrentPos(
string_as_array(&message_json), length);
base::string_as_array(&message_json), length);
if (read_result != static_cast<int>(length)) {
return nullptr;
}
......
......@@ -63,7 +63,7 @@ MATCHER_P(EqualsPointerTouchInfoFlag, id_to_flag_map, "") {
for (size_t i = 0; i < id_to_flag_map.size(); ++i) {
const POINTER_TOUCH_INFO* touch_info = arg + i;
const uint32_t id = touch_info->pointerInfo.pointerId;
if (!ContainsKey(id_to_flag_map, id))
if (!base::ContainsKey(id_to_flag_map, id))
return false;
if (id_to_flag_map.find(id)->second != touch_info->pointerInfo.pointerFlags)
......
......@@ -145,7 +145,7 @@ ChannelMultiplexer::MuxChannel::MuxChannel(
ChannelMultiplexer::MuxChannel::~MuxChannel() {
// Socket must be destroyed before the channel.
DCHECK(!socket_);
STLDeleteElements(&pending_packets_);
base::STLDeleteElements(&pending_packets_);
}
std::unique_ptr<P2PStreamSocket>
......@@ -310,7 +310,7 @@ ChannelMultiplexer::ChannelMultiplexer(StreamChannelFactory* factory,
ChannelMultiplexer::~ChannelMultiplexer() {
DCHECK(pending_channels_.empty());
STLDeleteValues(&channels_);
base::STLDeleteValues(&channels_);
// Cancel creation of the base channel if it hasn't finished.
if (base_channel_factory_)
......
......@@ -72,10 +72,10 @@ JingleSession::JingleSession(JingleSessionManager* session_manager)
}
JingleSession::~JingleSession() {
STLDeleteContainerPointers(pending_requests_.begin(),
pending_requests_.end());
STLDeleteContainerPointers(transport_info_requests_.begin(),
transport_info_requests_.end());
base::STLDeleteContainerPointers(pending_requests_.begin(),
pending_requests_.end());
base::STLDeleteContainerPointers(transport_info_requests_.begin(),
transport_info_requests_.end());
session_manager_->SessionDestroyed(this);
}
......
......@@ -107,7 +107,7 @@ void SimulateReadSequence(const int read_sequence[], int sequence_size) {
EXPECT_EQ((index % 2) != 0, message->key_event().pressed());
++index;
}
STLDeleteElements(&message_list);
base::STLDeleteElements(&message_list);
}
TEST(MessageDecoderTest, SmallReads) {
......
......@@ -50,7 +50,7 @@ class MessageReaderTest : public testing::Test {
reader_.reset(new MessageReader());
}
void TearDown() override { STLDeleteElements(&messages_); }
void TearDown() override { base::STLDeleteElements(&messages_); }
void InitReader() {
reader_->StartReading(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment