Skip to content

Commit

Permalink
Replace base::MakeUnique with std::make_unique in ipc/.
Browse files Browse the repository at this point in the history
base/memory/ptr_util.h includes will be cleaned up later.

Bug: 755727
Change-Id: I0fb685d0ae0f6b7c6ad026eadafb5028e5dd130c
Reviewed-on: https://chromium-review.googlesource.com/641635
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#498159}
  • Loading branch information
jeremyroman authored and Commit Bot committed Aug 29, 2017
1 parent 51e89c2 commit 160eb92
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ipc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ to binder function:

``` cpp
void BindFrobinator(mojom::FrobinatorRequest request) {
mojo::MakeStrongBinding(base::MakeUnique<FrobinatorImpl>, std::move(request));
mojo::MakeStrongBinding(std::make_unique<FrobinatorImpl>, std::move(request));
}

// |registry| will hereby handle all incoming requests for "mojom::Frobinator"
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_channel_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ std::unique_ptr<ChannelFactory> ChannelFactory::Create(
const ChannelHandle& handle,
Channel::Mode mode,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
return base::MakeUnique<PlatformChannelFactory>(handle, mode,
return std::make_unique<PlatformChannelFactory>(handle, mode,
ipc_task_runner);
}

Expand Down
11 changes: 6 additions & 5 deletions ipc/ipc_channel_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ std::unique_ptr<ChannelMojo> ChannelMojo::Create(
std::unique_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
mojo::ScopedMessagePipeHandle handle,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
return base::MakeUnique<MojoChannelFactory>(
return std::make_unique<MojoChannelFactory>(
std::move(handle), Channel::MODE_SERVER, ipc_task_runner);
}

// static
std::unique_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
mojo::ScopedMessagePipeHandle handle,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
return base::MakeUnique<MojoChannelFactory>(
return std::make_unique<MojoChannelFactory>(
std::move(handle), Channel::MODE_CLIENT, ipc_task_runner);
}

Expand Down Expand Up @@ -424,9 +424,10 @@ ChannelMojo::GetAssociatedInterfaceSupport() { return this; }

std::unique_ptr<mojo::ThreadSafeForwarder<mojom::Channel>>
ChannelMojo::CreateThreadSafeChannel() {
return base::MakeUnique<mojo::ThreadSafeForwarder<mojom::Channel>>(
task_runner_, base::Bind(&ChannelMojo::ForwardMessageFromThreadSafePtr,
weak_factory_.GetWeakPtr()),
return std::make_unique<mojo::ThreadSafeForwarder<mojom::Channel>>(
task_runner_,
base::Bind(&ChannelMojo::ForwardMessageFromThreadSafePtr,
weak_factory_.GetWeakPtr()),
base::Bind(&ChannelMojo::ForwardMessageWithResponderFromThreadSafePtr,
weak_factory_.GetWeakPtr()),
*bootstrap_->GetAssociatedGroup());
Expand Down
4 changes: 2 additions & 2 deletions ipc/ipc_channel_nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void ChannelNacl::DidRecvMsg(std::unique_ptr<MessageContents> contents) {
if (pipe_ == -1)
return;

auto data = base::MakeUnique<std::vector<char>>();
auto data = std::make_unique<std::vector<char>>();
data->swap(contents->data);
read_queue_.push_back(std::move(data));

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::MakeUnique<ChannelNacl>(channel_handle, mode, listener);
return std::make_unique<ChannelNacl>(channel_handle, mode, listener);
}

} // namespace IPC
8 changes: 4 additions & 4 deletions ipc/ipc_message_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST(IPCMessageTest, ListValue) {
base::ListValue input;
input.AppendDouble(42.42);
input.AppendString("forty");
input.Append(base::MakeUnique<base::Value>());
input.Append(std::make_unique<base::Value>());

IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
IPC::WriteParam(&msg, input);
Expand All @@ -89,16 +89,16 @@ TEST(IPCMessageTest, ListValue) {

TEST(IPCMessageTest, DictionaryValue) {
base::DictionaryValue input;
input.Set("null", base::MakeUnique<base::Value>());
input.Set("null", std::make_unique<base::Value>());
input.SetBoolean("bool", true);
input.SetInteger("int", 42);
input.SetKey("int.with.dot", base::Value(43));

auto subdict = base::MakeUnique<base::DictionaryValue>();
auto subdict = std::make_unique<base::DictionaryValue>();
subdict->SetString("str", "forty two");
subdict->SetBoolean("bool", false);

auto sublist = base::MakeUnique<base::ListValue>();
auto sublist = std::make_unique<base::ListValue>();
sublist->AppendDouble(42.42);
sublist->AppendString("forty");
sublist->AppendString("two");
Expand Down
14 changes: 7 additions & 7 deletions ipc/ipc_message_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,34 +266,34 @@ bool ReadValue(const base::Pickle* m,

switch (static_cast<base::Value::Type>(type)) {
case base::Value::Type::NONE:
*value = base::MakeUnique<base::Value>();
*value = std::make_unique<base::Value>();
break;
case base::Value::Type::BOOLEAN: {
bool val;
if (!ReadParam(m, iter, &val))
return false;
*value = base::MakeUnique<base::Value>(val);
*value = std::make_unique<base::Value>(val);
break;
}
case base::Value::Type::INTEGER: {
int val;
if (!ReadParam(m, iter, &val))
return false;
*value = base::MakeUnique<base::Value>(val);
*value = std::make_unique<base::Value>(val);
break;
}
case base::Value::Type::DOUBLE: {
double val;
if (!ReadParam(m, iter, &val))
return false;
*value = base::MakeUnique<base::Value>(val);
*value = std::make_unique<base::Value>(val);
break;
}
case base::Value::Type::STRING: {
std::string val;
if (!ReadParam(m, iter, &val))
return false;
*value = base::MakeUnique<base::Value>(std::move(val));
*value = std::make_unique<base::Value>(std::move(val));
break;
}
case base::Value::Type::BINARY: {
Expand All @@ -308,14 +308,14 @@ bool ReadValue(const base::Pickle* m,
base::DictionaryValue val;
if (!ReadDictionaryValue(m, iter, &val, recursion))
return false;
*value = base::MakeUnique<base::Value>(std::move(val));
*value = std::make_unique<base::Value>(std::move(val));
break;
}
case base::Value::Type::LIST: {
base::ListValue val;
if (!ReadListValue(m, iter, &val, recursion))
return false;
*value = base::MakeUnique<base::Value>(std::move(val));
*value = std::make_unique<base::Value>(std::move(val));
break;
}
default:
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_message_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TEST(IPCMessageUtilsTest, ValueSize) {
value->SetKey("foo", base::Value(42));
value->SetKey("bar", base::Value(3.14));
value->SetKey("baz", base::Value("hello"));
value->SetWithoutPathExpansion("qux", base::MakeUnique<base::Value>());
value->SetWithoutPathExpansion("qux", std::make_unique<base::Value>());

std::unique_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue);
nested_dict->SetKey("foobar", base::Value(5));
Expand Down
6 changes: 3 additions & 3 deletions ipc/ipc_mojo_bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@ class ChannelAssociatedGroupController
{
base::AutoLock locker(controller_->lock_);
if (!sync_message_event_) {
sync_message_event_ = base::MakeUnique<base::WaitableEvent>(
sync_message_event_ = std::make_unique<base::WaitableEvent>(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
if (peer_closed_ || !sync_messages_.empty())
SignalSyncMessageEvent();
}
}

sync_watcher_ = base::MakeUnique<mojo::SyncEventWatcher>(
sync_watcher_ = std::make_unique<mojo::SyncEventWatcher>(
sync_message_event_.get(),
base::Bind(&Endpoint::OnSyncMessageEventReady,
base::Unretained(this)));
Expand Down Expand Up @@ -928,7 +928,7 @@ std::unique_ptr<MojoBootstrap> MojoBootstrap::Create(
mojo::ScopedMessagePipeHandle handle,
Channel::Mode mode,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
return base::MakeUnique<MojoBootstrapImpl>(
return std::make_unique<MojoBootstrapImpl>(
std::move(handle), new ChannelAssociatedGroupController(
mode == Channel::MODE_SERVER, ipc_task_runner));
}
Expand Down
4 changes: 2 additions & 2 deletions ipc/ipc_sync_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class SyncChannel::ReceivedSyncMsgQueue :
dispatch_event_(base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED),
listener_task_runner_(base::ThreadTaskRunnerHandle::Get()),
sync_dispatch_watcher_(base::MakeUnique<mojo::SyncEventWatcher>(
sync_dispatch_watcher_(std::make_unique<mojo::SyncEventWatcher>(
&dispatch_event_,
base::Bind(&ReceivedSyncMsgQueue::OnDispatchEventReady,
base::Unretained(this)))) {
Expand Down Expand Up @@ -635,7 +635,7 @@ void SyncChannel::WaitForReply(mojo::SyncHandleRegistry* registry,
base::WaitableEvent* pump_messages_event = nullptr;
if (pump_messages) {
if (!g_pump_messages_event.Get()) {
g_pump_messages_event.Get() = base::MakeUnique<base::WaitableEvent>(
g_pump_messages_event.Get() = std::make_unique<base::WaitableEvent>(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::SIGNALED);
}
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ IPCChannelMojoTestBase::~IPCChannelMojoTestBase() = default;

void IPCChannelMojoTestBase::Init(const std::string& test_client_name) {
InitWithCustomMessageLoop(test_client_name,
base::MakeUnique<base::MessageLoop>());
std::make_unique<base::MessageLoop>());
}

void IPCChannelMojoTestBase::InitWithCustomMessageLoop(
Expand Down

0 comments on commit 160eb92

Please sign in to comment.