Skip to content

Commit

Permalink
ipc: Use std::unique_ptr instead of linked_ptr
Browse files Browse the repository at this point in the history
BUG=556939

Review-Url: https://codereview.chromium.org/2687323002
Cr-Commit-Position: refs/heads/master@{#450069}
  • Loading branch information
digit authored and Commit bot committed Feb 13, 2017
1 parent f14c6d2 commit ad900d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions ipc/ipc_channel_nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>(message_ptr.release()));
output_queue_.push_back(std::move(message_ptr));
if (!waiting_connect_)
return ProcessOutgoingMessages();

Expand All @@ -220,9 +220,9 @@ void ChannelNacl::DidRecvMsg(std::unique_ptr<MessageContents> contents) {
if (pipe_ == -1)
return;

linked_ptr<std::vector<char> > data(new std::vector<char>);
auto data = base::MakeUnique<std::vector<char>>();
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) {
Expand Down Expand Up @@ -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<Message> msg = output_queue_.front();
std::unique_ptr<Message> msg = std::move(output_queue_.front());
output_queue_.pop_front();

const size_t num_fds = msg->attachment_set()->size();
Expand Down Expand Up @@ -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<std::vector<char> > vec(read_queue_.front());
std::vector<char>* 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.
Expand Down Expand Up @@ -386,7 +386,7 @@ std::unique_ptr<Channel> Channel::Create(
const IPC::ChannelHandle& channel_handle,
Mode mode,
Listener* listener) {
return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener));
return base::MakeUnique<ChannelNacl>(channel_handle, mode, listener);
}

} // namespace IPC
5 changes: 2 additions & 3 deletions ipc/ipc_channel_nacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <string>

#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"
Expand Down Expand Up @@ -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<linked_ptr<std::vector<char> > > read_queue_;
std::deque<std::unique_ptr<std::vector<char>>> read_queue_;
// Queue of file descriptor attachments extracted from imc_recvmsg messages.
std::vector<scoped_refptr<MessageAttachment>> 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<linked_ptr<Message> > output_queue_;
std::deque<std::unique_ptr<Message>> output_queue_;

base::WeakPtrFactory<ChannelNacl> weak_ptr_factory_;

Expand Down

0 comments on commit ad900d3

Please sign in to comment.