From ad900d319365284907e63f8a416030e362012c55 Mon Sep 17 00:00:00 2001 From: digit Date: Mon, 13 Feb 2017 12:41:07 -0800 Subject: [PATCH] ipc: Use std::unique_ptr instead of linked_ptr BUG=556939 Review-Url: https://codereview.chromium.org/2687323002 Cr-Commit-Position: refs/heads/master@{#450069} --- ipc/ipc_channel_nacl.cc | 12 ++++++------ ipc/ipc_channel_nacl.h | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ipc/ipc_channel_nacl.cc b/ipc/ipc_channel_nacl.cc index 1fa8e691459097..17b680ed37afcd 100644 --- a/ipc/ipc_channel_nacl.cc +++ b/ipc/ipc_channel_nacl.cc @@ -207,7 +207,7 @@ bool ChannelNacl::Send(Message* message) { "ChannelNacl::Send", message->header()->flags, TRACE_EVENT_FLAG_FLOW_OUT); - output_queue_.push_back(linked_ptr(message_ptr.release())); + output_queue_.push_back(std::move(message_ptr)); if (!waiting_connect_) return ProcessOutgoingMessages(); @@ -220,9 +220,9 @@ void ChannelNacl::DidRecvMsg(std::unique_ptr contents) { if (pipe_ == -1) return; - linked_ptr > data(new std::vector); + auto data = base::MakeUnique>(); data->swap(contents->data); - read_queue_.push_back(data); + read_queue_.push_back(std::move(data)); input_attachments_.reserve(contents->fds.size()); for (int fd : contents->fds) { @@ -273,7 +273,7 @@ bool ChannelNacl::ProcessOutgoingMessages() { // Write out all the messages. The trusted implementation is guaranteed to not // block. See NaClIPCAdapter::Send for the implementation of imc_sendmsg. while (!output_queue_.empty()) { - linked_ptr msg = output_queue_.front(); + std::unique_ptr msg = std::move(output_queue_.front()); output_queue_.pop_front(); const size_t num_fds = msg->attachment_set()->size(); @@ -330,7 +330,7 @@ ChannelNacl::ReadState ChannelNacl::ReadData( if (read_queue_.empty()) return READ_PENDING; while (!read_queue_.empty() && *bytes_read < buffer_len) { - linked_ptr > vec(read_queue_.front()); + std::vector* vec = read_queue_.front().get(); size_t bytes_to_read = buffer_len - *bytes_read; if (vec->size() <= bytes_to_read) { // We can read and discard the entire vector. @@ -386,7 +386,7 @@ std::unique_ptr Channel::Create( const IPC::ChannelHandle& channel_handle, Mode mode, Listener* listener) { - return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener)); + return base::MakeUnique(channel_handle, mode, listener); } } // namespace IPC diff --git a/ipc/ipc_channel_nacl.h b/ipc/ipc_channel_nacl.h index 1860922c5cc650..e989f128559d25 100644 --- a/ipc/ipc_channel_nacl.h +++ b/ipc/ipc_channel_nacl.h @@ -10,7 +10,6 @@ #include #include "base/macros.h" -#include "base/memory/linked_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process/process.h" #include "base/threading/simple_thread.h" @@ -97,13 +96,13 @@ class ChannelNacl : public Channel, // the trouble given that we probably want to implement 1 and // 2 above in NaCl eventually. // When ReadData is called, it pulls the bytes out of this queue in order. - std::deque > > read_queue_; + std::deque>> read_queue_; // Queue of file descriptor attachments extracted from imc_recvmsg messages. std::vector> input_attachments_; // This queue is used when a message is sent prior to Connect having been // called. Normally after we're connected, the queue is empty. - std::deque > output_queue_; + std::deque> output_queue_; base::WeakPtrFactory weak_ptr_factory_;