Convert scoped_ptr to std::unique_ptr in //ipc.
TBR=brettw, jam, [email protected]
BUG=554298
Review URL: https://codereview.chromium.org/1913363002
Cr-Commit-Position: refs/heads/master@{#389361}
diff --git a/ipc/attachment_broker_mac_unittest.cc b/ipc/attachment_broker_mac_unittest.cc
index 61d41d7..d30e8a7 100644
--- a/ipc/attachment_broker_mac_unittest.cc
+++ b/ipc/attachment_broker_mac_unittest.cc
@@ -9,6 +9,7 @@
#include <stddef.h>
#include <sys/mman.h>
+#include <memory>
#include <tuple>
#include "base/command_line.h"
@@ -18,7 +19,6 @@
#include "base/mac/mac_util.h"
#include "base/mac/mach_logging.h"
#include "base/memory/free_deleter.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/spin_wait.h"
@@ -86,13 +86,14 @@
}
// Makes a Mach port backed SharedMemory region and fills it with |contents|.
-scoped_ptr<base::SharedMemory> MakeSharedMemory(const std::string& contents) {
+std::unique_ptr<base::SharedMemory> MakeSharedMemory(
+ const std::string& contents) {
base::SharedMemoryHandle shm(contents.size());
if (!shm.IsValid()) {
LOG(ERROR) << "Failed to make SharedMemoryHandle.";
return nullptr;
}
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(shm, false));
shared_memory->Map(contents.size());
memcpy(shared_memory->memory(), contents.c_str(), contents.size());
@@ -141,7 +142,7 @@
}
// Returns |nullptr| on error.
-scoped_ptr<base::SharedMemory> MapSharedMemoryHandle(
+std::unique_ptr<base::SharedMemory> MapSharedMemoryHandle(
const base::SharedMemoryHandle& shm,
bool read_only) {
if (!shm.IsValid()) {
@@ -155,7 +156,7 @@
return nullptr;
}
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(shm, read_only));
shared_memory->Map(size);
return shared_memory;
@@ -165,7 +166,7 @@
// consumes a reference to the underlying Mach port.
bool CheckContentsOfSharedMemoryHandle(const base::SharedMemoryHandle& shm,
const std::string& contents) {
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MapSharedMemoryHandle(shm, false));
if (memcmp(shared_memory->memory(), contents.c_str(), contents.size()) != 0) {
@@ -181,7 +182,7 @@
const std::string& contents) {
base::ScopedFD fd_closer(file_descriptor.fd);
lseek(file_descriptor.fd, 0, SEEK_SET);
- scoped_ptr<char, base::FreeDeleter> buffer(
+ std::unique_ptr<char, base::FreeDeleter> buffer(
static_cast<char*>(malloc(contents.size())));
if (!base::ReadFromFD(file_descriptor.fd, buffer.get(), contents.size()))
return false;
@@ -221,9 +222,9 @@
const base::SharedMemoryHandle& handle1,
const base::SharedMemoryHandle& handle2,
const std::string& contents) {
- scoped_ptr<base::SharedMemory> shared_memory1(
+ std::unique_ptr<base::SharedMemory> shared_memory1(
MapSharedMemoryHandle(handle1, false));
- scoped_ptr<base::SharedMemory> shared_memory2(
+ std::unique_ptr<base::SharedMemory> shared_memory2(
MapSharedMemoryHandle(handle2, false));
if (memcmp(shared_memory1->memory(), contents.c_str(), contents.size()) !=
@@ -469,7 +470,8 @@
// Makes a SharedMemory region, fills it with |contents|, sends the handle
// over Chrome IPC, and unmaps the region.
void SendMessage1(const std::string& contents) {
- scoped_ptr<base::SharedMemory> shared_memory(MakeSharedMemory(contents));
+ std::unique_ptr<base::SharedMemory> shared_memory(
+ MakeSharedMemory(contents));
IPC::Message* message =
new TestSharedMemoryHandleMsg1(100, shared_memory->handle(), 200);
sender()->Send(message);
@@ -486,7 +488,7 @@
private:
ProxyListener proxy_listener_;
- scoped_ptr<IPC::AttachmentBrokerUnprivilegedMac> broker_;
+ std::unique_ptr<IPC::AttachmentBrokerUnprivilegedMac> broker_;
AttachmentBrokerObserver observer_;
// A port on which the main process listens for mach messages from the child
@@ -511,7 +513,7 @@
// gets a chance to unregister itself as an observer. This doesn't matter
// outside of tests, since neither port_provider nor broker will ever be
// destroyed.
- scoped_ptr<IPC::AttachmentBrokerPrivilegedMac> broker;
+ std::unique_ptr<IPC::AttachmentBrokerPrivilegedMac> broker;
base::mac::ScopedMachSendRight server_task_port;
// Total resident memory before running the message loop.
@@ -527,7 +529,7 @@
// Sets up the Mach communication ports with the server. Returns a set of
// globals that must live at least as long as the test.
-scoped_ptr<ChildProcessGlobals> CommonChildProcessSetUp() {
+std::unique_ptr<ChildProcessGlobals> CommonChildProcessSetUp() {
base::CommandLine cmd_line = *base::CommandLine::ForCurrentProcess();
std::string service_name =
cmd_line.GetSwitchValueASCII(g_service_switch_name);
@@ -543,7 +545,7 @@
base::mac::ScopedMachSendRight server_task_port(
IPC::ReceiveMachPort(client_port.get()));
- scoped_ptr<ChildProcessGlobals> globals(new ChildProcessGlobals);
+ std::unique_ptr<ChildProcessGlobals> globals(new ChildProcessGlobals);
globals->broker.reset(
new IPC::AttachmentBrokerPrivilegedMac(&globals->port_provider));
globals->port_provider.InsertEntry(getppid(), server_task_port.get());
@@ -555,14 +557,14 @@
int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback,
const char* channel_name) {
LOG(INFO) << "Privileged process start.";
- scoped_ptr<ChildProcessGlobals> globals(CommonChildProcessSetUp());
+ std::unique_ptr<ChildProcessGlobals> globals(CommonChildProcessSetUp());
mach_msg_type_number_t active_names_at_start = IPC::GetActiveNameCount();
base::MessageLoopForIO main_message_loop;
ProxyListener listener;
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName(channel_name), &listener));
globals->broker->RegisterCommunicationChannel(channel.get(), nullptr);
CHECK(channel->Connect());
@@ -679,7 +681,7 @@
CommonSetUp("SendTwoMessagesSameSharedMemoryHandle");
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
for (int i = 0; i < 2; ++i) {
@@ -725,9 +727,9 @@
CommonSetUp("SendOneMessageWithTwoDifferentSharedMemoryHandles");
{
- scoped_ptr<base::SharedMemory> shared_memory1(
+ std::unique_ptr<base::SharedMemory> shared_memory1(
MakeSharedMemory(kDataBuffer1));
- scoped_ptr<base::SharedMemory> shared_memory2(
+ std::unique_ptr<base::SharedMemory> shared_memory2(
MakeSharedMemory(kDataBuffer2));
IPC::Message* message = new TestSharedMemoryHandleMsg2(
shared_memory1->handle(), shared_memory2->handle());
@@ -768,7 +770,7 @@
CommonSetUp("SendOneMessageWithTwoSameSharedMemoryHandles");
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
IPC::Message* message = new TestSharedMemoryHandleMsg2(
shared_memory->handle(), shared_memory->handle());
@@ -813,9 +815,9 @@
CommonSetUp("SendPosixFDAndMachPort");
{
- scoped_ptr<base::SharedMemory> shared_memory1(
+ std::unique_ptr<base::SharedMemory> shared_memory1(
MakeSharedMemory(kDataBuffer1));
- scoped_ptr<base::SharedMemory> shared_memory2(
+ std::unique_ptr<base::SharedMemory> shared_memory2(
MakeSharedMemory(kDataBuffer2));
base::FileDescriptor file_descriptor1(
@@ -877,7 +879,7 @@
get_proxy_listener()->set_listener(get_broker());
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
mach_port_urefs_t ref_count = IPC::GetMachRefCount(
shared_memory->handle().GetMemoryObject(), MACH_PORT_RIGHT_SEND);
@@ -932,7 +934,7 @@
SetBroker(new IPC::AttachmentBrokerUnprivilegedMac);
get_broker()->AddObserver(get_observer(), task_runner());
- scoped_ptr<base::Thread> thread(
+ std::unique_ptr<base::Thread> thread(
new base::Thread("ChannelProxyTestServerThread"));
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_IO;
@@ -981,7 +983,7 @@
CommonSetUp("ShareToProcess");
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
base::SharedMemoryHandle new_handle;
ASSERT_TRUE(shared_memory->ShareToProcess(0, &new_handle));
@@ -1011,7 +1013,7 @@
CommonSetUp("ShareReadOnlyToProcess");
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
base::SharedMemoryHandle new_handle;
ASSERT_TRUE(shared_memory->ShareReadOnlyToProcess(0, &new_handle));
@@ -1030,12 +1032,12 @@
base::SharedMemoryHandle shm(GetSharedMemoryHandleFromMsg1(message));
// Try to map the memory as writable.
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MapSharedMemoryHandle(shm, false));
ASSERT_EQ(nullptr, shared_memory->memory());
// Now try as read-only.
- scoped_ptr<base::SharedMemory> shared_memory2(
+ std::unique_ptr<base::SharedMemory> shared_memory2(
MapSharedMemoryHandle(shm.Duplicate(), true));
int current_prot, max_prot;
ASSERT_TRUE(IPC::GetMachProtections(shared_memory2->memory(),
@@ -1066,7 +1068,7 @@
get_proxy_listener()->set_listener(get_broker());
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
mach_port_urefs_t ref_count = IPC::GetMachRefCount(
shared_memory->handle().GetMemoryObject(), MACH_PORT_RIGHT_SEND);
@@ -1168,7 +1170,7 @@
globals->initial_resident_size + g_expected_memory_increase);
base::SharedMemoryHandle shm(GetSharedMemoryHandleFromMsg1(message));
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MapSharedMemoryHandle(shm, false));
EXPECT_LE(GetResidentSize(),
globals->initial_resident_size + g_expected_memory_increase);
@@ -1231,7 +1233,7 @@
// Map the shared memory, and make sure that its pages are counting towards
// resident size.
base::SharedMemoryHandle shm(GetSharedMemoryHandleFromMsg1(message));
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MapSharedMemoryHandle(shm, false));
char* addr = static_cast<char*>(shared_memory->memory());
diff --git a/ipc/attachment_broker_privileged.cc b/ipc/attachment_broker_privileged.cc
index 9f41892..8da461b 100644
--- a/ipc/attachment_broker_privileged.cc
+++ b/ipc/attachment_broker_privileged.cc
@@ -5,10 +5,12 @@
#include "ipc/attachment_broker_privileged.h"
#include <algorithm>
+#include <memory>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/location.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "ipc/ipc_endpoint.h"
@@ -52,12 +54,11 @@
// responsible for ensuring that the attachment broker lives longer than
// every IPC::Channel. The new instance automatically registers itself as the
// global attachment broker.
-scoped_ptr<AttachmentBrokerPrivileged> CreateBroker() {
+std::unique_ptr<AttachmentBrokerPrivileged> CreateBroker() {
#if defined(OS_WIN)
- return scoped_ptr<AttachmentBrokerPrivileged>(
- new IPC::AttachmentBrokerPrivilegedWin);
+ return base::WrapUnique(new IPC::AttachmentBrokerPrivilegedWin);
#elif defined(OS_MACOSX) && !defined(OS_IOS)
- return scoped_ptr<AttachmentBrokerPrivileged>(
+ return base::WrapUnique(
new IPC::AttachmentBrokerPrivilegedMac(g_port_provider));
#else
return nullptr;
@@ -72,7 +73,7 @@
AttachmentBrokerMakeOnce() : attachment_broker_(CreateBroker()) {}
private:
- scoped_ptr<IPC::AttachmentBrokerPrivileged> attachment_broker_;
+ std::unique_ptr<IPC::AttachmentBrokerPrivileged> attachment_broker_;
};
base::LazyInstance<AttachmentBrokerMakeOnce>::Leaky
diff --git a/ipc/attachment_broker_privileged.h b/ipc/attachment_broker_privileged.h
index 1fff37f..8be24ac 100644
--- a/ipc/attachment_broker_privileged.h
+++ b/ipc/attachment_broker_privileged.h
@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "ipc/attachment_broker.h"
#include "ipc/ipc_export.h"
diff --git a/ipc/attachment_broker_privileged_mac_unittest.cc b/ipc/attachment_broker_privileged_mac_unittest.cc
index 53981943..330db03a 100644
--- a/ipc/attachment_broker_privileged_mac_unittest.cc
+++ b/ipc/attachment_broker_privileged_mac_unittest.cc
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include "base/command_line.h"
#include "base/mac/mac_util.h"
@@ -102,10 +103,10 @@
}
// Creates a new shared memory region populated with 'a'.
-scoped_ptr<base::SharedMemory> CreateAndPopulateSharedMemoryHandle(
+std::unique_ptr<base::SharedMemory> CreateAndPopulateSharedMemoryHandle(
size_t size) {
base::SharedMemoryHandle shm(size);
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(shm, false));
shared_memory->Map(size);
memset(shared_memory->memory(), 'a', size);
@@ -114,10 +115,10 @@
// Create a shared memory region from a memory object. The returned object takes
// ownership of |memory_object|.
-scoped_ptr<base::SharedMemory> MapMemoryObject(mach_port_t memory_object,
- size_t size) {
+std::unique_ptr<base::SharedMemory> MapMemoryObject(mach_port_t memory_object,
+ size_t size) {
base::SharedMemoryHandle shm(memory_object, size, base::GetCurrentProcId());
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(shm, false));
shared_memory->Map(size);
return shared_memory;
@@ -187,7 +188,7 @@
IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_);
// Create some shared memory.
- scoped_ptr<base::SharedMemory> shared_memory =
+ std::unique_ptr<base::SharedMemory> shared_memory =
CreateAndPopulateSharedMemoryHandle(s_memory_size);
ASSERT_TRUE(shared_memory->handle().IsValid());
@@ -227,7 +228,7 @@
EXPECT_EQ(original_name_count + 1, GetActiveNameCount());
// Map the memory object and check its contents.
- scoped_ptr<base::SharedMemory> shared_memory(MapMemoryObject(
+ std::unique_ptr<base::SharedMemory> shared_memory(MapMemoryObject(
memory_object.release(),
AttachmentBrokerPrivilegedMacMultiProcessTest::s_memory_size));
const char* start = static_cast<const char*>(shared_memory->memory());
@@ -251,7 +252,7 @@
IPC::AttachmentBrokerPrivilegedMac broker(&port_provider_);
// Create some shared memory.
- scoped_ptr<base::SharedMemory> shared_memory =
+ std::unique_ptr<base::SharedMemory> shared_memory =
CreateAndPopulateSharedMemoryHandle(s_memory_size);
ASSERT_TRUE(shared_memory->handle().IsValid());
@@ -301,7 +302,7 @@
EXPECT_EQ(original_name_count + 1, GetActiveNameCount());
// Map both memory objects and check their contents.
- scoped_ptr<base::SharedMemory> shared_memory(MapMemoryObject(
+ std::unique_ptr<base::SharedMemory> shared_memory(MapMemoryObject(
memory_object.release(),
AttachmentBrokerPrivilegedMacMultiProcessTest::s_memory_size));
char* start = static_cast<char*>(shared_memory->memory());
@@ -310,7 +311,7 @@
DCHECK_EQ(start[i], 'a');
}
- scoped_ptr<base::SharedMemory> shared_memory2(MapMemoryObject(
+ std::unique_ptr<base::SharedMemory> shared_memory2(MapMemoryObject(
memory_object2.release(),
AttachmentBrokerPrivilegedMacMultiProcessTest::s_memory_size));
char* start2 = static_cast<char*>(shared_memory2->memory());
@@ -345,7 +346,7 @@
for (int i = 0; i < 2; ++i) {
// Create some shared memory.
- scoped_ptr<base::SharedMemory> shared_memory =
+ std::unique_ptr<base::SharedMemory> shared_memory =
CreateAndPopulateSharedMemoryHandle(s_memory_size);
ASSERT_TRUE(shared_memory->handle().IsValid());
@@ -393,7 +394,7 @@
EXPECT_EQ(original_name_count + 2, GetActiveNameCount());
// Map both memory objects and check their contents.
- scoped_ptr<base::SharedMemory> shared_memory(MapMemoryObject(
+ std::unique_ptr<base::SharedMemory> shared_memory(MapMemoryObject(
memory_object.release(),
AttachmentBrokerPrivilegedMacMultiProcessTest::s_memory_size));
char* start = static_cast<char*>(shared_memory->memory());
@@ -402,7 +403,7 @@
DCHECK_EQ(start[i], 'a');
}
- scoped_ptr<base::SharedMemory> shared_memory2(MapMemoryObject(
+ std::unique_ptr<base::SharedMemory> shared_memory2(MapMemoryObject(
memory_object2.release(),
AttachmentBrokerPrivilegedMacMultiProcessTest::s_memory_size));
char* start2 = static_cast<char*>(shared_memory2->memory());
diff --git a/ipc/attachment_broker_privileged_win_unittest.cc b/ipc/attachment_broker_privileged_win_unittest.cc
index 3ab91119..dc3bffc 100644
--- a/ipc/attachment_broker_privileged_win_unittest.cc
+++ b/ipc/attachment_broker_privileged_win_unittest.cc
@@ -6,12 +6,12 @@
#include <windows.h>
+#include <memory>
#include <tuple>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/memory/shared_memory_handle.h"
#include "base/win/scoped_handle.h"
@@ -83,7 +83,7 @@
}
// Returns a mapped, shared memory region based on the handle in |message|.
-scoped_ptr<base::SharedMemory> GetSharedMemoryFromSharedMemoryHandleMsg1(
+std::unique_ptr<base::SharedMemory> GetSharedMemoryFromSharedMemoryHandleMsg1(
const IPC::Message& message,
size_t size) {
// Expect a message with a brokered attachment.
@@ -100,7 +100,7 @@
}
base::SharedMemoryHandle handle = std::get<0>(p);
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
new base::SharedMemory(handle, false));
shared_memory->Map(size);
@@ -313,7 +313,7 @@
base::ScopedTempDir temp_dir_;
base::FilePath temp_path_;
ProxyListener proxy_listener_;
- scoped_ptr<IPC::AttachmentBrokerUnprivilegedWin> broker_;
+ std::unique_ptr<IPC::AttachmentBrokerUnprivilegedWin> broker_;
MockObserver observer_;
DWORD handle_count_;
};
@@ -479,7 +479,7 @@
ResultListener result_listener;
get_proxy_listener()->set_listener(&result_listener);
- scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
+ std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
shared_memory->CreateAndMapAnonymous(kSharedMemorySize);
memcpy(shared_memory->memory(), kDataBuffer, strlen(kDataBuffer));
sender()->Send(new TestSharedMemoryHandleMsg1(shared_memory->handle()));
@@ -504,7 +504,7 @@
// Set up IPC channel.
IPC::AttachmentBrokerPrivilegedWin broker;
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName(channel_name), &listener));
broker.RegisterCommunicationChannel(channel.get(), nullptr);
CHECK(channel->Connect());
@@ -639,7 +639,7 @@
void SendSharedMemoryHandleCallback(IPC::Sender* sender,
const IPC::Message& message) {
- scoped_ptr<base::SharedMemory> shared_memory =
+ std::unique_ptr<base::SharedMemory> shared_memory =
GetSharedMemoryFromSharedMemoryHandleMsg1(message, kSharedMemorySize);
bool success =
memcmp(shared_memory->memory(), kDataBuffer, strlen(kDataBuffer)) == 0;
diff --git a/ipc/attachment_broker_unprivileged.cc b/ipc/attachment_broker_unprivileged.cc
index c1e4c4ac..ad7c717 100644
--- a/ipc/attachment_broker_unprivileged.cc
+++ b/ipc/attachment_broker_unprivileged.cc
@@ -4,7 +4,10 @@
#include "ipc/attachment_broker_unprivileged.h"
+#include <memory>
+
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
@@ -28,13 +31,11 @@
// responsible for ensuring that the attachment broker lives longer than
// every IPC::Channel. The new instance automatically registers itself as the
// global attachment broker.
-scoped_ptr<AttachmentBrokerUnprivileged> CreateBroker() {
+std::unique_ptr<AttachmentBrokerUnprivileged> CreateBroker() {
#if defined(OS_WIN)
- return scoped_ptr<AttachmentBrokerUnprivileged>(
- new IPC::AttachmentBrokerUnprivilegedWin);
+ return base::WrapUnique(new IPC::AttachmentBrokerUnprivilegedWin);
#elif defined(OS_MACOSX) && !defined(OS_IOS)
- return scoped_ptr<AttachmentBrokerUnprivileged>(
- new IPC::AttachmentBrokerUnprivilegedMac);
+ return base::WrapUnique(new IPC::AttachmentBrokerUnprivilegedMac);
#else
return nullptr;
#endif
@@ -53,7 +54,7 @@
}
private:
- scoped_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_;
+ std::unique_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_;
};
base::LazyInstance<AttachmentBrokerMakeOnce>::Leaky
diff --git a/ipc/attachment_broker_unprivileged.h b/ipc/attachment_broker_unprivileged.h
index f6d520d..d66a693 100644
--- a/ipc/attachment_broker_unprivileged.h
+++ b/ipc/attachment_broker_unprivileged.h
@@ -6,7 +6,6 @@
#define IPC_ATTACHMENT_BROKER_UNPRIVILEGED_H_
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "ipc/attachment_broker.h"
#include "ipc/ipc_export.h"
diff --git a/ipc/ipc_channel.h b/ipc/ipc_channel.h
index c1ad417..dba2150 100644
--- a/ipc/ipc_channel.h
+++ b/ipc/ipc_channel.h
@@ -8,11 +8,11 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/files/scoped_file.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/process.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_handle.h"
@@ -127,11 +127,12 @@
// Each mode has its own Create*() API to create the Channel object.
//
// TODO(morrita): Replace CreateByModeForProxy() with one of above Create*().
- static scoped_ptr<Channel> Create(const IPC::ChannelHandle& channel_handle,
- Mode mode,
- Listener* listener);
+ static std::unique_ptr<Channel> Create(
+ const IPC::ChannelHandle& channel_handle,
+ Mode mode,
+ Listener* listener);
- static scoped_ptr<Channel> CreateClient(
+ static std::unique_ptr<Channel> CreateClient(
const IPC::ChannelHandle& channel_handle,
Listener* listener);
@@ -140,21 +141,21 @@
// from other processes. Named channels work via named unix domain sockets.
// On Windows MODE_NAMED_SERVER is equivalent to MODE_SERVER and
// MODE_NAMED_CLIENT is equivalent to MODE_CLIENT.
- static scoped_ptr<Channel> CreateNamedServer(
+ static std::unique_ptr<Channel> CreateNamedServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener);
- static scoped_ptr<Channel> CreateNamedClient(
+ static std::unique_ptr<Channel> CreateNamedClient(
const IPC::ChannelHandle& channel_handle,
Listener* listener);
#if defined(OS_POSIX)
// An "open" named server accepts connections from ANY client.
// The caller must then implement their own access-control based on the
// client process' user Id.
- static scoped_ptr<Channel> CreateOpenNamedServer(
+ static std::unique_ptr<Channel> CreateOpenNamedServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener);
#endif
- static scoped_ptr<Channel> CreateServer(
+ static std::unique_ptr<Channel> CreateServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener);
@@ -251,7 +252,7 @@
Message* get_message() const { return message_.get(); }
private:
- scoped_ptr<Message> message_;
+ std::unique_ptr<Message> message_;
void* buffer_;
size_t length_;
};
diff --git a/ipc/ipc_channel_common.cc b/ipc/ipc_channel_common.cc
index c12a360..d999733f 100644
--- a/ipc/ipc_channel_common.cc
+++ b/ipc/ipc_channel_common.cc
@@ -8,21 +8,21 @@
namespace IPC {
// static
-scoped_ptr<Channel> Channel::CreateClient(
+std::unique_ptr<Channel> Channel::CreateClient(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
return Channel::Create(channel_handle, Channel::MODE_CLIENT, listener);
}
// static
-scoped_ptr<Channel> Channel::CreateNamedServer(
+std::unique_ptr<Channel> Channel::CreateNamedServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
return Channel::Create(channel_handle, Channel::MODE_NAMED_SERVER, listener);
}
// static
-scoped_ptr<Channel> Channel::CreateNamedClient(
+std::unique_ptr<Channel> Channel::CreateNamedClient(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
return Channel::Create(channel_handle, Channel::MODE_NAMED_CLIENT, listener);
@@ -30,7 +30,7 @@
#if defined(OS_POSIX)
// static
-scoped_ptr<Channel> Channel::CreateOpenNamedServer(
+std::unique_ptr<Channel> Channel::CreateOpenNamedServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
return Channel::Create(channel_handle, Channel::MODE_OPEN_NAMED_SERVER,
@@ -39,7 +39,7 @@
#endif
// static
-scoped_ptr<Channel> Channel::CreateServer(
+std::unique_ptr<Channel> Channel::CreateServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
return Channel::Create(channel_handle, Channel::MODE_SERVER, listener);
diff --git a/ipc/ipc_channel_factory.cc b/ipc/ipc_channel_factory.cc
index 6dda14d273..746b19a 100644
--- a/ipc/ipc_channel_factory.cc
+++ b/ipc/ipc_channel_factory.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "ipc/ipc_channel_factory.h"
namespace IPC {
@@ -18,7 +19,7 @@
return handle_.name;
}
- scoped_ptr<Channel> BuildChannel(Listener* listener) override {
+ std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
return Channel::Create(handle_, mode_, listener);
}
@@ -32,9 +33,10 @@
} // namespace
// static
-scoped_ptr<ChannelFactory> ChannelFactory::Create(const ChannelHandle& handle,
- Channel::Mode mode) {
- return scoped_ptr<ChannelFactory>(new PlatformChannelFactory(handle, mode));
+std::unique_ptr<ChannelFactory> ChannelFactory::Create(
+ const ChannelHandle& handle,
+ Channel::Mode mode) {
+ return base::WrapUnique(new PlatformChannelFactory(handle, mode));
}
} // namespace IPC
diff --git a/ipc/ipc_channel_factory.h b/ipc/ipc_channel_factory.h
index 4c8569c..3b6ae87 100644
--- a/ipc/ipc_channel_factory.h
+++ b/ipc/ipc_channel_factory.h
@@ -5,10 +5,10 @@
#ifndef IPC_IPC_CHANNEL_FACTORY_H_
#define IPC_IPC_CHANNEL_FACTORY_H_
+#include <memory>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "ipc/ipc_channel.h"
namespace IPC {
@@ -20,12 +20,12 @@
public:
// Creates a factory for "native" channel built through
// IPC::Channel::Create().
- static scoped_ptr<ChannelFactory> Create(const ChannelHandle& handle,
- Channel::Mode mode);
+ static std::unique_ptr<ChannelFactory> Create(const ChannelHandle& handle,
+ Channel::Mode mode);
virtual ~ChannelFactory() { }
virtual std::string GetName() const = 0;
- virtual scoped_ptr<Channel> BuildChannel(Listener* listener) = 0;
+ virtual std::unique_ptr<Channel> BuildChannel(Listener* listener) = 0;
};
} // namespace IPC
diff --git a/ipc/ipc_channel_nacl.cc b/ipc/ipc_channel_nacl.cc
index 84d77f6..197e59938 100644
--- a/ipc/ipc_channel_nacl.cc
+++ b/ipc/ipc_channel_nacl.cc
@@ -14,6 +14,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/task_runner_util.h"
@@ -77,7 +78,7 @@
// above callbacks.
ReaderThreadRunner(
int pipe,
- base::Callback<void(scoped_ptr<MessageContents>)> data_read_callback,
+ base::Callback<void(std::unique_ptr<MessageContents>)> data_read_callback,
base::Callback<void()> failure_callback,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
@@ -87,7 +88,7 @@
private:
int pipe_;
- base::Callback<void (scoped_ptr<MessageContents>)> data_read_callback_;
+ base::Callback<void(std::unique_ptr<MessageContents>)> data_read_callback_;
base::Callback<void ()> failure_callback_;
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
@@ -96,18 +97,17 @@
ChannelNacl::ReaderThreadRunner::ReaderThreadRunner(
int pipe,
- base::Callback<void(scoped_ptr<MessageContents>)> data_read_callback,
+ base::Callback<void(std::unique_ptr<MessageContents>)> data_read_callback,
base::Callback<void()> failure_callback,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner)
: pipe_(pipe),
data_read_callback_(data_read_callback),
failure_callback_(failure_callback),
- main_task_runner_(main_task_runner) {
-}
+ main_task_runner_(main_task_runner) {}
void ChannelNacl::ReaderThreadRunner::Run() {
while (true) {
- scoped_ptr<MessageContents> msg_contents(new MessageContents);
+ std::unique_ptr<MessageContents> msg_contents(new MessageContents);
bool success = ReadDataOnReaderThread(pipe_, msg_contents.get());
if (success) {
main_task_runner_->PostTask(
@@ -206,7 +206,7 @@
DCHECK(!message->HasAttachments());
DVLOG(2) << "sending message @" << message << " on channel @" << this
<< " with type " << message->type();
- scoped_ptr<Message> message_ptr(message);
+ std::unique_ptr<Message> message_ptr(message);
#ifdef IPC_MESSAGE_LOG_ENABLED
Logging::GetInstance()->OnSendMessage(message_ptr.get(), "");
@@ -227,7 +227,7 @@
return nullptr;
}
-void ChannelNacl::DidRecvMsg(scoped_ptr<MessageContents> contents) {
+void ChannelNacl::DidRecvMsg(std::unique_ptr<MessageContents> contents) {
// Close sets the pipe to -1. It's possible we'll get a buffer sent to us from
// the reader thread after Close is called. If so, we ignore it.
if (pipe_ == -1)
@@ -397,10 +397,11 @@
// Channel's methods
// static
-scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle,
- Mode mode,
- Listener* listener) {
- return scoped_ptr<Channel>(new ChannelNacl(channel_handle, mode, listener));
+std::unique_ptr<Channel> Channel::Create(
+ const IPC::ChannelHandle& channel_handle,
+ Mode mode,
+ Listener* listener) {
+ return base::WrapUnique(new ChannelNacl(channel_handle, mode, listener));
}
} // namespace IPC
diff --git a/ipc/ipc_channel_nacl.h b/ipc/ipc_channel_nacl.h
index 0fcf85a..06dc0be 100644
--- a/ipc/ipc_channel_nacl.h
+++ b/ipc/ipc_channel_nacl.h
@@ -6,11 +6,11 @@
#define IPC_IPC_CHANNEL_NACL_H_
#include <deque>
+#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/process/process.h"
#include "base/threading/simple_thread.h"
@@ -50,7 +50,7 @@
AttachmentBroker* GetAttachmentBroker() override;
// Posted to the main thread by ReaderThreadRunner.
- void DidRecvMsg(scoped_ptr<MessageContents> contents);
+ void DidRecvMsg(std::unique_ptr<MessageContents> contents);
void ReadDidFail();
private:
@@ -90,8 +90,8 @@
// imc_recvmsg supports non-blocking reads, but there's no easy way to be
// informed when a write or read can be done without blocking (this is handled
// by libevent in Posix).
- scoped_ptr<ReaderThreadRunner> reader_thread_runner_;
- scoped_ptr<base::DelegateSimpleThread> reader_thread_;
+ std::unique_ptr<ReaderThreadRunner> reader_thread_runner_;
+ std::unique_ptr<base::DelegateSimpleThread> reader_thread_;
// IPC::ChannelReader expects to be able to call ReadData on us to
// synchronously read data waiting in the pipe's buffer without blocking.
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc
index b0a8c38..42db9e1 100644
--- a/ipc/ipc_channel_posix.cc
+++ b/ipc/ipc_channel_posix.cc
@@ -13,6 +13,10 @@
#include <sys/types.h>
#include <unistd.h>
+#include <memory>
+
+#include "base/memory/ptr_util.h"
+
#if defined(OS_OPENBSD)
#include <sys/uio.h>
#endif
@@ -31,7 +35,6 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/global_descriptors.h"
@@ -820,9 +823,8 @@
void ChannelPosix::QueueHelloMessage() {
// Create the Hello message
- scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
- HELLO_MESSAGE_TYPE,
- IPC::Message::PRIORITY_NORMAL));
+ std::unique_ptr<Message> msg(new Message(MSG_ROUTING_NONE, HELLO_MESSAGE_TYPE,
+ IPC::Message::PRIORITY_NORMAL));
if (!msg->WriteInt(GetHelloMessageProcId())) {
NOTREACHED() << "Unable to pickle hello message proc id";
}
@@ -976,9 +978,9 @@
case 1:
case 2: {
// Create the message
- scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
- CLOSE_FD_MESSAGE_TYPE,
- IPC::Message::PRIORITY_NORMAL));
+ std::unique_ptr<Message> msg(new Message(MSG_ROUTING_NONE,
+ CLOSE_FD_MESSAGE_TYPE,
+ IPC::Message::PRIORITY_NORMAL));
if (!msg->WriteInt(hops - 1) || !msg->WriteInt(fd)) {
NOTREACHED() << "Unable to pickle close fd.";
}
@@ -1101,10 +1103,11 @@
// Channel's methods
// static
-scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle,
- Mode mode,
- Listener* listener) {
- return make_scoped_ptr(new ChannelPosix(channel_handle, mode, listener));
+std::unique_ptr<Channel> Channel::Create(
+ const IPC::ChannelHandle& channel_handle,
+ Mode mode,
+ Listener* listener) {
+ return base::WrapUnique(new ChannelPosix(channel_handle, mode, listener));
}
// static
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index 29f0d39..c76af5a 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -15,10 +15,11 @@
#include <sys/un.h>
#include <unistd.h>
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/process.h"
@@ -118,7 +119,7 @@
void TearDown() override;
private:
- scoped_ptr<base::MessageLoopForIO> message_loop_;
+ std::unique_ptr<base::MessageLoopForIO> message_loop_;
};
const std::string IPCChannelPosixTest::GetChannelDirName() {
@@ -178,7 +179,7 @@
IPC::ChannelHandle handle(kChannelName);
SetUpSocket(&handle, IPC::Channel::MODE_NAMED_SERVER);
unlink(handle.name.c_str());
- scoped_ptr<IPC::ChannelPosix> channel(
+ std::unique_ptr<IPC::ChannelPosix> channel(
new IPC::ChannelPosix(handle, IPC::Channel::MODE_NAMED_SERVER, NULL));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
@@ -197,7 +198,7 @@
base::FileDescriptor fd(pipe_fds[0], false);
IPC::ChannelHandle handle(socket_name, fd);
- scoped_ptr<IPC::ChannelPosix> channel(
+ std::unique_ptr<IPC::ChannelPosix> channel(
new IPC::ChannelPosix(handle, IPC::Channel::MODE_SERVER, NULL));
ASSERT_TRUE(channel->Connect());
ASSERT_FALSE(channel->AcceptsConnections());
@@ -206,7 +207,7 @@
// Make sure that we can use the socket that is created for us by
// a standard channel.
- scoped_ptr<IPC::ChannelPosix> channel2(
+ std::unique_ptr<IPC::ChannelPosix> channel2(
new IPC::ChannelPosix(socket_name, IPC::Channel::MODE_SERVER, NULL));
ASSERT_TRUE(channel2->Connect());
ASSERT_FALSE(channel2->AcceptsConnections());
@@ -219,11 +220,11 @@
IPCChannelPosixTestListener out_listener(true);
IPCChannelPosixTestListener in_listener(true);
IPC::ChannelHandle in_handle("IN");
- scoped_ptr<IPC::ChannelPosix> in_chan(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> in_chan(new IPC::ChannelPosix(
in_handle, IPC::Channel::MODE_SERVER, &in_listener));
IPC::ChannelHandle out_handle(
"OUT", base::FileDescriptor(in_chan->TakeClientFileDescriptor()));
- scoped_ptr<IPC::ChannelPosix> out_chan(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> out_chan(new IPC::ChannelPosix(
out_handle, IPC::Channel::MODE_CLIENT, &out_listener));
ASSERT_TRUE(in_chan->Connect());
ASSERT_TRUE(out_chan->Connect());
@@ -244,11 +245,11 @@
IPCChannelPosixTestListener out_listener(true);
IPCChannelPosixTestListener in_listener(true);
IPC::ChannelHandle in_handle("IN");
- scoped_ptr<IPC::ChannelPosix> in_chan(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> in_chan(new IPC::ChannelPosix(
in_handle, IPC::Channel::MODE_SERVER, &in_listener));
IPC::ChannelHandle out_handle(
"OUT", base::FileDescriptor(in_chan->TakeClientFileDescriptor()));
- scoped_ptr<IPC::ChannelPosix> out_chan(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> out_chan(new IPC::ChannelPosix(
out_handle, IPC::Channel::MODE_CLIENT, &out_listener));
ASSERT_TRUE(in_chan->Connect());
in_chan->Close(); // simulate remote process dying at an unfortunate time.
@@ -267,7 +268,7 @@
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
- scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
@@ -303,7 +304,7 @@
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
- scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
@@ -339,7 +340,7 @@
TEST_F(IPCChannelPosixTest, BadChannelName) {
// Test empty name
IPC::ChannelHandle handle("");
- scoped_ptr<IPC::ChannelPosix> channel(
+ std::unique_ptr<IPC::ChannelPosix> channel(
new IPC::ChannelPosix(handle, IPC::Channel::MODE_NAMED_SERVER, NULL));
ASSERT_FALSE(channel->Connect());
@@ -353,7 +354,7 @@
"leading-edge_processes";
EXPECT_GE(strlen(kTooLongName), IPC::kMaxSocketNameLength);
IPC::ChannelHandle handle2(kTooLongName);
- scoped_ptr<IPC::ChannelPosix> channel2(
+ std::unique_ptr<IPC::ChannelPosix> channel2(
new IPC::ChannelPosix(handle2, IPC::Channel::MODE_NAMED_SERVER, NULL));
EXPECT_FALSE(channel2->Connect());
}
@@ -369,7 +370,7 @@
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
SetUpSocket(&chan_handle, IPC::Channel::MODE_NAMED_SERVER);
- scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(channel->Connect());
ASSERT_TRUE(channel->AcceptsConnections());
@@ -405,9 +406,9 @@
IPCChannelPosixTestListener listener(false);
IPCChannelPosixTestListener listener2(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
- scoped_ptr<IPC::ChannelPosix> channel(
+ std::unique_ptr<IPC::ChannelPosix> channel(
new IPC::ChannelPosix(chan_handle, IPC::Channel::MODE_SERVER, &listener));
- scoped_ptr<IPC::ChannelPosix> channel2(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel2(new IPC::ChannelPosix(
chan_handle, IPC::Channel::MODE_SERVER, &listener2));
ASSERT_TRUE(channel->Connect());
ASSERT_FALSE(channel2->Connect());
@@ -417,7 +418,7 @@
// Test setting up two servers with a bad mode.
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle chan_handle(GetConnectionSocketName());
- scoped_ptr<IPC::ChannelPosix> channel(
+ std::unique_ptr<IPC::ChannelPosix> channel(
new IPC::ChannelPosix(chan_handle, IPC::Channel::MODE_NONE, &listener));
ASSERT_FALSE(channel->Connect());
}
@@ -429,7 +430,7 @@
ASSERT_TRUE(base::DeleteFile(base::FilePath(connection_socket_name), false));
ASSERT_FALSE(IPC::Channel::IsNamedServerInitialized(
connection_socket_name));
- scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener));
ASSERT_TRUE(IPC::Channel::IsNamedServerInitialized(
connection_socket_name));
@@ -445,7 +446,7 @@
IPCChannelPosixTestListener listener(true);
IPC::ChannelHandle handle(IPCChannelPosixTest::GetConnectionSocketName());
IPCChannelPosixTest::SetUpSocket(&handle, IPC::Channel::MODE_NAMED_CLIENT);
- scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
handle, IPC::Channel::MODE_NAMED_CLIENT, &listener));
EXPECT_TRUE(channel->Connect());
IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout());
@@ -459,7 +460,7 @@
IPCChannelPosixTestListener listener(false);
IPC::ChannelHandle handle(IPCChannelPosixTest::GetConnectionSocketName());
IPCChannelPosixTest::SetUpSocket(&handle, IPC::Channel::MODE_NAMED_CLIENT);
- scoped_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
+ std::unique_ptr<IPC::ChannelPosix> channel(new IPC::ChannelPosix(
handle, IPC::Channel::MODE_NAMED_CLIENT, &listener));
// In this case connect may succeed or fail depending on if the packet
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index 848e1856..f0031d6 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -6,13 +6,14 @@
#include <stddef.h>
#include <stdint.h>
+
#include <utility>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/location.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/profiler/scoped_tracker.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
@@ -58,7 +59,8 @@
ipc_task_runner_ = NULL;
}
-void ChannelProxy::Context::CreateChannel(scoped_ptr<ChannelFactory> factory) {
+void ChannelProxy::Context::CreateChannel(
+ std::unique_ptr<ChannelFactory> factory) {
base::AutoLock l(channel_lifetime_lock_);
DCHECK(!channel_);
channel_id_ = factory->GetName();
@@ -182,7 +184,7 @@
}
// Called on the IPC::Channel thread
-void ChannelProxy::Context::OnSendMessage(scoped_ptr<Message> message) {
+void ChannelProxy::Context::OnSendMessage(std::unique_ptr<Message> message) {
// TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
@@ -332,7 +334,7 @@
ipc_task_runner()->PostTask(
FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this,
- base::Passed(scoped_ptr<Message>(message))));
+ base::Passed(base::WrapUnique(message))));
}
bool ChannelProxy::Context::IsChannelSendThreadSafe() const {
@@ -342,22 +344,24 @@
//-----------------------------------------------------------------------------
// static
-scoped_ptr<ChannelProxy> ChannelProxy::Create(
+std::unique_ptr<ChannelProxy> ChannelProxy::Create(
const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
- scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
+ std::unique_ptr<ChannelProxy> channel(
+ new ChannelProxy(listener, ipc_task_runner));
channel->Init(channel_handle, mode, true);
return channel;
}
// static
-scoped_ptr<ChannelProxy> ChannelProxy::Create(
- scoped_ptr<ChannelFactory> factory,
+std::unique_ptr<ChannelProxy> ChannelProxy::Create(
+ std::unique_ptr<ChannelFactory> factory,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
- scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
+ std::unique_ptr<ChannelProxy> channel(
+ new ChannelProxy(listener, ipc_task_runner));
channel->Init(std::move(factory), true);
return channel;
}
@@ -400,7 +404,7 @@
Init(ChannelFactory::Create(channel_handle, mode), create_pipe_now);
}
-void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory,
+void ChannelProxy::Init(std::unique_ptr<ChannelFactory> factory,
bool create_pipe_now) {
DCHECK(CalledOnValidThread());
DCHECK(!did_init_);
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index 9fdffb1c..2c5ec98 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -7,10 +7,10 @@
#include <stdint.h>
+#include <memory>
#include <vector>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/non_thread_safe.h"
#include "build/build_config.h"
@@ -86,14 +86,14 @@
// on the background thread. Any message not handled by the filter will be
// dispatched to the listener. The given task runner correspond to a thread
// on which IPC::Channel is created and used (e.g. IO thread).
- static scoped_ptr<ChannelProxy> Create(
+ static std::unique_ptr<ChannelProxy> Create(
const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);
- static scoped_ptr<ChannelProxy> Create(
- scoped_ptr<ChannelFactory> factory,
+ static std::unique_ptr<ChannelProxy> Create(
+ std::unique_ptr<ChannelFactory> factory,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);
@@ -106,7 +106,7 @@
void Init(const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
bool create_pipe_now);
- void Init(scoped_ptr<ChannelFactory> factory, bool create_pipe_now);
+ void Init(std::unique_ptr<ChannelFactory> factory, bool create_pipe_now);
// Close the IPC::Channel. This operation completes asynchronously, once the
// background thread processes the command to close the channel. It is ok to
@@ -214,7 +214,7 @@
friend class IpcSecurityTestUtil;
// Create the Channel
- void CreateChannel(scoped_ptr<ChannelFactory> factory);
+ void CreateChannel(std::unique_ptr<ChannelFactory> factory);
void set_attachment_broker_endpoint(bool is_endpoint) {
attachment_broker_endpoint_ = is_endpoint;
@@ -223,7 +223,7 @@
}
// Methods called on the IO thread.
- void OnSendMessage(scoped_ptr<Message> message_ptr);
+ void OnSendMessage(std::unique_ptr<Message> message_ptr);
void OnAddFilter();
void OnRemoveFilter(MessageFilter* filter);
@@ -247,7 +247,7 @@
// But once it has been set, it must only be read or cleared on the IPC
// thread.
// One exception is the thread-safe send. See the class comment.
- scoped_ptr<Channel> channel_;
+ std::unique_ptr<Channel> channel_;
std::string channel_id_;
bool channel_connected_called_;
@@ -260,7 +260,7 @@
// Routes a given message to a proper subset of |filters_|, depending
// on which message classes a filter might support.
- scoped_ptr<MessageFilterRouter> message_filter_router_;
+ std::unique_ptr<MessageFilterRouter> message_filter_router_;
// Holds filters between the AddFilter call on the listerner thread and the
// IPC thread when they're added to filters_.
diff --git a/ipc/ipc_channel_proxy_unittest.cc b/ipc/ipc_channel_proxy_unittest.cc
index f7f832b..5997668 100644
--- a/ipc/ipc_channel_proxy_unittest.cc
+++ b/ipc/ipc_channel_proxy_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include "base/pickle.h"
#include "base/threading/thread.h"
@@ -268,8 +269,8 @@
}
private:
- scoped_ptr<base::Thread> thread_;
- scoped_ptr<QuitListener> listener_;
+ std::unique_ptr<base::Thread> thread_;
+ std::unique_ptr<QuitListener> listener_;
};
#if defined(OS_ANDROID)
@@ -423,7 +424,7 @@
}
private:
- scoped_ptr<QuitListener> listener_;
+ std::unique_ptr<QuitListener> listener_;
};
#if !defined(OS_WIN)
@@ -440,7 +441,7 @@
MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ChannelProxyClient) {
base::MessageLoopForIO main_message_loop;
ChannelReflectorListener listener;
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName("ChannelProxyClient"), &listener));
CHECK(channel->Connect());
listener.Init(channel.get());
diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc
index e11fb93a..9af3696e 100644
--- a/ipc/ipc_channel_reader.cc
+++ b/ipc/ipc_channel_reader.cc
@@ -237,7 +237,7 @@
}
// Make a deep copy of |external_message| to add to the queue.
- scoped_ptr<Message> m(new Message(*external_message));
+ std::unique_ptr<Message> m(new Message(*external_message));
queued_messages_.push_back(m.release());
return true;
}
diff --git a/ipc/ipc_channel_reader_unittest.cc b/ipc/ipc_channel_reader_unittest.cc
index 4ec71b53..1107cc7 100644
--- a/ipc/ipc_channel_reader_unittest.cc
+++ b/ipc/ipc_channel_reader_unittest.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <limits>
+#include <memory>
#include <set>
#include "base/run_loop.h"
@@ -155,7 +156,7 @@
}
TEST(ChannelReaderTest, AttachmentNotYetBrokered) {
- scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoopForIO());
+ std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoopForIO());
MockAttachmentBroker broker;
MockChannelReader reader;
diff --git a/ipc/ipc_channel_unittest.cc b/ipc/ipc_channel_unittest.cc
index 134bec2..e423b89 100644
--- a/ipc/ipc_channel_unittest.cc
+++ b/ipc/ipc_channel_unittest.cc
@@ -10,6 +10,7 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/pickle.h"
@@ -158,7 +159,7 @@
IPC::TestChannelListener listener;
// Set up IPC channel.
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName("GenericClient"), &listener));
CHECK(channel->Connect());
listener.Init(channel.get());
diff --git a/ipc/ipc_channel_win.cc b/ipc/ipc_channel_win.cc
index 6291862..6ae83b7 100644
--- a/ipc/ipc_channel_win.cc
+++ b/ipc/ipc_channel_win.cc
@@ -12,6 +12,7 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/pickle.h"
#include "base/process/process_handle.h"
#include "base/rand_util.h"
@@ -373,9 +374,8 @@
}
// Create the Hello message to be sent when Connect is called
- scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE,
- HELLO_MESSAGE_TYPE,
- IPC::Message::PRIORITY_NORMAL));
+ std::unique_ptr<Message> m(new Message(MSG_ROUTING_NONE, HELLO_MESSAGE_TYPE,
+ IPC::Message::PRIORITY_NORMAL));
// Don't send the secret to the untrusted process, and don't send a secret
// if the value is zero (for IPC backwards compatability).
@@ -578,10 +578,11 @@
// Channel's methods
// static
-scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle,
- Mode mode,
- Listener* listener) {
- return scoped_ptr<Channel>(new ChannelWin(channel_handle, mode, listener));
+std::unique_ptr<Channel> Channel::Create(
+ const IPC::ChannelHandle& channel_handle,
+ Mode mode,
+ Listener* listener) {
+ return base::WrapUnique(new ChannelWin(channel_handle, mode, listener));
}
// static
diff --git a/ipc/ipc_channel_win.h b/ipc/ipc_channel_win.h
index fd186fc..88e586d 100644
--- a/ipc/ipc_channel_win.h
+++ b/ipc/ipc_channel_win.h
@@ -5,18 +5,17 @@
#ifndef IPC_IPC_CHANNEL_WIN_H_
#define IPC_IPC_CHANNEL_WIN_H_
-#include "ipc/ipc_channel.h"
-
#include <stdint.h>
+#include <memory>
#include <queue>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/win/scoped_handle.h"
+#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_reader.h"
namespace base {
@@ -131,7 +130,7 @@
// compatability with existing clients that don't validate the channel.)
int32_t client_secret_;
- scoped_ptr<base::ThreadChecker> thread_check_;
+ std::unique_ptr<base::ThreadChecker> thread_check_;
base::WeakPtrFactory<ChannelWin> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ChannelWin);
diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc
index 6eb93054..00e91f3 100644
--- a/ipc/ipc_fuzzing_tests.cc
+++ b/ipc/ipc_fuzzing_tests.cc
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <limits>
+#include <memory>
#include <sstream>
#include <string>
@@ -259,7 +260,7 @@
MULTIPROCESS_IPC_TEST_CLIENT_MAIN(FuzzServerClient) {
base::MessageLoopForIO main_message_loop;
FuzzerServerListener listener;
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName("FuzzServerClient"), &listener));
CHECK(channel->Connect());
listener.Init(channel.get());
diff --git a/ipc/ipc_logging.h b/ipc/ipc_logging.h
index 2d12cb4..5234135 100644
--- a/ipc/ipc_logging.h
+++ b/ipc/ipc_logging.h
@@ -14,7 +14,6 @@
#include <vector>
#include "base/containers/hash_tables.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/message_loop/message_loop.h"
#include "ipc/ipc_export.h"
diff --git a/ipc/ipc_message_unittest.cc b/ipc/ipc_message_unittest.cc
index c022f97..21f5eb2 100644
--- a/ipc/ipc_message_unittest.cc
+++ b/ipc/ipc_message_unittest.cc
@@ -9,8 +9,8 @@
#include <string.h>
#include <limits>
+#include <memory>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -93,11 +93,11 @@
input.Set("int", new base::FundamentalValue(42));
input.SetWithoutPathExpansion("int.with.dot", new base::FundamentalValue(43));
- scoped_ptr<base::DictionaryValue> subdict(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> subdict(new base::DictionaryValue());
subdict->Set("str", new base::StringValue("forty two"));
subdict->Set("bool", new base::FundamentalValue(false));
- scoped_ptr<base::ListValue> sublist(new base::ListValue());
+ std::unique_ptr<base::ListValue> sublist(new base::ListValue());
sublist->Set(0, new base::FundamentalValue(42.42));
sublist->Set(1, new base::StringValue("forty"));
sublist->Set(2, new base::StringValue("two"));
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 59057ee..6a8be498 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -9,7 +9,6 @@
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -305,14 +304,14 @@
break;
}
case base::Value::TYPE_DICTIONARY: {
- scoped_ptr<base::DictionaryValue> val(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue());
if (!ReadDictionaryValue(m, iter, val.get(), recursion))
return false;
*value = val.release();
break;
}
case base::Value::TYPE_LIST: {
- scoped_ptr<base::ListValue> val(new base::ListValue());
+ std::unique_ptr<base::ListValue> val(new base::ListValue());
if (!ReadListValue(m, iter, val.get(), recursion))
return false;
*value = val.release();
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index cf4fa8f..2c457031 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -11,6 +11,7 @@
#include <algorithm>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <tuple>
@@ -20,7 +21,6 @@
#include "base/containers/stack_container.h"
#include "base/files/file.h"
#include "base/format_macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
@@ -941,8 +941,8 @@
};
template <class P>
-struct ParamTraits<scoped_ptr<P> > {
- typedef scoped_ptr<P> param_type;
+struct ParamTraits<std::unique_ptr<P>> {
+ typedef std::unique_ptr<P> param_type;
static void GetSize(base::PickleSizer* sizer, const param_type& p) {
bool valid = !!p;
GetParamSize(sizer, valid);
diff --git a/ipc/ipc_message_utils_unittest.cc b/ipc/ipc_message_utils_unittest.cc
index 659047d2..51e8336a 100644
--- a/ipc/ipc_message_utils_unittest.cc
+++ b/ipc/ipc_message_utils_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
@@ -93,17 +94,17 @@
// Tests that PickleSizer and Pickle agree on the size of a complex base::Value.
TEST(IPCMessageUtilsTest, ValueSize) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue);
value->SetWithoutPathExpansion("foo", new base::FundamentalValue(42));
value->SetWithoutPathExpansion("bar", new base::FundamentalValue(3.14));
value->SetWithoutPathExpansion("baz", new base::StringValue("hello"));
value->SetWithoutPathExpansion("qux", base::Value::CreateNullValue());
- scoped_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> nested_dict(new base::DictionaryValue);
nested_dict->SetWithoutPathExpansion("foobar", new base::FundamentalValue(5));
value->SetWithoutPathExpansion("nested", std::move(nested_dict));
- scoped_ptr<base::ListValue> list_value(new base::ListValue);
+ std::unique_ptr<base::ListValue> list_value(new base::ListValue);
list_value->Append(new base::StringValue("im a string"));
list_value->Append(new base::StringValue("im another string"));
value->SetWithoutPathExpansion("awesome-list", std::move(list_value));
diff --git a/ipc/ipc_perftest_support.cc b/ipc/ipc_perftest_support.cc
index 5cd2b1d..050b5413 100644
--- a/ipc/ipc_perftest_support.cc
+++ b/ipc/ipc_perftest_support.cc
@@ -8,11 +8,12 @@
#include <stdint.h>
#include <algorithm>
+#include <memory>
#include <string>
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/pickle.h"
#include "base/strings/stringprintf.h"
#include "base/test/perf_time_logger.h"
@@ -224,7 +225,7 @@
int count_down_;
std::string payload_;
EventTimeTracker latency_tracker_;
- scoped_ptr<base::PerfTimeLogger> perf_logger_;
+ std::unique_ptr<base::PerfTimeLogger> perf_logger_;
};
IPCChannelPerfTestBase::IPCChannelPerfTestBase() = default;
@@ -286,8 +287,7 @@
const std::vector<PingPongTestParams>& params) {
io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart));
InitWithCustomMessageLoop("PerformanceClient",
- make_scoped_ptr(new base::MessageLoop()));
-
+ base::WrapUnique(new base::MessageLoop()));
// Set up IPC channel and start client.
PerformanceChannelListener listener("ChannelProxy");
@@ -333,15 +333,14 @@
PingPongTestClient::~PingPongTestClient() {
}
-scoped_ptr<Channel> PingPongTestClient::CreateChannel(
- Listener* listener) {
+std::unique_ptr<Channel> PingPongTestClient::CreateChannel(Listener* listener) {
return Channel::CreateClient(IPCTestBase::GetChannelName("PerformanceClient"),
listener);
}
int PingPongTestClient::RunMain() {
LockThreadAffinity thread_locker(kSharedCore);
- scoped_ptr<Channel> channel = CreateChannel(listener_.get());
+ std::unique_ptr<Channel> channel = CreateChannel(listener_.get());
listener_->Init(channel.get());
CHECK(channel->Connect());
diff --git a/ipc/ipc_perftest_support.h b/ipc/ipc_perftest_support.h
index 82eb1eef..ba75dc7 100644
--- a/ipc/ipc_perftest_support.h
+++ b/ipc/ipc_perftest_support.h
@@ -7,6 +7,7 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/macros.h"
@@ -53,7 +54,7 @@
}
private:
- scoped_ptr<base::TestIOThread> io_thread_;
+ std::unique_ptr<base::TestIOThread> io_thread_;
};
class PingPongTestClient {
@@ -61,14 +62,14 @@
PingPongTestClient();
virtual ~PingPongTestClient();
- virtual scoped_ptr<Channel> CreateChannel(Listener* listener);
+ virtual std::unique_ptr<Channel> CreateChannel(Listener* listener);
int RunMain();
scoped_refptr<base::TaskRunner> task_runner();
private:
base::MessageLoopForIO main_message_loop_;
- scoped_ptr<ChannelReflectorListener> listener_;
- scoped_ptr<Channel> channel_;
+ std::unique_ptr<ChannelReflectorListener> listener_;
+ std::unique_ptr<Channel> channel_;
};
// This class locks the current thread to a particular CPU core. This is
diff --git a/ipc/ipc_send_fds_test.cc b/ipc/ipc_send_fds_test.cc
index 2d5616b..81a995da 100644
--- a/ipc/ipc_send_fds_test.cc
+++ b/ipc/ipc_send_fds_test.cc
@@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <memory>
#include <queue>
#include "base/callback.h"
@@ -158,7 +159,7 @@
MyChannelDescriptorListener listener(expected_inode_num);
// Set up IPC channel.
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName(test_client_name), &listener));
CHECK(channel->Connect());
@@ -266,8 +267,8 @@
FROM_HERE, base::Bind(&PipeChannelHelper::Connect, out.get()));
}
- static void DestroyChannel(scoped_ptr<IPC::Channel> *c,
- base::WaitableEvent *event) {
+ static void DestroyChannel(std::unique_ptr<IPC::Channel>* c,
+ base::WaitableEvent* event) {
c->reset(0);
event->Signal();
}
@@ -300,7 +301,7 @@
}
private:
- scoped_ptr<IPC::Channel> in, out;
+ std::unique_ptr<IPC::Channel> in, out;
base::Thread* in_thread_;
base::Thread* out_thread_;
MyCBListener cb_listener_;
@@ -359,9 +360,9 @@
// Unless the workaround is in place. With 10000 sends, we
// should see at least a 3% failure rate.
const int pipes_to_send = 20000;
- scoped_ptr<base::Thread> producer(CreateThread("producer"));
- scoped_ptr<base::Thread> middleman(CreateThread("middleman"));
- scoped_ptr<base::Thread> consumer(CreateThread("consumer"));
+ std::unique_ptr<base::Thread> producer(CreateThread("producer"));
+ std::unique_ptr<base::Thread> middleman(CreateThread("middleman"));
+ std::unique_ptr<base::Thread> consumer(CreateThread("consumer"));
PipeChannelHelper pipe1(
middleman.get(),
consumer.get(),
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc
index 48d9328f..6758958 100644
--- a/ipc/ipc_sync_channel.cc
+++ b/ipc/ipc_sync_channel.cc
@@ -6,12 +6,14 @@
#include <stddef.h>
#include <stdint.h>
+
#include <utility>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/synchronization/waitable_event_watcher.h"
#include "base/thread_task_runner_handle.h"
@@ -405,38 +407,38 @@
}
// static
-scoped_ptr<SyncChannel> SyncChannel::Create(
+std::unique_ptr<SyncChannel> SyncChannel::Create(
const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
bool create_pipe_now,
base::WaitableEvent* shutdown_event) {
- scoped_ptr<SyncChannel> channel =
+ std::unique_ptr<SyncChannel> channel =
Create(listener, ipc_task_runner, shutdown_event);
channel->Init(channel_handle, mode, create_pipe_now);
return channel;
}
// static
-scoped_ptr<SyncChannel> SyncChannel::Create(
- scoped_ptr<ChannelFactory> factory,
+std::unique_ptr<SyncChannel> SyncChannel::Create(
+ std::unique_ptr<ChannelFactory> factory,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
bool create_pipe_now,
base::WaitableEvent* shutdown_event) {
- scoped_ptr<SyncChannel> channel =
+ std::unique_ptr<SyncChannel> channel =
Create(listener, ipc_task_runner, shutdown_event);
channel->Init(std::move(factory), create_pipe_now);
return channel;
}
// static
-scoped_ptr<SyncChannel> SyncChannel::Create(
+std::unique_ptr<SyncChannel> SyncChannel::Create(
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
WaitableEvent* shutdown_event) {
- return make_scoped_ptr(
+ return base::WrapUnique(
new SyncChannel(listener, ipc_task_runner, shutdown_event));
}
diff --git a/ipc/ipc_sync_channel.h b/ipc/ipc_sync_channel.h
index eb2a2723..103925a 100644
--- a/ipc/ipc_sync_channel.h
+++ b/ipc/ipc_sync_channel.h
@@ -6,6 +6,7 @@
#define IPC_IPC_SYNC_CHANNEL_H_
#include <deque>
+#include <memory>
#include <string>
#include <vector>
@@ -70,7 +71,7 @@
// Creates and initializes a sync channel. If create_pipe_now is specified,
// the channel will be initialized synchronously.
// The naming pattern follows IPC::Channel.
- static scoped_ptr<SyncChannel> Create(
+ static std::unique_ptr<SyncChannel> Create(
const IPC::ChannelHandle& channel_handle,
IPC::Channel::Mode mode,
Listener* listener,
@@ -78,8 +79,8 @@
bool create_pipe_now,
base::WaitableEvent* shutdown_event);
- static scoped_ptr<SyncChannel> Create(
- scoped_ptr<ChannelFactory> factory,
+ static std::unique_ptr<SyncChannel> Create(
+ std::unique_ptr<ChannelFactory> factory,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
bool create_pipe_now,
@@ -88,7 +89,7 @@
// Creates an uninitialized sync channel. Call ChannelProxy::Init to
// initialize the channel. This two-step setup allows message filters to be
// added before any messages are sent or received.
- static scoped_ptr<SyncChannel> Create(
+ static std::unique_ptr<SyncChannel> Create(
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
base::WaitableEvent* shutdown_event);
diff --git a/ipc/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc
index e3a7192..ea48f1d 100644
--- a/ipc/ipc_sync_channel_unittest.cc
+++ b/ipc/ipc_sync_channel_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
@@ -13,7 +14,6 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/process_handle.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
@@ -158,7 +158,7 @@
}
virtual SyncChannel* CreateChannel() {
- scoped_ptr<SyncChannel> channel = SyncChannel::Create(
+ std::unique_ptr<SyncChannel> channel = SyncChannel::Create(
channel_name_, mode_, this, ipc_thread_.task_runner().get(), true,
&shutdown_event_);
return channel.release();
@@ -224,11 +224,11 @@
thread->StartWithOptions(options);
}
- scoped_ptr<WaitableEvent> done_;
- scoped_ptr<WaitableEvent> channel_created_;
+ std::unique_ptr<WaitableEvent> done_;
+ std::unique_ptr<WaitableEvent> channel_created_;
std::string channel_name_;
Channel::Mode mode_;
- scoped_ptr<SyncChannel> channel_;
+ std::unique_ptr<SyncChannel> channel_;
base::Thread ipc_thread_;
base::Thread listener_thread_;
base::Thread* overrided_thread_;
@@ -1251,7 +1251,7 @@
NonRestrictedDispatchServer* server2_;
int* success_;
WaitableEvent* sent_ping_event_;
- scoped_ptr<SyncChannel> non_restricted_channel_;
+ std::unique_ptr<SyncChannel> non_restricted_channel_;
};
TEST_F(IPCSyncChannelTest, RestrictedDispatch) {
@@ -1599,7 +1599,7 @@
return true;
}
- scoped_ptr<SyncChannel> other_channel_;
+ std::unique_ptr<SyncChannel> other_channel_;
WaitableEvent* event1_;
WaitableEvent* event2_;
std::string other_channel_name_;
@@ -1680,7 +1680,7 @@
}
WaitableEvent* server_ready_;
- scoped_ptr<SyncChannel> server2_channel_;
+ std::unique_ptr<SyncChannel> server2_channel_;
};
class ReentrantReplyServer2 : public Worker {
diff --git a/ipc/ipc_sync_message.h b/ipc/ipc_sync_message.h
index 6dd3b63..cb259b1 100644
--- a/ipc/ipc_sync_message.h
+++ b/ipc/ipc_sync_message.h
@@ -6,13 +6,14 @@
#define IPC_IPC_SYNC_MESSAGE_H_
#include <stdint.h>
+
#if defined(OS_WIN)
#include <windows.h>
#endif
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "ipc/ipc_message.h"
@@ -82,7 +83,7 @@
static bool ReadSyncHeader(const Message& msg, SyncHeader* header);
static bool WriteSyncHeader(Message* msg, const SyncHeader& header);
- scoped_ptr<MessageReplyDeserializer> deserializer_;
+ std::unique_ptr<MessageReplyDeserializer> deserializer_;
base::WaitableEvent* pump_messages_event_;
};
diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc
index 6243138..831a59ad 100644
--- a/ipc/ipc_test_base.cc
+++ b/ipc/ipc_test_base.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
#include "base/process/kill.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
@@ -36,14 +37,13 @@
}
void IPCTestBase::Init(const std::string& test_client_name) {
- InitWithCustomMessageLoop(
- test_client_name,
- scoped_ptr<base::MessageLoop>(new base::MessageLoopForIO()));
+ InitWithCustomMessageLoop(test_client_name,
+ base::WrapUnique(new base::MessageLoopForIO()));
}
void IPCTestBase::InitWithCustomMessageLoop(
const std::string& test_client_name,
- scoped_ptr<base::MessageLoop> message_loop) {
+ std::unique_ptr<base::MessageLoop> message_loop) {
DCHECK(!test_client_name.empty());
DCHECK(test_client_name_.empty());
DCHECK(!message_loop_);
@@ -61,11 +61,11 @@
return channel_->Connect();
}
-scoped_ptr<IPC::Channel> IPCTestBase::ReleaseChannel() {
+std::unique_ptr<IPC::Channel> IPCTestBase::ReleaseChannel() {
return std::move(channel_);
}
-void IPCTestBase::SetChannel(scoped_ptr<IPC::Channel> channel) {
+void IPCTestBase::SetChannel(std::unique_ptr<IPC::Channel> channel) {
channel_ = std::move(channel);
}
@@ -158,7 +158,7 @@
return message_loop_->task_runner();
}
-scoped_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory(
+std::unique_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::SequencedTaskRunner* runner) {
return IPC::ChannelFactory::Create(handle, IPC::Channel::MODE_SERVER);
diff --git a/ipc/ipc_test_base.h b/ipc/ipc_test_base.h
index 86178b0..5637a57e 100644
--- a/ipc/ipc_test_base.h
+++ b/ipc/ipc_test_base.h
@@ -5,10 +5,10 @@
#ifndef IPC_IPC_TEST_BASE_H_
#define IPC_IPC_TEST_BASE_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/process.h"
#include "base/test/multiprocess_test.h"
#include "build/build_config.h"
@@ -50,7 +50,7 @@
// thread.
virtual void InitWithCustomMessageLoop(
const std::string& test_client_name,
- scoped_ptr<base::MessageLoop> message_loop);
+ std::unique_ptr<base::MessageLoop> message_loop);
// Creates a channel with the given listener and connects to the channel
// (returning true if successful), respectively. Use these to use a channel
@@ -62,8 +62,8 @@
// Releases or replaces existing channel.
// These are useful for testing specific types of channel subclasses.
- scoped_ptr<IPC::Channel> ReleaseChannel();
- void SetChannel(scoped_ptr<IPC::Channel> channel);
+ std::unique_ptr<IPC::Channel> ReleaseChannel();
+ void SetChannel(std::unique_ptr<IPC::Channel> channel);
// Use this instead of CreateChannel() if you want to use some different
// channel specification (then use ConnectChannel() as usual).
@@ -109,8 +109,9 @@
const base::Process& client_process() const { return client_process_; }
scoped_refptr<base::SequencedTaskRunner> task_runner();
- virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
- const IPC::ChannelHandle& handle, base::SequencedTaskRunner* runner);
+ virtual std::unique_ptr<IPC::ChannelFactory> CreateChannelFactory(
+ const IPC::ChannelHandle& handle,
+ base::SequencedTaskRunner* runner);
virtual bool DidStartClient();
@@ -118,10 +119,10 @@
std::string GetTestMainName() const;
std::string test_client_name_;
- scoped_ptr<base::MessageLoop> message_loop_;
+ std::unique_ptr<base::MessageLoop> message_loop_;
- scoped_ptr<IPC::Channel> channel_;
- scoped_ptr<IPC::ChannelProxy> channel_proxy_;
+ std::unique_ptr<IPC::Channel> channel_;
+ std::unique_ptr<IPC::ChannelProxy> channel_proxy_;
base::Process client_process_;
diff --git a/ipc/mojo/ipc_channel_mojo.cc b/ipc/mojo/ipc_channel_mojo.cc
index 57ec8ec..8806c6a 100644
--- a/ipc/mojo/ipc_channel_mojo.cc
+++ b/ipc/mojo/ipc_channel_mojo.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
+
#include <memory>
#include <utility>
@@ -14,6 +15,7 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_listener.h"
@@ -48,7 +50,7 @@
std::string GetName() const override { return ""; }
- scoped_ptr<Channel> BuildChannel(Listener* listener) override {
+ std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
return ChannelMojo::Create(std::move(handle_), mode_, listener);
}
@@ -199,24 +201,24 @@
//------------------------------------------------------------------------------
// static
-scoped_ptr<ChannelMojo> ChannelMojo::Create(
+std::unique_ptr<ChannelMojo> ChannelMojo::Create(
mojo::ScopedMessagePipeHandle handle,
Mode mode,
Listener* listener) {
- return make_scoped_ptr(new ChannelMojo(std::move(handle), mode, listener));
+ return base::WrapUnique(new ChannelMojo(std::move(handle), mode, listener));
}
// static
-scoped_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
+std::unique_ptr<ChannelFactory> ChannelMojo::CreateServerFactory(
mojo::ScopedMessagePipeHandle handle) {
- return make_scoped_ptr(
+ return base::WrapUnique(
new MojoChannelFactory(std::move(handle), Channel::MODE_SERVER));
}
// static
-scoped_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
+std::unique_ptr<ChannelFactory> ChannelMojo::CreateClientFactory(
mojo::ScopedMessagePipeHandle handle) {
- return make_scoped_ptr(
+ return base::WrapUnique(
new MojoChannelFactory(std::move(handle), Channel::MODE_CLIENT));
}
@@ -246,7 +248,7 @@
}
void ChannelMojo::Close() {
- scoped_ptr<internal::MessagePipeReader, ReaderDeleter> reader;
+ std::unique_ptr<internal::MessagePipeReader, ReaderDeleter> reader;
{
base::AutoLock lock(lock_);
if (!message_reader_)
@@ -280,9 +282,9 @@
base::ProcessId peer_pid) {
mojom::ChannelAssociatedPtr sender_ptr;
sender_ptr.Bind(std::move(sender));
- scoped_ptr<internal::MessagePipeReader, ChannelMojo::ReaderDeleter> reader(
- new internal::MessagePipeReader(pipe_, std::move(sender_ptr),
- std::move(receiver), peer_pid, this));
+ std::unique_ptr<internal::MessagePipeReader, ChannelMojo::ReaderDeleter>
+ reader(new internal::MessagePipeReader(
+ pipe_, std::move(sender_ptr), std::move(receiver), peer_pid, this));
bool connected = true;
{
@@ -326,13 +328,13 @@
bool ChannelMojo::Send(Message* message) {
base::AutoLock lock(lock_);
if (!message_reader_) {
- pending_messages_.push_back(make_scoped_ptr(message));
+ pending_messages_.push_back(base::WrapUnique(message));
// Counts as OK before the connection is established, but it's an
// error otherwise.
return waiting_connect_;
}
- if (!message_reader_->Send(make_scoped_ptr(message))) {
+ if (!message_reader_->Send(base::WrapUnique(message))) {
OnPipeError();
return false;
}
diff --git a/ipc/mojo/ipc_channel_mojo.h b/ipc/mojo/ipc_channel_mojo.h
index 5968d84e..a8a28ec 100644
--- a/ipc/mojo/ipc_channel_mojo.h
+++ b/ipc/mojo/ipc_channel_mojo.h
@@ -7,11 +7,11 @@
#include <stdint.h>
+#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
@@ -42,17 +42,16 @@
public NON_EXPORTED_BASE(internal::MessagePipeReader::Delegate) {
public:
// Creates a ChannelMojo.
- static scoped_ptr<ChannelMojo> Create(mojo::ScopedMessagePipeHandle handle,
- Mode mode,
- Listener* listener);
+ static std::unique_ptr<ChannelMojo>
+ Create(mojo::ScopedMessagePipeHandle handle, Mode mode, Listener* listener);
// Create a factory object for ChannelMojo.
// The factory is used to create Mojo-based ChannelProxy family.
// |host| must not be null.
- static scoped_ptr<ChannelFactory> CreateServerFactory(
+ static std::unique_ptr<ChannelFactory> CreateServerFactory(
mojo::ScopedMessagePipeHandle handle);
- static scoped_ptr<ChannelFactory> CreateClientFactory(
+ static std::unique_ptr<ChannelFactory> CreateClientFactory(
mojo::ScopedMessagePipeHandle handle);
~ChannelMojo() override;
@@ -107,13 +106,13 @@
scoped_refptr<base::TaskRunner> task_runner_;
const mojo::MessagePipeHandle pipe_;
- scoped_ptr<MojoBootstrap> bootstrap_;
+ std::unique_ptr<MojoBootstrap> bootstrap_;
Listener* listener_;
// Guards access to the fields below.
mutable base::Lock lock_;
- scoped_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_;
- std::vector<scoped_ptr<Message>> pending_messages_;
+ std::unique_ptr<internal::MessagePipeReader, ReaderDeleter> message_reader_;
+ std::vector<std::unique_ptr<Message>> pending_messages_;
bool waiting_connect_;
base::WeakPtrFactory<ChannelMojo> weak_factory_;
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index 615e72d..4310e50 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <utility>
#include "base/base_paths.h"
@@ -118,7 +119,7 @@
private:
base::MessageLoopForIO main_message_loop_;
mojo::ScopedMessagePipeHandle handle_;
- scoped_ptr<IPC::ChannelMojo> channel_;
+ std::unique_ptr<IPC::ChannelMojo> channel_;
};
class IPCChannelMojoTest : public testing::Test {
@@ -150,7 +151,7 @@
base::TestIOThread io_thread_;
mojo::edk::test::MultiprocessTestHelper helper_;
mojo::ScopedMessagePipeHandle handle_;
- scoped_ptr<IPC::Channel> channel_;
+ std::unique_ptr<IPC::Channel> channel_;
};
class TestChannelListenerWithExtraExpectations
@@ -516,7 +517,7 @@
TestingMessagePipe pipe;
- scoped_ptr<IPC::Message> message(new IPC::Message());
+ std::unique_ptr<IPC::Message> message(new IPC::Message());
IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(),
pipe.peer.release());
WriteOK(pipe.self.get());
@@ -548,7 +549,7 @@
ASSERT_TRUE(ConnectChannel());
mojo::MessagePipeHandle invalid_handle;
- scoped_ptr<IPC::Message> message(new IPC::Message());
+ std::unique_ptr<IPC::Message> message(new IPC::Message());
IPC::ParamTraits<mojo::MessagePipeHandle>::Write(message.get(),
invalid_handle);
diff --git a/ipc/mojo/ipc_message_pipe_reader.cc b/ipc/mojo/ipc_message_pipe_reader.cc
index b657bfdc..de5726d 100644
--- a/ipc/mojo/ipc_message_pipe_reader.cc
+++ b/ipc/mojo/ipc_message_pipe_reader.cc
@@ -83,7 +83,7 @@
binding_.Close();
}
-bool MessagePipeReader::Send(scoped_ptr<Message> message) {
+bool MessagePipeReader::Send(std::unique_ptr<Message> message) {
TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"),
"MessagePipeReader::Send",
message->flags(),
diff --git a/ipc/mojo/ipc_message_pipe_reader.h b/ipc/mojo/ipc_message_pipe_reader.h
index d2ba9de..661ffde 100644
--- a/ipc/mojo/ipc_message_pipe_reader.h
+++ b/ipc/mojo/ipc_message_pipe_reader.h
@@ -13,7 +13,6 @@
#include "base/atomicops.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "ipc/ipc_message.h"
#include "ipc/mojo/ipc.mojom.h"
@@ -90,7 +89,7 @@
// Sends an IPC::Message to the other end of the pipe. Safe to call from any
// thread.
- bool Send(scoped_ptr<Message> message);
+ bool Send(std::unique_ptr<Message> message);
base::ProcessId GetPeerPid() const { return peer_pid_; }
diff --git a/ipc/mojo/ipc_mojo_bootstrap.cc b/ipc/mojo/ipc_mojo_bootstrap.cc
index a80b461..9188323 100644
--- a/ipc/mojo/ipc_mojo_bootstrap.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/process/process_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_message_utils.h"
@@ -125,15 +126,15 @@
// MojoBootstrap
// static
-scoped_ptr<MojoBootstrap> MojoBootstrap::Create(
+std::unique_ptr<MojoBootstrap> MojoBootstrap::Create(
mojo::ScopedMessagePipeHandle handle,
Channel::Mode mode,
Delegate* delegate) {
CHECK(mode == Channel::MODE_CLIENT || mode == Channel::MODE_SERVER);
- scoped_ptr<MojoBootstrap> self =
+ std::unique_ptr<MojoBootstrap> self =
mode == Channel::MODE_CLIENT
- ? scoped_ptr<MojoBootstrap>(new MojoClientBootstrap())
- : scoped_ptr<MojoBootstrap>(new MojoServerBootstrap());
+ ? std::unique_ptr<MojoBootstrap>(new MojoClientBootstrap)
+ : std::unique_ptr<MojoBootstrap>(new MojoServerBootstrap);
self->Init(std::move(handle), delegate);
return self;
diff --git a/ipc/mojo/ipc_mojo_bootstrap.h b/ipc/mojo/ipc_mojo_bootstrap.h
index 23e0e91..e7769ec 100644
--- a/ipc/mojo/ipc_mojo_bootstrap.h
+++ b/ipc/mojo/ipc_mojo_bootstrap.h
@@ -7,8 +7,9 @@
#include <stdint.h>
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/process/process_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
@@ -40,9 +41,10 @@
// Create the MojoBootstrap instance, using |handle| as the message pipe, in
// mode as specified by |mode|. The result is passed to |delegate|.
- static scoped_ptr<MojoBootstrap> Create(mojo::ScopedMessagePipeHandle handle,
- Channel::Mode mode,
- Delegate* delegate);
+ static std::unique_ptr<MojoBootstrap> Create(
+ mojo::ScopedMessagePipeHandle handle,
+ Channel::Mode mode,
+ Delegate* delegate);
MojoBootstrap();
virtual ~MojoBootstrap();
diff --git a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
index d702a6a..dcf68bd 100644
--- a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
@@ -5,6 +5,7 @@
#include "ipc/mojo/ipc_mojo_bootstrap.h"
#include <stdint.h>
+#include <memory>
#include "base/base_paths.h"
#include "base/files/file.h"
@@ -68,7 +69,7 @@
base::MessageLoop message_loop;
base::RunLoop run_loop;
TestingDelegate delegate(run_loop.QuitClosure());
- scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
+ std::unique_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
helper_.StartChild("IPCMojoBootstrapTestClient"),
IPC::Channel::MODE_SERVER, &delegate);
@@ -86,7 +87,7 @@
base::MessageLoop message_loop;
base::RunLoop run_loop;
TestingDelegate delegate(run_loop.QuitClosure());
- scoped_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
+ std::unique_ptr<IPC::MojoBootstrap> bootstrap = IPC::MojoBootstrap::Create(
mojo::edk::CreateChildMessagePipe(
mojo::edk::test::MultiprocessTestHelper::primordial_pipe_token),
IPC::Channel::MODE_CLIENT, &delegate);
diff --git a/ipc/mojo/ipc_mojo_perftest.cc b/ipc/mojo/ipc_mojo_perftest.cc
index b1c6c86..083bb08 100644
--- a/ipc/mojo/ipc_mojo_perftest.cc
+++ b/ipc/mojo/ipc_mojo_perftest.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include <stddef.h>
+#include <memory>
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/thread_task_runner_handle.h"
#include "build/build_config.h"
@@ -24,7 +26,7 @@
test::IPCChannelPerfTestBase::TearDown();
}
- scoped_ptr<ChannelFactory> CreateChannelFactory(
+ std::unique_ptr<ChannelFactory> CreateChannelFactory(
const ChannelHandle& handle,
base::SequencedTaskRunner* runner) override {
ipc_support_.reset(new mojo::edk::test::ScopedIPCSupport(io_task_runner()));
@@ -41,7 +43,7 @@
}
mojo::edk::test::MultiprocessTestHelper helper_;
- scoped_ptr<mojo::edk::test::ScopedIPCSupport> ipc_support_;
+ std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipc_support_;
};
TEST_F(MojoChannelPerfTest, ChannelPingPong) {
@@ -78,7 +80,7 @@
MojoPerfTestClient();
- scoped_ptr<Channel> CreateChannel(Listener* listener) override;
+ std::unique_ptr<Channel> CreateChannel(Listener* listener) override;
int Run(MojoHandle handle);
@@ -92,9 +94,9 @@
mojo::edk::test::MultiprocessTestHelper::ChildSetup();
}
-scoped_ptr<Channel> MojoPerfTestClient::CreateChannel(Listener* listener) {
- return scoped_ptr<Channel>(
- ChannelMojo::Create(std::move(handle_), Channel::MODE_CLIENT, listener));
+std::unique_ptr<Channel> MojoPerfTestClient::CreateChannel(Listener* listener) {
+ return ChannelMojo::Create(std::move(handle_), Channel::MODE_CLIENT,
+ listener);
}
int MojoPerfTestClient::Run(MojoHandle handle) {
diff --git a/ipc/sync_socket_unittest.cc b/ipc/sync_socket_unittest.cc
index 89c155b..7c83b24 100644
--- a/ipc/sync_socket_unittest.cc
+++ b/ipc/sync_socket_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdio.h>
+#include <memory>
#include <sstream>
#include <string>
@@ -110,7 +111,7 @@
MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) {
base::MessageLoopForIO main_message_loop;
SyncSocketServerListener listener;
- scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
+ std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
IPCTestBase::GetChannelName("SyncSocketServerClient"), &listener));
EXPECT_TRUE(channel->Connect());
listener.Init(channel.get());
diff --git a/ipc/unix_domain_socket_util_unittest.cc b/ipc/unix_domain_socket_util_unittest.cc
index 2ba8cfe..3fa44546 100644
--- a/ipc/unix_domain_socket_util_unittest.cc
+++ b/ipc/unix_domain_socket_util_unittest.cc
@@ -2,21 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ipc/unix_domain_socket_util.h"
+
#include <stddef.h>
#include <sys/socket.h>
+#include <memory>
+
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
-#include "ipc/unix_domain_socket_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -75,7 +77,7 @@
int server_fd_;
base::SingleThreadTaskRunner* target_thread_;
- scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> watcher_;
+ std::unique_ptr<base::MessageLoopForIO::FileDescriptorWatcher> watcher_;
base::WaitableEvent started_watching_event_;
base::WaitableEvent accepted_event_;
@@ -144,7 +146,7 @@
int server_listen_fd_;
int server_fd_;
int client_fd_;
- scoped_ptr<SocketAcceptor> acceptor_;
+ std::unique_ptr<SocketAcceptor> acceptor_;
};
// Ensure that IPC::CreateServerUnixDomainSocket creates a socket that