summaryrefslogtreecommitdiff
path: root/chromium/ipc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/ipc
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ipc')
-rw-r--r--chromium/ipc/BUILD.gn13
-rw-r--r--chromium/ipc/DEPS1
-rw-r--r--chromium/ipc/attachment_broker_mac_unittest.cc64
-rw-r--r--chromium/ipc/attachment_broker_privileged.cc11
-rw-r--r--chromium/ipc/attachment_broker_privileged.h1
-rw-r--r--chromium/ipc/attachment_broker_privileged_mac.cc39
-rw-r--r--chromium/ipc/attachment_broker_privileged_mac_unittest.cc27
-rw-r--r--chromium/ipc/attachment_broker_privileged_win_unittest.cc14
-rw-r--r--chromium/ipc/attachment_broker_unprivileged.cc13
-rw-r--r--chromium/ipc/attachment_broker_unprivileged.h1
-rw-r--r--chromium/ipc/ipc.gyp5
-rw-r--r--chromium/ipc/ipc_channel.h21
-rw-r--r--chromium/ipc/ipc_channel_common.cc10
-rw-r--r--chromium/ipc/ipc_channel_factory.cc10
-rw-r--r--chromium/ipc/ipc_channel_factory.h8
-rw-r--r--chromium/ipc/ipc_channel_nacl.cc27
-rw-r--r--chromium/ipc/ipc_channel_nacl.h8
-rw-r--r--chromium/ipc/ipc_channel_posix.cc25
-rw-r--r--chromium/ipc/ipc_channel_posix_unittest.cc79
-rw-r--r--chromium/ipc/ipc_channel_proxy.cc26
-rw-r--r--chromium/ipc/ipc_channel_proxy.h18
-rw-r--r--chromium/ipc/ipc_channel_proxy_unittest.cc30
-rw-r--r--chromium/ipc/ipc_channel_reader.cc2
-rw-r--r--chromium/ipc/ipc_channel_reader_unittest.cc3
-rw-r--r--chromium/ipc/ipc_channel_unittest.cc3
-rw-r--r--chromium/ipc/ipc_channel_win.cc22
-rw-r--r--chromium/ipc/ipc_channel_win.h11
-rw-r--r--chromium/ipc/ipc_fuzzing_tests.cc24
-rw-r--r--chromium/ipc/ipc_logging.cc2
-rw-r--r--chromium/ipc/ipc_logging.h1
-rw-r--r--chromium/ipc/ipc_message.cc3
-rw-r--r--chromium/ipc/ipc_message_attachment_set_posix_unittest.cc2
-rw-r--r--chromium/ipc/ipc_message_start.h4
-rw-r--r--chromium/ipc/ipc_message_unittest.cc6
-rw-r--r--chromium/ipc/ipc_message_utils.cc128
-rw-r--r--chromium/ipc/ipc_message_utils.h9
-rw-r--r--chromium/ipc/ipc_message_utils_unittest.cc7
-rw-r--r--chromium/ipc/ipc_perftest_support.cc13
-rw-r--r--chromium/ipc/ipc_perftest_support.h11
-rw-r--r--chromium/ipc/ipc_send_fds_test.cc37
-rw-r--r--chromium/ipc/ipc_sync_channel.cc18
-rw-r--r--chromium/ipc/ipc_sync_channel.h9
-rw-r--r--chromium/ipc/ipc_sync_channel_unittest.cc18
-rw-r--r--chromium/ipc/ipc_sync_message.h5
-rw-r--r--chromium/ipc/ipc_sync_message_filter.cc2
-rw-r--r--chromium/ipc/ipc_test_base.cc19
-rw-r--r--chromium/ipc/ipc_test_base.h19
-rw-r--r--chromium/ipc/mach_port_mac.cc6
-rw-r--r--chromium/ipc/mach_port_mac.h1
-rw-r--r--chromium/ipc/mojo/ipc_channel_mojo.cc57
-rw-r--r--chromium/ipc/mojo/ipc_channel_mojo.h17
-rw-r--r--chromium/ipc/mojo/ipc_channel_mojo_unittest.cc75
-rw-r--r--chromium/ipc/mojo/ipc_message_pipe_reader.cc15
-rw-r--r--chromium/ipc/mojo/ipc_message_pipe_reader.h3
-rw-r--r--chromium/ipc/mojo/ipc_mojo.gyp19
-rw-r--r--chromium/ipc/mojo/ipc_mojo_bootstrap.cc9
-rw-r--r--chromium/ipc/mojo/ipc_mojo_bootstrap.h10
-rw-r--r--chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc15
-rw-r--r--chromium/ipc/mojo/ipc_mojo_perftest.cc16
-rw-r--r--chromium/ipc/mojo/ipc_mojo_unittests.isolate23
-rw-r--r--chromium/ipc/mojo/run_all_unittests.cc5
-rw-r--r--chromium/ipc/run_all_unittests.cc3
-rw-r--r--chromium/ipc/sync_socket_unittest.cc17
-rw-r--r--chromium/ipc/unix_domain_socket_util_unittest.cc10
64 files changed, 558 insertions, 572 deletions
diff --git a/chromium/ipc/BUILD.gn b/chromium/ipc/BUILD.gn
index c3d3bb45b10..87587ec0942 100644
--- a/chromium/ipc/BUILD.gn
+++ b/chromium/ipc/BUILD.gn
@@ -4,6 +4,7 @@
import("//build/config/nacl/config.gni")
import("//testing/test.gni")
+import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
component("ipc") {
sources = [
@@ -118,7 +119,7 @@ component("ipc") {
]
}
- if (is_win || is_ios || is_nacl_nonsfi) {
+ if (is_win || is_nacl_nonsfi) {
sources -= [ "unix_domain_socket_util.cc" ]
}
@@ -139,6 +140,10 @@ component("ipc") {
# On Mac MachPortAttachmentMac needs to generate random IDs.
deps += [ "//crypto" ]
}
+
+ if (enable_ipc_fuzzer) {
+ public_configs = [ "//tools/ipc_fuzzer:ipc_fuzzer_config" ]
+ }
}
# This is provided as a separate target so other targets can provide param
@@ -169,6 +174,7 @@ test("ipc_tests") {
"ipc_test_message_generator.cc",
"ipc_test_message_generator.h",
"ipc_test_messages.h",
+ "run_all_unittests.cc",
"sync_socket_unittest.cc",
"unix_domain_socket_util_unittest.cc",
]
@@ -192,11 +198,14 @@ test("ipc_tests") {
":test_support",
"//base",
"//base:i18n",
- "//base/test:run_all_unittests",
"//base/test:test_support",
"//crypto",
"//testing/gtest",
]
+
+ if (is_mac) {
+ deps += [ "//sandbox/mac:seatbelt" ]
+ }
}
test("ipc_perftests") {
diff --git a/chromium/ipc/DEPS b/chromium/ipc/DEPS
index 1c97fa3433f..b8caf57633e 100644
--- a/chromium/ipc/DEPS
+++ b/chromium/ipc/DEPS
@@ -2,4 +2,5 @@ include_rules = [
"+crypto",
# For ipc_channel_nacl.cc:
"+native_client/src/public",
+ "+sandbox/mac/seatbelt.h",
]
diff --git a/chromium/ipc/attachment_broker_mac_unittest.cc b/chromium/ipc/attachment_broker_mac_unittest.cc
index b569706ef8b..3be3d4397d6 100644
--- a/chromium/ipc/attachment_broker_mac_unittest.cc
+++ b/chromium/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 @@ base::mac::ScopedMachSendRight GetMachPortFromBrokeredAttachment(
}
// 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 @@ bool GetSharedMemoryHandlesFromMsg2(const IPC::Message& message,
}
// 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 @@ scoped_ptr<base::SharedMemory> MapSharedMemoryHandle(
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 @@ scoped_ptr<base::SharedMemory> MapSharedMemoryHandle(
// 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 @@ bool CheckContentsOfFileDescriptor(const base::FileDescriptor& file_descriptor,
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 @@ bool CheckContentsOfTwoEquivalentSharedMemoryHandles(
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()) !=
@@ -479,7 +480,8 @@ class IPCAttachmentBrokerMacTest : public IPCTestBase {
// 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);
@@ -496,7 +498,7 @@ class IPCAttachmentBrokerMacTest : public IPCTestBase {
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
@@ -521,7 +523,7 @@ struct ChildProcessGlobals {
// 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.
@@ -537,7 +539,7 @@ using OnMessageReceivedCallback = void (*)(IPC::Sender* sender,
// 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);
@@ -553,7 +555,7 @@ scoped_ptr<ChildProcessGlobals> CommonChildProcessSetUp() {
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());
@@ -565,14 +567,14 @@ scoped_ptr<ChildProcessGlobals> CommonChildProcessSetUp() {
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());
@@ -689,7 +691,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendTwoMessagesSameSharedMemoryHandle) {
CommonSetUp("SendTwoMessagesSameSharedMemoryHandle");
{
- scoped_ptr<base::SharedMemory> shared_memory(
+ std::unique_ptr<base::SharedMemory> shared_memory(
MakeSharedMemory(kDataBuffer1));
for (int i = 0; i < 2; ++i) {
@@ -735,9 +737,9 @@ TEST_F(IPCAttachmentBrokerMacTest,
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());
@@ -778,7 +780,7 @@ TEST_F(IPCAttachmentBrokerMacTest,
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());
@@ -823,9 +825,9 @@ TEST_F(IPCAttachmentBrokerMacTest, SendPosixFDAndMachPort) {
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(
@@ -887,7 +889,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleToSelf) {
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);
@@ -942,7 +944,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleChannelProxy) {
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;
@@ -995,7 +997,7 @@ TEST_F(IPCAttachmentBrokerMacTest, ShareToProcess) {
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));
@@ -1025,7 +1027,7 @@ TEST_F(IPCAttachmentBrokerMacTest, ShareReadOnlyToProcess) {
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));
@@ -1044,12 +1046,12 @@ void ShareReadOnlyToProcessCallback(IPC::Sender* sender,
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(),
@@ -1080,7 +1082,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleToSelfDelayedPort) {
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);
@@ -1182,7 +1184,7 @@ void MemoryUsageLargeMessageCallback(IPC::Sender* sender,
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);
@@ -1245,7 +1247,7 @@ void MemoryUsageManyMessagesCallback(IPC::Sender* sender,
// 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/chromium/ipc/attachment_broker_privileged.cc b/chromium/ipc/attachment_broker_privileged.cc
index 9f41892f721..8da461b265b 100644
--- a/chromium/ipc/attachment_broker_privileged.cc
+++ b/chromium/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 @@ base::PortProvider* g_port_provider = nullptr;
// 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 @@ class AttachmentBrokerMakeOnce {
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/chromium/ipc/attachment_broker_privileged.h b/chromium/ipc/attachment_broker_privileged.h
index d6e4c2c516c..36069c11f39 100644
--- a/chromium/ipc/attachment_broker_privileged.h
+++ b/chromium/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/chromium/ipc/attachment_broker_privileged_mac.cc b/chromium/ipc/attachment_broker_privileged_mac.cc
index b80283bb45f..8c6b556f43b 100644
--- a/chromium/ipc/attachment_broker_privileged_mac.cc
+++ b/chromium/ipc/attachment_broker_privileged_mac.cc
@@ -200,6 +200,9 @@ bool AttachmentBrokerPrivilegedMac::RouteWireFormatToAnother(
base::mac::ScopedMachSendRight AttachmentBrokerPrivilegedMac::ExtractNamedRight(
mach_port_t task_port,
mach_port_name_t named_right) {
+ if (named_right == MACH_PORT_NULL)
+ return base::mac::ScopedMachSendRight(MACH_PORT_NULL);
+
mach_port_t extracted_right = MACH_PORT_NULL;
mach_msg_type_name_t extracted_right_type;
kern_return_t kr =
@@ -240,15 +243,14 @@ void AttachmentBrokerPrivilegedMac::SendPrecursorsForProcess(
AttachmentBrokerPrivileged::EndpointRunnerPair pair =
GetSenderWithProcessId(pid);
if (!pair.first) {
- if (store_on_failure) {
- // Try again later.
- LogError(DELAYED);
- } else {
- // If there is no sender, then permanently fail.
- LogError(DESTINATION_NOT_FOUND);
- delete it->second;
- precursors_.erase(it);
- }
+ // Try again later.
+ if (store_on_failure)
+ return;
+
+ // If there is no sender, then permanently fail.
+ LogError(DESTINATION_NOT_FOUND);
+ delete it->second;
+ precursors_.erase(it);
return;
}
}
@@ -337,16 +339,15 @@ void AttachmentBrokerPrivilegedMac::ProcessExtractorsForProcess(
AttachmentBrokerPrivileged::EndpointRunnerPair pair =
GetSenderWithProcessId(pid);
if (!pair.first) {
- if (store_on_failure) {
- // If there is no sender, then the communication channel with the source
- // process has not yet been established. Try again later.
- LogError(DELAYED);
- } else {
- // There is no sender. Permanently fail.
- LogError(ERROR_SOURCE_NOT_FOUND);
- delete it->second;
- extractors_.erase(it);
- }
+ // If there is no sender, then the communication channel with the source
+ // process has not yet been established. Try again later.
+ if (store_on_failure)
+ return;
+
+ // There is no sender. Permanently fail.
+ LogError(ERROR_SOURCE_NOT_FOUND);
+ delete it->second;
+ extractors_.erase(it);
return;
}
}
diff --git a/chromium/ipc/attachment_broker_privileged_mac_unittest.cc b/chromium/ipc/attachment_broker_privileged_mac_unittest.cc
index 53981943bba..330db03af96 100644
--- a/chromium/ipc/attachment_broker_privileged_mac_unittest.cc
+++ b/chromium/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 @@ base::mac::ScopedMachReceiveRight CommonChildProcessSetUp(
}
// 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 @@ scoped_ptr<base::SharedMemory> CreateAndPopulateSharedMemoryHandle(
// 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 @@ TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertRight) {
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 @@ MULTIPROCESS_TEST_MAIN(InsertRightClient) {
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 @@ TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertSameRightTwice) {
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 @@ MULTIPROCESS_TEST_MAIN(InsertSameRightTwiceClient) {
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 @@ MULTIPROCESS_TEST_MAIN(InsertSameRightTwiceClient) {
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 @@ TEST_F(AttachmentBrokerPrivilegedMacMultiProcessTest, InsertTwoRights) {
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 @@ MULTIPROCESS_TEST_MAIN(InsertTwoRightsClient) {
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 @@ MULTIPROCESS_TEST_MAIN(InsertTwoRightsClient) {
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/chromium/ipc/attachment_broker_privileged_win_unittest.cc b/chromium/ipc/attachment_broker_privileged_win_unittest.cc
index 36a7c68e175..3c8df8e8064 100644
--- a/chromium/ipc/attachment_broker_privileged_win_unittest.cc
+++ b/chromium/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 @@ ScopedHandle GetHandleFromTestHandleWinMsg(const IPC::Message& message) {
}
// 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 @@ scoped_ptr<base::SharedMemory> GetSharedMemoryFromSharedMemoryHandleMsg1(
}
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);
@@ -323,7 +323,7 @@ class IPCAttachmentBrokerPrivilegedWinTest : public IPCTestBase {
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_;
};
@@ -491,7 +491,7 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendSharedMemoryHandle) {
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()));
@@ -516,7 +516,7 @@ int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback,
// 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());
@@ -651,7 +651,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendHandleTwice) {
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/chromium/ipc/attachment_broker_unprivileged.cc b/chromium/ipc/attachment_broker_unprivileged.cc
index c1e4c4ac7c1..ad7c7171fa2 100644
--- a/chromium/ipc/attachment_broker_unprivileged.cc
+++ b/chromium/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 @@ namespace {
// 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 @@ class AttachmentBrokerMakeOnce {
}
private:
- scoped_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_;
+ std::unique_ptr<IPC::AttachmentBrokerUnprivileged> attachment_broker_;
};
base::LazyInstance<AttachmentBrokerMakeOnce>::Leaky
diff --git a/chromium/ipc/attachment_broker_unprivileged.h b/chromium/ipc/attachment_broker_unprivileged.h
index f6d520de6e3..d66a693928f 100644
--- a/chromium/ipc/attachment_broker_unprivileged.h
+++ b/chromium/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/chromium/ipc/ipc.gyp b/chromium/ipc/ipc.gyp
index b78bbf1674b..a11ffe3e0bd 100644
--- a/chromium/ipc/ipc.gyp
+++ b/chromium/ipc/ipc.gyp
@@ -89,6 +89,11 @@
'../testing/android/native_test.gyp:native_test_native_code',
],
}],
+ ['OS == "mac"', {
+ 'dependencies': [
+ '../sandbox/sandbox.gyp:seatbelt',
+ ],
+ }],
],
},
{
diff --git a/chromium/ipc/ipc_channel.h b/chromium/ipc/ipc_channel.h
index a008e7e15d5..fdd0b352964 100644
--- a/chromium/ipc/ipc_channel.h
+++ b/chromium/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 @@ class IPC_EXPORT Channel : public Endpoint {
// 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 @@ class IPC_EXPORT Channel : public Endpoint {
// 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);
@@ -254,7 +255,7 @@ class IPC_EXPORT Channel : public Endpoint {
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/chromium/ipc/ipc_channel_common.cc b/chromium/ipc/ipc_channel_common.cc
index 69abc3412b7..b5dcb1ab4bf 100644
--- a/chromium/ipc/ipc_channel_common.cc
+++ b/chromium/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 @@ scoped_ptr<Channel> Channel::CreateNamedClient(
#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 @@ scoped_ptr<Channel> Channel::CreateOpenNamedServer(
#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/chromium/ipc/ipc_channel_factory.cc b/chromium/ipc/ipc_channel_factory.cc
index 6dda14d273c..746b19a3844 100644
--- a/chromium/ipc/ipc_channel_factory.cc
+++ b/chromium/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 @@ class PlatformChannelFactory : public ChannelFactory {
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 @@ class PlatformChannelFactory : public ChannelFactory {
} // 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/chromium/ipc/ipc_channel_factory.h b/chromium/ipc/ipc_channel_factory.h
index 4c8569cf9de..3b6ae87bdf0 100644
--- a/chromium/ipc/ipc_channel_factory.h
+++ b/chromium/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 @@ class IPC_EXPORT ChannelFactory {
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/chromium/ipc/ipc_channel_nacl.cc b/chromium/ipc/ipc_channel_nacl.cc
index 3515202182c..34fd30287f5 100644
--- a/chromium/ipc/ipc_channel_nacl.cc
+++ b/chromium/ipc/ipc_channel_nacl.cc
@@ -14,11 +14,12 @@
#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"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/simple_thread.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_message_attachment_set.h"
@@ -77,7 +78,7 @@ class ChannelNacl::ReaderThreadRunner
// 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 @@ class ChannelNacl::ReaderThreadRunner
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 @@ class ChannelNacl::ReaderThreadRunner
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(
@@ -208,7 +208,7 @@ bool ChannelNacl::Send(Message* message) {
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(), "");
@@ -229,7 +229,7 @@ AttachmentBroker* ChannelNacl::GetAttachmentBroker() {
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)
@@ -399,10 +399,11 @@ bool ChannelNacl::IsAttachmentBrokerEndpoint() {
// 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/chromium/ipc/ipc_channel_nacl.h b/chromium/ipc/ipc_channel_nacl.h
index 0fcf85af829..06dc0be4d47 100644
--- a/chromium/ipc/ipc_channel_nacl.h
+++ b/chromium/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 @@ class ChannelNacl : public Channel,
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 @@ class ChannelNacl : public Channel,
// 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/chromium/ipc/ipc_channel_posix.cc b/chromium/ipc/ipc_channel_posix.cc
index 3bdf82bef3f..df7a7589465 100644
--- a/chromium/ipc/ipc_channel_posix.cc
+++ b/chromium/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"
@@ -822,9 +825,8 @@ int ChannelPosix::GetHelloMessageProcId() const {
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";
}
@@ -978,9 +980,9 @@ void ChannelPosix::QueueCloseFDMessage(int fd, int hops) {
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.";
}
@@ -1109,10 +1111,11 @@ void ChannelPosix::ResetSafely(base::ScopedFD* fd) {
// 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/chromium/ipc/ipc_channel_posix_unittest.cc b/chromium/ipc/ipc_channel_posix_unittest.cc
index 29f0d392d69..0ed66797aa1 100644
--- a/chromium/ipc/ipc_channel_posix_unittest.cc
+++ b/chromium/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"
@@ -113,12 +114,21 @@ class IPCChannelPosixTest : public base::MultiProcessTest {
static const std::string GetConnectionSocketName();
static const std::string GetChannelDirName();
+ bool WaitForExit(base::Process& process, int* exit_code) {
+#if defined(OS_ANDROID)
+ return AndroidWaitForChildExitWithTimeout(
+ process, base::TimeDelta::Max(), exit_code);
+#else
+ return process.WaitForExit(exit_code);
+#endif // defined(OS_ANDROID)
+ }
+
protected:
void SetUp() override;
void TearDown() override;
private:
- scoped_ptr<base::MessageLoopForIO> message_loop_;
+ std::unique_ptr<base::MessageLoopForIO> message_loop_;
};
const std::string IPCChannelPosixTest::GetChannelDirName() {
@@ -178,7 +188,7 @@ TEST_F(IPCChannelPosixTest, BasicListen) {
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 +207,7 @@ TEST_F(IPCChannelPosixTest, BasicConnected) {
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 +216,7 @@ TEST_F(IPCChannelPosixTest, BasicConnected) {
// 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 +229,11 @@ TEST_F(IPCChannelPosixTest, SendHangTest) {
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 +254,11 @@ TEST_F(IPCChannelPosixTest, AcceptHangTest) {
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.
@@ -257,17 +267,12 @@ TEST_F(IPCChannelPosixTest, AcceptHangTest) {
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, out_listener.status());
}
-#if defined(OS_ANDROID)
-#define MAYBE_AdvancedConnected DISABLED_AdvancedConnected
-#else
-#define MAYBE_AdvancedConnected AdvancedConnected
-#endif
-TEST_F(IPCChannelPosixTest, MAYBE_AdvancedConnected) {
+TEST_F(IPCChannelPosixTest, AdvancedConnected) {
// Test creating a connection to an external process.
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());
@@ -284,26 +289,21 @@ TEST_F(IPCChannelPosixTest, MAYBE_AdvancedConnected) {
channel->Send(message);
SpinRunLoop(TestTimeouts::action_timeout());
int exit_code = 0;
- EXPECT_TRUE(process.WaitForExit(&exit_code));
+ EXPECT_TRUE(WaitForExit(process, &exit_code));
EXPECT_EQ(0, exit_code);
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
ASSERT_FALSE(channel->HasAcceptedConnection());
unlink(chan_handle.name.c_str());
}
-#if defined(OS_ANDROID)
-#define MAYBE_ResetState DISABLED_ResetState
-#else
-#define MAYBE_ResetState ResetState
-#endif
-TEST_F(IPCChannelPosixTest, MAYBE_ResetState) {
+TEST_F(IPCChannelPosixTest, ResetState) {
// Test creating a connection to an external process. Close the connection,
// but continue to listen and make sure another external process can connect
// to us.
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());
@@ -329,7 +329,7 @@ TEST_F(IPCChannelPosixTest, MAYBE_ResetState) {
SpinRunLoop(TestTimeouts::action_timeout());
EXPECT_TRUE(process.Terminate(0, false));
int exit_code = 0;
- EXPECT_TRUE(process2.WaitForExit(&exit_code));
+ EXPECT_TRUE(WaitForExit(process2, &exit_code));
EXPECT_EQ(0, exit_code);
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -339,7 +339,7 @@ TEST_F(IPCChannelPosixTest, MAYBE_ResetState) {
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,23 +353,18 @@ TEST_F(IPCChannelPosixTest, BadChannelName) {
"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());
}
-#if defined(OS_ANDROID)
-#define MAYBE_MultiConnection DISABLED_MultiConnection
-#else
-#define MAYBE_MultiConnection MultiConnection
-#endif
-TEST_F(IPCChannelPosixTest, MAYBE_MultiConnection) {
+TEST_F(IPCChannelPosixTest, MultiConnection) {
// Test setting up a connection to an external process, and then have
// another external process attempt to connect to us.
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());
@@ -384,7 +379,7 @@ TEST_F(IPCChannelPosixTest, MAYBE_MultiConnection) {
ASSERT_TRUE(process2.IsValid());
SpinRunLoop(TestTimeouts::action_max_timeout());
int exit_code = 0;
- EXPECT_TRUE(process2.WaitForExit(&exit_code));
+ EXPECT_TRUE(WaitForExit(process2, &exit_code));
EXPECT_EQ(exit_code, 0);
ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status());
ASSERT_TRUE(channel->HasAcceptedConnection());
@@ -393,7 +388,7 @@ TEST_F(IPCChannelPosixTest, MAYBE_MultiConnection) {
IPC::Message::PRIORITY_NORMAL);
channel->Send(message);
SpinRunLoop(TestTimeouts::action_timeout());
- EXPECT_TRUE(process.WaitForExit(&exit_code));
+ EXPECT_TRUE(WaitForExit(process, &exit_code));
EXPECT_EQ(exit_code, 0);
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -405,9 +400,9 @@ TEST_F(IPCChannelPosixTest, DoubleServer) {
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 +412,7 @@ TEST_F(IPCChannelPosixTest, BadMode) {
// 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 +424,7 @@ TEST_F(IPCChannelPosixTest, IsNamedServerInitialized) {
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 +440,7 @@ MULTIPROCESS_TEST_MAIN(IPCChannelPosixTestConnectionProc) {
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 +454,7 @@ MULTIPROCESS_TEST_MAIN(IPCChannelPosixFailConnectionProc) {
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/chromium/ipc/ipc_channel_proxy.cc b/chromium/ipc/ipc_channel_proxy.cc
index 2ebc9040a1e..b3424124158 100644
--- a/chromium/ipc/ipc_channel_proxy.cc
+++ b/chromium/ipc/ipc_channel_proxy.cc
@@ -6,16 +6,17 @@
#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"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_factory.h"
#include "ipc/ipc_listener.h"
@@ -58,7 +59,8 @@ void ChannelProxy::Context::ClearIPCTaskRunner() {
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 @@ void ChannelProxy::Context::Clear() {
}
// 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 @@ void ChannelProxy::Context::Send(Message* message) {
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 @@ bool ChannelProxy::Context::IsChannelSendThreadSafe() const {
//-----------------------------------------------------------------------------
// 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 @@ void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
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/chromium/ipc/ipc_channel_proxy.h b/chromium/ipc/ipc_channel_proxy.h
index 495c5eb8a52..0c932330409 100644
--- a/chromium/ipc/ipc_channel_proxy.h
+++ b/chromium/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 @@ class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
// 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);
@@ -111,7 +111,7 @@ class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
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
@@ -216,7 +216,7 @@ class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
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;
@@ -225,7 +225,7 @@ class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
}
// 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);
@@ -249,7 +249,7 @@ class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
// 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_;
@@ -262,7 +262,7 @@ class IPC_EXPORT ChannelProxy : public Endpoint, public base::NonThreadSafe {
// 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/chromium/ipc/ipc_channel_proxy_unittest.cc b/chromium/ipc/ipc_channel_proxy_unittest.cc
index f7f832b1445..5367157ec40 100644
--- a/chromium/ipc/ipc_channel_proxy_unittest.cc
+++ b/chromium/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,16 +269,11 @@ class IPCChannelProxyTest : public IPCTestBase {
}
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)
-#define MAYBE_MessageClassFilters DISABLED_MessageClassFilters
-#else
-#define MAYBE_MessageClassFilters MessageClassFilters
-#endif
-TEST_F(IPCChannelProxyTest, MAYBE_MessageClassFilters) {
+TEST_F(IPCChannelProxyTest, MessageClassFilters) {
// Construct a filter per message class.
std::vector<scoped_refptr<MessageCountFilter> > class_filters;
class_filters.push_back(make_scoped_refptr(
@@ -301,12 +297,7 @@ TEST_F(IPCChannelProxyTest, MAYBE_MessageClassFilters) {
EXPECT_EQ(1U, class_filters[i]->messages_received());
}
-#if defined(OS_ANDROID)
-#define MAYBE_GlobalAndMessageClassFilters DISABLED_GlobalAndMessageClassFilters
-#else
-#define MAYBE_GlobalAndMessageClassFilters GlobalAndMessageClassFilters
-#endif
-TEST_F(IPCChannelProxyTest, MAYBE_GlobalAndMessageClassFilters) {
+TEST_F(IPCChannelProxyTest, GlobalAndMessageClassFilters) {
// Add a class and global filter.
scoped_refptr<MessageCountFilter> class_filter(
new MessageCountFilter(TestMsgStart));
@@ -335,12 +326,7 @@ TEST_F(IPCChannelProxyTest, MAYBE_GlobalAndMessageClassFilters) {
EXPECT_EQ(3U, global_filter->messages_received());
}
-#if defined(OS_ANDROID)
-#define MAYBE_FilterRemoval DISABLED_FilterRemoval
-#else
-#define MAYBE_FilterRemoval FilterRemoval
-#endif
-TEST_F(IPCChannelProxyTest, MAYBE_FilterRemoval) {
+TEST_F(IPCChannelProxyTest, FilterRemoval) {
// Add a class and global filter.
scoped_refptr<MessageCountFilter> class_filter(
new MessageCountFilter(TestMsgStart));
@@ -423,7 +409,7 @@ class IPCChannelBadMessageTest : public IPCTestBase {
}
private:
- scoped_ptr<QuitListener> listener_;
+ std::unique_ptr<QuitListener> listener_;
};
#if !defined(OS_WIN)
@@ -440,7 +426,7 @@ TEST_F(IPCChannelBadMessageTest, BadMessage) {
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/chromium/ipc/ipc_channel_reader.cc b/chromium/ipc/ipc_channel_reader.cc
index e11fb93aea4..9af3696ef61 100644
--- a/chromium/ipc/ipc_channel_reader.cc
+++ b/chromium/ipc/ipc_channel_reader.cc
@@ -237,7 +237,7 @@ bool ChannelReader::HandleExternalMessage(
}
// 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/chromium/ipc/ipc_channel_reader_unittest.cc b/chromium/ipc/ipc_channel_reader_unittest.cc
index 4ec71b53676..1107cc73eeb 100644
--- a/chromium/ipc/ipc_channel_reader_unittest.cc
+++ b/chromium/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, AttachmentAlreadyBrokered) {
}
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/chromium/ipc/ipc_channel_unittest.cc b/chromium/ipc/ipc_channel_unittest.cc
index 134bec26edc..e423b896475 100644
--- a/chromium/ipc/ipc_channel_unittest.cc
+++ b/chromium/ipc/ipc_channel_unittest.cc
@@ -10,6 +10,7 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/pickle.h"
@@ -158,7 +159,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(GenericClient) {
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/chromium/ipc/ipc_channel_win.cc b/chromium/ipc/ipc_channel_win.cc
index 4447dcf4616..4321b04beef 100644
--- a/chromium/ipc/ipc_channel_win.cc
+++ b/chromium/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"
@@ -27,10 +28,7 @@
namespace IPC {
-ChannelWin::State::State(ChannelWin* channel) : is_pending(false) {
- memset(&context.overlapped, 0, sizeof(context.overlapped));
- context.handler = channel;
-}
+ChannelWin::State::State() = default;
ChannelWin::State::~State() {
static_assert(offsetof(ChannelWin::State, context) == 0,
@@ -42,8 +40,6 @@ ChannelWin::ChannelWin(const IPC::ChannelHandle& channel_handle,
Mode mode,
Listener* listener)
: ChannelReader(listener),
- input_state_(this),
- output_state_(this),
peer_pid_(base::kNullProcessId),
waiting_connect_(mode & MODE_SERVER_FLAG),
processing_incoming_(false),
@@ -378,9 +374,8 @@ bool ChannelWin::CreatePipe(const IPC::ChannelHandle &channel_handle,
}
// 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).
@@ -585,10 +580,11 @@ void ChannelWin::OnIOCompleted(
// 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/chromium/ipc/ipc_channel_win.h b/chromium/ipc/ipc_channel_win.h
index fd186fc186f..2ea865ea178 100644
--- a/chromium/ipc/ipc_channel_win.h
+++ b/chromium/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 {
@@ -83,10 +82,10 @@ class ChannelWin : public Channel,
private:
struct State {
- explicit State(ChannelWin* channel);
+ State();
~State();
base::MessageLoopForIO::IOContext context;
- bool is_pending;
+ bool is_pending = false;
};
State input_state_;
@@ -131,7 +130,7 @@ class ChannelWin : public Channel,
// 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/chromium/ipc/ipc_fuzzing_tests.cc b/chromium/ipc/ipc_fuzzing_tests.cc
index 6eb93054c66..f197a6b8164 100644
--- a/chromium/ipc/ipc_fuzzing_tests.cc
+++ b/chromium/ipc/ipc_fuzzing_tests.cc
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <limits>
+#include <memory>
#include <sstream>
#include <string>
@@ -259,7 +260,7 @@ class FuzzerClientListener : public SimpleListener {
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());
@@ -270,14 +271,9 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(FuzzServerClient) {
class IPCFuzzingTest : public IPCTestBase {
};
-#if defined(OS_ANDROID)
-#define MAYBE_SanityTest DISABLED_SanityTest
-#else
-#define MAYBE_SanityTest SanityTest
-#endif
// This test makes sure that the FuzzerClientListener and FuzzerServerListener
// are working properly by generating two well formed IPC calls.
-TEST_F(IPCFuzzingTest, MAYBE_SanityTest) {
+TEST_F(IPCFuzzingTest, SanityTest) {
Init("FuzzServerClient");
FuzzerClientListener listener;
@@ -300,17 +296,12 @@ TEST_F(IPCFuzzingTest, MAYBE_SanityTest) {
DestroyChannel();
}
-#if defined(OS_ANDROID)
-#define MAYBE_MsgBadPayloadShort DISABLED_MsgBadPayloadShort
-#else
-#define MAYBE_MsgBadPayloadShort MsgBadPayloadShort
-#endif
// This test uses a payload that is smaller than expected. This generates an
// error while unpacking the IPC buffer which in debug trigger an assertion and
// in release is ignored (!). Right after we generate another valid IPC to make
// sure framing is working properly.
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
-TEST_F(IPCFuzzingTest, MAYBE_MsgBadPayloadShort) {
+TEST_F(IPCFuzzingTest, MsgBadPayloadShort) {
Init("FuzzServerClient");
FuzzerClientListener listener;
@@ -334,16 +325,11 @@ TEST_F(IPCFuzzingTest, MAYBE_MsgBadPayloadShort) {
}
#endif
-#if defined(OS_ANDROID)
-#define MAYBE_MsgBadPayloadArgs DISABLED_MsgBadPayloadArgs
-#else
-#define MAYBE_MsgBadPayloadArgs MsgBadPayloadArgs
-#endif
// This test uses a payload that has too many arguments, but so the payload size
// is big enough so the unpacking routine does not generate an error as in the
// case of MsgBadPayloadShort test. This test does not pinpoint a flaw (per se)
// as by design we don't carry type information on the IPC message.
-TEST_F(IPCFuzzingTest, MAYBE_MsgBadPayloadArgs) {
+TEST_F(IPCFuzzingTest, MsgBadPayloadArgs) {
Init("FuzzServerClient");
FuzzerClientListener listener;
diff --git a/chromium/ipc/ipc_logging.cc b/chromium/ipc/ipc_logging.cc
index abe26cb82d7..693c71d072b 100644
--- a/chromium/ipc/ipc_logging.cc
+++ b/chromium/ipc/ipc_logging.cc
@@ -19,8 +19,8 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ipc/ipc_message_utils.h"
diff --git a/chromium/ipc/ipc_logging.h b/chromium/ipc/ipc_logging.h
index 2d12cb4c664..523413501d1 100644
--- a/chromium/ipc/ipc_logging.h
+++ b/chromium/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/chromium/ipc/ipc_message.cc b/chromium/ipc/ipc_message.cc
index 289f08dab06..83ee495a813 100644
--- a/chromium/ipc/ipc_message.cc
+++ b/chromium/ipc/ipc_message.cc
@@ -249,6 +249,9 @@ bool Message::WriteAttachment(
&index, &brokerable);
DCHECK(success);
+ // NOTE: If you add more data to the pickle, make sure to update
+ // PickleSizer::AddAttachment.
+
// Write the type of descriptor.
WriteBool(brokerable);
diff --git a/chromium/ipc/ipc_message_attachment_set_posix_unittest.cc b/chromium/ipc/ipc_message_attachment_set_posix_unittest.cc
index e43e43163cb..5ebed84070c 100644
--- a/chromium/ipc/ipc_message_attachment_set_posix_unittest.cc
+++ b/chromium/ipc/ipc_message_attachment_set_posix_unittest.cc
@@ -154,7 +154,7 @@ TEST(MessageAttachmentSet, WalkWrongOrder) {
set->AddAttachment(new internal::PlatformFileAttachment(kFDBase + 2)));
ASSERT_EQ(set->GetNonBrokerableAttachmentAt(0)->TakePlatformFile(), kFDBase);
- ASSERT_EQ(set->GetNonBrokerableAttachmentAt(2), nullptr);
+ ASSERT_FALSE(set->GetNonBrokerableAttachmentAt(2));
set->CommitAllDescriptors();
}
diff --git a/chromium/ipc/ipc_message_start.h b/chromium/ipc/ipc_message_start.h
index c3abddc0ae2..453a4bddd15 100644
--- a/chromium/ipc/ipc_message_start.h
+++ b/chromium/ipc/ipc_message_start.h
@@ -91,7 +91,6 @@ enum IPCMessageStart {
ScreenOrientationMsgStart,
MediaStreamTrackMetricsHostMsgStart,
ChromeExtensionMsgStart,
- MojoMsgStart,
TranslateMsgStart,
CldDataProviderMsgStart,
PushMessagingMsgStart,
@@ -101,11 +100,9 @@ enum IPCMessageStart {
OzoneGpuMsgStart,
ChromeUtilityExtensionsMsgStart,
PlatformNotificationMsgStart,
- CredentialManagerMsgStart,
PDFMsgStart,
ManifestManagerMsgStart,
ExtensionUtilityMsgStart,
- GeofencingMsgStart,
LayoutTestMsgStart,
NetworkHintsMsgStart,
BluetoothMsgStart,
@@ -121,7 +118,6 @@ enum IPCMessageStart {
DataReductionProxyStart,
ContentSettingsMsgStart,
ChromeAppBannerMsgStart,
- SafeJsonParserMsgStart,
AttachmentBrokerMsgStart,
RenderProcessMsgStart,
PageLoadMetricsMsgStart,
diff --git a/chromium/ipc/ipc_message_unittest.cc b/chromium/ipc/ipc_message_unittest.cc
index c022f9765a8..21f5eb29533 100644
--- a/chromium/ipc/ipc_message_unittest.cc
+++ b/chromium/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 @@ TEST(IPCMessageTest, DictionaryValue) {
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/chromium/ipc/ipc_message_utils.cc b/chromium/ipc/ipc_message_utils.cc
index 9edc3bbd4cd..f31add1da14 100644
--- a/chromium/ipc/ipc_message_utils.cc
+++ b/chromium/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 @@ bool ReadValue(const base::Pickle* m,
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();
@@ -636,6 +635,12 @@ void ParamTraits<base::DictionaryValue>::Log(const param_type& p,
}
#if defined(OS_POSIX)
+void ParamTraits<base::FileDescriptor>::GetSize(base::PickleSizer* sizer,
+ const param_type& p) {
+ GetParamSize(sizer, p.fd >= 0);
+ sizer->AddAttachment();
+}
+
void ParamTraits<base::FileDescriptor>::Write(base::Pickle* m,
const param_type& p) {
const bool valid = p.fd >= 0;
@@ -688,95 +693,62 @@ void ParamTraits<base::FileDescriptor>::Log(const param_type& p,
#endif // defined(OS_POSIX)
#if defined(OS_MACOSX) && !defined(OS_IOS)
+void ParamTraits<base::SharedMemoryHandle>::GetSize(base::PickleSizer* sizer,
+ const param_type& p) {
+ GetParamSize(sizer, p.GetMemoryObject());
+ uint32_t dummy = 0;
+ GetParamSize(sizer, dummy);
+}
+
void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m,
const param_type& p) {
- m->WriteInt(p.GetType());
+ MachPortMac mach_port_mac(p.GetMemoryObject());
+ ParamTraits<MachPortMac>::Write(m, mach_port_mac);
+ size_t size = 0;
+ bool result = p.GetSize(&size);
+ DCHECK(result);
+ ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size));
- switch (p.GetType()) {
- case base::SharedMemoryHandle::POSIX:
- ParamTraits<base::FileDescriptor>::Write(m, p.GetFileDescriptor());
- break;
- case base::SharedMemoryHandle::MACH:
- MachPortMac mach_port_mac(p.GetMemoryObject());
- ParamTraits<MachPortMac>::Write(m, mach_port_mac);
- size_t size = 0;
- bool result = p.GetSize(&size);
- DCHECK(result);
- ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size));
-
- // If the caller intended to pass ownership to the IPC stack, release a
- // reference.
- if (p.OwnershipPassesToIPC())
- p.Close();
-
- break;
- }
+ // If the caller intended to pass ownership to the IPC stack, release a
+ // reference.
+ if (p.OwnershipPassesToIPC())
+ p.Close();
}
bool ParamTraits<base::SharedMemoryHandle>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
- base::SharedMemoryHandle::TypeWireFormat type;
- if (!iter->ReadInt(&type))
+ MachPortMac mach_port_mac;
+ if (!ParamTraits<MachPortMac>::Read(m, iter, &mach_port_mac))
return false;
- base::SharedMemoryHandle::Type shm_type = base::SharedMemoryHandle::POSIX;
- switch (type) {
- case base::SharedMemoryHandle::POSIX:
- case base::SharedMemoryHandle::MACH: {
- shm_type = static_cast<base::SharedMemoryHandle::Type>(type);
- break;
- }
- default: {
- return false;
- }
- }
-
- switch (shm_type) {
- case base::SharedMemoryHandle::POSIX: {
- base::FileDescriptor file_descriptor;
-
- bool success =
- ParamTraits<base::FileDescriptor>::Read(m, iter, &file_descriptor);
- if (!success)
- return false;
-
- *r = base::SharedMemoryHandle(file_descriptor.fd,
- file_descriptor.auto_close);
- return true;
- }
- case base::SharedMemoryHandle::MACH: {
- MachPortMac mach_port_mac;
- if (!ParamTraits<MachPortMac>::Read(m, iter, &mach_port_mac))
- return false;
-
- uint32_t size;
- if (!ParamTraits<uint32_t>::Read(m, iter, &size))
- return false;
+ uint32_t size;
+ if (!ParamTraits<uint32_t>::Read(m, iter, &size))
+ return false;
- *r = base::SharedMemoryHandle(mach_port_mac.get_mach_port(),
- static_cast<size_t>(size),
- base::GetCurrentProcId());
- return true;
- }
- }
+ *r = base::SharedMemoryHandle(mach_port_mac.get_mach_port(),
+ static_cast<size_t>(size),
+ base::GetCurrentProcId());
+ return true;
}
void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p,
std::string* l) {
- switch (p.GetType()) {
- case base::SharedMemoryHandle::POSIX:
- l->append("POSIX Fd: ");
- ParamTraits<base::FileDescriptor>::Log(p.GetFileDescriptor(), l);
- break;
- case base::SharedMemoryHandle::MACH:
- l->append("Mach port: ");
- LogParam(p.GetMemoryObject(), l);
- break;
- }
+ l->append("Mach port: ");
+ LogParam(p.GetMemoryObject(), l);
}
#elif defined(OS_WIN)
+void ParamTraits<base::SharedMemoryHandle>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, p.NeedsBrokering());
+ if (p.NeedsBrokering()) {
+ GetParamSize(s, p.GetHandle());
+ } else {
+ GetParamSize(s, HandleToLong(p.GetHandle()));
+ }
+}
+
void ParamTraits<base::SharedMemoryHandle>::Write(base::Pickle* m,
const param_type& p) {
m->WriteBool(p.NeedsBrokering());
@@ -1024,6 +996,14 @@ void ParamTraits<base::TimeTicks>::Log(const param_type& p, std::string* l) {
ParamTraits<int64_t>::Log(p.ToInternalValue(), l);
}
+void ParamTraits<IPC::ChannelHandle>::GetSize(base::PickleSizer* sizer,
+ const param_type& p) {
+ GetParamSize(sizer, p.name);
+#if defined(OS_POSIX)
+ GetParamSize(sizer, p.socket);
+#endif
+}
+
void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m,
const param_type& p) {
#if defined(OS_WIN)
diff --git a/chromium/ipc/ipc_message_utils.h b/chromium/ipc/ipc_message_utils.h
index cf4fa8fb14c..98485493511 100644
--- a/chromium/ipc/ipc_message_utils.h
+++ b/chromium/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"
@@ -554,6 +554,7 @@ struct IPC_EXPORT ParamTraits<base::DictionaryValue> {
template<>
struct IPC_EXPORT ParamTraits<base::FileDescriptor> {
typedef base::FileDescriptor param_type;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -566,6 +567,7 @@ struct IPC_EXPORT ParamTraits<base::FileDescriptor> {
template <>
struct IPC_EXPORT ParamTraits<base::SharedMemoryHandle> {
typedef base::SharedMemoryHandle param_type;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -941,8 +943,8 @@ struct ParamTraits<base::SmallMap<NormalMap, kArraySize, EqualKey, MapInit> > {
};
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);
@@ -990,6 +992,7 @@ struct ParamTraits<scoped_ptr<P> > {
template<>
struct IPC_EXPORT ParamTraits<IPC::ChannelHandle> {
typedef ChannelHandle param_type;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
diff --git a/chromium/ipc/ipc_message_utils_unittest.cc b/chromium/ipc/ipc_message_utils_unittest.cc
index 659047d2061..51e8336a010 100644
--- a/chromium/ipc/ipc_message_utils_unittest.cc
+++ b/chromium/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 @@ TEST(IPCMessageUtilsTest, StackVector) {
// 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/chromium/ipc/ipc_perftest_support.cc b/chromium/ipc/ipc_perftest_support.cc
index 5cd2b1db82a..050b541330f 100644
--- a/chromium/ipc/ipc_perftest_support.cc
+++ b/chromium/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 @@ class PerformanceChannelListener : public Listener {
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 @@ void IPCChannelPerfTestBase::RunTestChannelProxyPingPong(
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()
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/chromium/ipc/ipc_perftest_support.h b/chromium/ipc/ipc_perftest_support.h
index 82eb1eefbf0..f719db4368c 100644
--- a/chromium/ipc/ipc_perftest_support.h
+++ b/chromium/ipc/ipc_perftest_support.h
@@ -7,11 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/test/test_io_thread.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_test_base.h"
@@ -53,7 +54,7 @@ class IPCChannelPerfTestBase : public IPCTestBase {
}
private:
- scoped_ptr<base::TestIOThread> io_thread_;
+ std::unique_ptr<base::TestIOThread> io_thread_;
};
class PingPongTestClient {
@@ -61,14 +62,14 @@ class PingPongTestClient {
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/chromium/ipc/ipc_send_fds_test.cc b/chromium/ipc/ipc_send_fds_test.cc
index 264aa855f91..9480d0e6232 100644
--- a/chromium/ipc/ipc_send_fds_test.cc
+++ b/chromium/ipc/ipc_send_fds_test.cc
@@ -8,7 +8,7 @@
#if defined(OS_MACOSX)
extern "C" {
#include <sandbox.h>
-}
+};
#endif
#include <fcntl.h>
#include <stddef.h>
@@ -16,6 +16,7 @@ extern "C" {
#include <sys/stat.h>
#include <unistd.h>
+#include <memory>
#include <queue>
#include "base/callback.h"
@@ -33,6 +34,10 @@ extern "C" {
#include "base/macros.h"
#endif
+#if defined(OS_MACOSX)
+#include "sandbox/mac/seatbelt.h"
+#endif
+
namespace {
const unsigned kNumFDsToSend = 7; // per message
@@ -138,12 +143,7 @@ class IPCSendFdsTest : public IPCTestBase {
}
};
-#if defined(OS_ANDROID)
-#define MAYBE_DescriptorTest DISABLED_DescriptorTest
-#else
-#define MAYBE_DescriptorTest DescriptorTest
-#endif
-TEST_F(IPCSendFdsTest, MAYBE_DescriptorTest) {
+TEST_F(IPCSendFdsTest, DescriptorTest) {
Init("SendFdsClient");
RunServer();
}
@@ -154,7 +154,7 @@ int SendFdsClientCommon(const std::string& test_client_name,
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());
@@ -193,16 +193,13 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsSandboxedClient) {
// Enable the sandbox.
char* error_buff = NULL;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED,
- &error_buff);
+ int error = sandbox::Seatbelt::Init(kSBXProfilePureComputation, SANDBOX_NAMED,
+ &error_buff);
bool success = (error == 0 && error_buff == NULL);
if (!success)
return -1;
- sandbox_free_error(error_buff);
-#pragma clang diagnostic pop
+ sandbox::Seatbelt::FreeError(error_buff);
// Make sure sandbox is really enabled.
if (open(kDevZeroPath, O_RDONLY) != -1) {
@@ -265,8 +262,8 @@ class PipeChannelHelper {
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();
}
@@ -299,7 +296,7 @@ class PipeChannelHelper {
}
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_;
@@ -358,9 +355,9 @@ class IPCMultiSendingFdsTest : public testing::Test {
// 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/chromium/ipc/ipc_sync_channel.cc b/chromium/ipc/ipc_sync_channel.cc
index 48d9328fe1b..de54755f892 100644
--- a/chromium/ipc/ipc_sync_channel.cc
+++ b/chromium/ipc/ipc_sync_channel.cc
@@ -6,16 +6,18 @@
#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"
#include "base/threading/thread_local.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "ipc/ipc_channel_factory.h"
#include "ipc/ipc_logging.h"
@@ -405,38 +407,38 @@ base::WaitableEventWatcher::EventCallback
}
// 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/chromium/ipc/ipc_sync_channel.h b/chromium/ipc/ipc_sync_channel.h
index eb2a272330c..103925a70fb 100644
--- a/chromium/ipc/ipc_sync_channel.h
+++ b/chromium/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 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
// 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 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
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 @@ class IPC_EXPORT SyncChannel : public ChannelProxy {
// 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/chromium/ipc/ipc_sync_channel_unittest.cc b/chromium/ipc/ipc_sync_channel_unittest.cc
index e3a71927a9b..4048825349c 100644
--- a/chromium/ipc/ipc_sync_channel_unittest.cc
+++ b/chromium/ipc/ipc_sync_channel_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
@@ -13,15 +14,14 @@
#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"
#include "base/strings/string_util.h"
#include "base/synchronization/waitable_event.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_message.h"
@@ -158,7 +158,7 @@ class Worker : public Listener, public Sender {
}
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 @@ class Worker : public Listener, public Sender {
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 @@ class RestrictedDispatchClient : public Worker {
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 @@ class RestrictedDispatchPipeWorker : public Worker {
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 @@ class ReentrantReplyServer1 : public Worker {
}
WaitableEvent* server_ready_;
- scoped_ptr<SyncChannel> server2_channel_;
+ std::unique_ptr<SyncChannel> server2_channel_;
};
class ReentrantReplyServer2 : public Worker {
diff --git a/chromium/ipc/ipc_sync_message.h b/chromium/ipc/ipc_sync_message.h
index 6dd3b632451..cb259b1dbf1 100644
--- a/chromium/ipc/ipc_sync_message.h
+++ b/chromium/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 @@ class IPC_EXPORT SyncMessage : public Message {
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/chromium/ipc/ipc_sync_message_filter.cc b/chromium/ipc/ipc_sync_message_filter.cc
index 73e905833ed..da883f6fd68 100644
--- a/chromium/ipc/ipc_sync_message_filter.cc
+++ b/chromium/ipc/ipc_sync_message_filter.cc
@@ -9,7 +9,7 @@
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_sync_message.h"
diff --git a/chromium/ipc/ipc_test_base.cc b/chromium/ipc/ipc_test_base.cc
index 6243138cd4b..757d9f5bb62 100644
--- a/chromium/ipc/ipc_test_base.cc
+++ b/chromium/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::TearDown() {
}
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 @@ bool IPCTestBase::ConnectChannel() {
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);
}
@@ -144,8 +144,13 @@ bool IPCTestBase::WaitForClientShutdown() {
DCHECK(client_process_.IsValid());
int exit_code;
+#if defined(OS_ANDROID)
+ bool rv = AndroidWaitForChildExitWithTimeout(
+ client_process_, base::TimeDelta::FromSeconds(5), &exit_code);
+#else
bool rv = client_process_.WaitForExitWithTimeout(
base::TimeDelta::FromSeconds(5), &exit_code);
+#endif // defined(OS_ANDROID)
client_process_.Close();
return rv;
}
@@ -158,7 +163,7 @@ scoped_refptr<base::SequencedTaskRunner> IPCTestBase::task_runner() {
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/chromium/ipc/ipc_test_base.h b/chromium/ipc/ipc_test_base.h
index 0646363805b..c85c74f43a1 100644
--- a/chromium/ipc/ipc_test_base.h
+++ b/chromium/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 @@ class IPCTestBase : public base::MultiProcessTest {
// 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 @@ class IPCTestBase : public base::MultiProcessTest {
// 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).
@@ -113,8 +113,9 @@ class IPCTestBase : public base::MultiProcessTest {
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();
@@ -122,10 +123,10 @@ class IPCTestBase : public base::MultiProcessTest {
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/chromium/ipc/mach_port_mac.cc b/chromium/ipc/mach_port_mac.cc
index 9375d728eab..a482d24d7f0 100644
--- a/chromium/ipc/mach_port_mac.cc
+++ b/chromium/ipc/mach_port_mac.cc
@@ -12,6 +12,12 @@
namespace IPC {
// static
+void ParamTraits<MachPortMac>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ s->AddAttachment();
+}
+
+// static
void ParamTraits<MachPortMac>::Write(base::Pickle* m, const param_type& p) {
if (!m->WriteAttachment(
new IPC::internal::MachPortAttachmentMac(p.get_mach_port()))) {
diff --git a/chromium/ipc/mach_port_mac.h b/chromium/ipc/mach_port_mac.h
index b95a37b47d0..f8511344f6b 100644
--- a/chromium/ipc/mach_port_mac.h
+++ b/chromium/ipc/mach_port_mac.h
@@ -71,6 +71,7 @@ class IPC_EXPORT MachPortMac {
template <>
struct IPC_EXPORT ParamTraits<MachPortMac> {
typedef MachPortMac param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
diff --git a/chromium/ipc/mojo/ipc_channel_mojo.cc b/chromium/ipc/mojo/ipc_channel_mojo.cc
index e7d0a9a33cf..74fec87c6ee 100644
--- a/chromium/ipc/mojo/ipc_channel_mojo.cc
+++ b/chromium/ipc/mojo/ipc_channel_mojo.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
+
#include <memory>
#include <utility>
@@ -14,7 +15,8 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/memory/ptr_util.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_logging.h"
@@ -48,7 +50,7 @@ class MojoChannelFactory : public ChannelFactory {
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 @@ MojoResult UnwrapAttachment(mojom::SerializedHandlePtr handle,
//------------------------------------------------------------------------------
// 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));
}
@@ -238,16 +240,18 @@ ChannelMojo::~ChannelMojo() {
bool ChannelMojo::Connect() {
WillConnect();
- base::AutoLock lock(lock_);
- DCHECK(!task_runner_);
- task_runner_ = base::ThreadTaskRunnerHandle::Get();
- DCHECK(!message_reader_);
+ {
+ base::AutoLock lock(lock_);
+ DCHECK(!task_runner_);
+ task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ DCHECK(!message_reader_);
+ }
bootstrap_->Connect();
return true;
}
void ChannelMojo::Close() {
- scoped_ptr<internal::MessagePipeReader, ReaderDeleter> reader;
+ std::unique_ptr<internal::MessagePipeReader, ReaderDeleter> reader;
{
base::AutoLock lock(lock_);
if (!message_reader_)
@@ -281,9 +285,9 @@ void ChannelMojo::InitMessageReader(mojom::ChannelAssociatedPtrInfo sender,
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;
{
@@ -325,15 +329,20 @@ void ChannelMojo::OnPipeError() {
}
bool ChannelMojo::Send(Message* message) {
- base::AutoLock lock(lock_);
- if (!message_reader_) {
- pending_messages_.push_back(make_scoped_ptr(message));
- // Counts as OK before the connection is established, but it's an
- // error otherwise.
- return waiting_connect_;
+ bool sent = false;
+ {
+ base::AutoLock lock(lock_);
+ if (!message_reader_) {
+ pending_messages_.push_back(base::WrapUnique(message));
+ // Counts as OK before the connection is established, but it's an
+ // error otherwise.
+ return waiting_connect_;
+ }
+
+ sent = message_reader_->Send(base::WrapUnique(message));
}
- if (!message_reader_->Send(make_scoped_ptr(message))) {
+ if (!sent) {
OnPipeError();
return false;
}
@@ -342,7 +351,7 @@ bool ChannelMojo::Send(Message* message) {
}
bool ChannelMojo::IsSendThreadSafe() const {
- return true;
+ return false;
}
base::ProcessId ChannelMojo::GetPeerPID() const {
diff --git a/chromium/ipc/mojo/ipc_channel_mojo.h b/chromium/ipc/mojo/ipc_channel_mojo.h
index 5968d84ec9b..a8a28ecc7fc 100644
--- a/chromium/ipc/mojo/ipc_channel_mojo.h
+++ b/chromium/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 @@ class IPC_MOJO_EXPORT ChannelMojo
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 @@ class IPC_MOJO_EXPORT ChannelMojo
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/chromium/ipc/mojo/ipc_channel_mojo_unittest.cc b/chromium/ipc/mojo/ipc_channel_mojo_unittest.cc
index 615e72d5945..613b2e26116 100644
--- a/chromium/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/chromium/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"
@@ -17,8 +18,8 @@
#include "base/single_thread_task_runner.h"
#include "base/test/test_io_thread.h"
#include "base/test/test_timeouts.h"
-#include "base/thread_task_runner_handle.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_test_base.h"
@@ -118,7 +119,7 @@ class ChannelClient {
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 @@ class IPCChannelMojoTest : public testing::Test {
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
@@ -170,13 +171,7 @@ class TestChannelListenerWithExtraExpectations
bool is_connected_called_;
};
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_ConnectedFromClient DISABLED_ConnectedFromClient
-#else
-#define MAYBE_ConnectedFromClient ConnectedFromClient
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_ConnectedFromClient) {
+TEST_F(IPCChannelMojoTest, ConnectedFromClient) {
InitWithMojo("IPCChannelMojoTestClient");
// Set up IPC channel and start client.
@@ -255,13 +250,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoErraticTestClient,
Close();
}
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_SendFailWithPendingMessages DISABLED_SendFailWithPendingMessages
-#else
-#define MAYBE_SendFailWithPendingMessages SendFailWithPendingMessages
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_SendFailWithPendingMessages) {
+TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) {
InitWithMojo("IPCChannelMojoErraticTestClient");
// Set up IPC channel and start client.
@@ -404,13 +393,7 @@ class ListenerThatExpectsMessagePipe : public IPC::Listener {
IPC::Sender* sender_;
};
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_SendMessagePipe DISABLED_SendMessagePipe
-#else
-#define MAYBE_SendMessagePipe SendMessagePipe
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_SendMessagePipe) {
+TEST_F(IPCChannelMojoTest, SendMessagePipe) {
InitWithMojo("IPCChannelMojoTestSendMessagePipeClient");
ListenerThatExpectsOK listener;
@@ -501,13 +484,7 @@ class ParamTraitMessagePipeClient : public ChannelClient {
}
};
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_ParamTraitValidMessagePipe DISABLED_ParamTraitValidMessagePipe
-#else
-#define MAYBE_ParamTraitValidMessagePipe ParamTraitValidMessagePipe
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) {
+TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) {
InitWithMojo("ParamTraitValidMessagePipeClient");
ListenerThatExpectsOK listener;
@@ -516,7 +493,7 @@ TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitValidMessagePipe) {
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());
@@ -534,13 +511,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitValidMessagePipeClient,
RunTest(true);
}
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_ParamTraitInvalidMessagePipe DISABLED_ParamTraitInvalidMessagePipe
-#else
-#define MAYBE_ParamTraitInvalidMessagePipe ParamTraitInvalidMessagePipe
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) {
+TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) {
InitWithMojo("ParamTraitInvalidMessagePipeClient");
ListenerThatExpectsOK listener;
@@ -548,7 +519,7 @@ TEST_F(IPCChannelMojoTest, MAYBE_ParamTraitInvalidMessagePipe) {
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);
@@ -565,13 +536,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(ParamTraitInvalidMessagePipeClient,
RunTest(false);
}
-// Times out on Android. crbug.com/593790
-#if defined(OS_ANDROID)
-#define MAYBE_SendFailAfterClose DISABLED_SendFailAfterClose
-#else
-#define MAYBE_SendFailAfterClose SendFailAfterClose
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_SendFailAfterClose) {
+TEST_F(IPCChannelMojoTest, SendFailAfterClose) {
InitWithMojo("IPCChannelMojoTestSendOkClient");
ListenerThatExpectsOK listener;
@@ -637,13 +602,7 @@ class ListenerThatExpectsFile : public IPC::Listener {
IPC::Sender* sender_;
};
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_SendPlatformHandle DISABLED_SendPlatformHandle
-#else
-#define MAYBE_SendPlatformHandle SendPlatformHandle
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandle) {
+TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
InitWithMojo("IPCChannelMojoTestSendPlatformHandleClient");
ListenerThatExpectsOK listener;
@@ -696,13 +655,7 @@ class ListenerThatExpectsFileAndPipe : public IPC::Listener {
IPC::Sender* sender_;
};
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_SendPlatformHandleAndPipe DISABLED_SendPlatformHandleAndPipe
-#else
-#define MAYBE_SendPlatformHandleAndPipe SendPlatformHandleAndPipe
-#endif
-TEST_F(IPCChannelMojoTest, MAYBE_SendPlatformHandleAndPipe) {
+TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) {
InitWithMojo("IPCChannelMojoTestSendPlatformHandleAndPipeClient");
ListenerThatExpectsOK listener;
diff --git a/chromium/ipc/mojo/ipc_message_pipe_reader.cc b/chromium/ipc/mojo/ipc_message_pipe_reader.cc
index b657bfdc168..08bbcd4c2c2 100644
--- a/chromium/ipc/mojo/ipc_message_pipe_reader.cc
+++ b/chromium/ipc/mojo/ipc_message_pipe_reader.cc
@@ -14,7 +14,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "ipc/mojo/ipc_channel_mojo.h"
#include "mojo/public/cpp/bindings/message.h"
@@ -83,7 +83,7 @@ void MessagePipeReader::Close() {
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(),
@@ -108,15 +108,8 @@ bool MessagePipeReader::Send(scoped_ptr<Message> message) {
DCHECK_LE(num_handles, std::numeric_limits<uint32_t>::max());
mojo_message->set_interface_id(sender_interface_id_);
- result = mojo::WriteMessageRaw(
- sender_pipe_, mojo_message->data(), mojo_message->data_num_bytes(),
- reinterpret_cast<const MojoHandle*>(mojo_message->handles()->data()),
- static_cast<uint32_t>(num_handles), MOJO_WRITE_MESSAGE_FLAG_NONE);
-
- // If the write was successful, the handles have been transferred and they
- // should not be closed when the message is destroyed.
- if (result == MOJO_RESULT_OK)
- mojo_message->mutable_handles()->clear();
+ result = mojo::WriteMessageNew(sender_pipe_, mojo_message->TakeMojoMessage(),
+ MOJO_WRITE_MESSAGE_FLAG_NONE);
DVLOG(4) << "Send " << message->type() << ": " << message->size();
return result == MOJO_RESULT_OK;
diff --git a/chromium/ipc/mojo/ipc_message_pipe_reader.h b/chromium/ipc/mojo/ipc_message_pipe_reader.h
index d2ba9dea45d..661ffde1a07 100644
--- a/chromium/ipc/mojo/ipc_message_pipe_reader.h
+++ b/chromium/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 @@ class MessagePipeReader : public mojom::Channel {
// 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/chromium/ipc/mojo/ipc_mojo.gyp b/chromium/ipc/mojo/ipc_mojo.gyp
index 75c85d9824a..e925d7ba856 100644
--- a/chromium/ipc/mojo/ipc_mojo.gyp
+++ b/chromium/ipc/mojo/ipc_mojo.gyp
@@ -103,4 +103,23 @@
],
},
],
+ 'conditions': [
+ ['test_isolation_mode != "noop"', {
+ 'targets': [
+ {
+ 'target_name': 'ipc_mojo_unittests_run',
+ 'type': 'none',
+ 'dependencies': [
+ 'ipc_mojo_unittests',
+ ],
+ 'includes': [
+ '../../build/isolate.gypi',
+ ],
+ 'sources': [
+ 'ipc_mojo_unittests.isolate',
+ ],
+ },
+ ],
+ }],
+ ],
}
diff --git a/chromium/ipc/mojo/ipc_mojo_bootstrap.cc b/chromium/ipc/mojo/ipc_mojo_bootstrap.cc
index a80b4610301..91883238ba4 100644
--- a/chromium/ipc/mojo/ipc_mojo_bootstrap.cc
+++ b/chromium/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 @@ void MojoClientBootstrap::Init(mojom::ChannelAssociatedRequest receive_channel,
// 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/chromium/ipc/mojo/ipc_mojo_bootstrap.h b/chromium/ipc/mojo/ipc_mojo_bootstrap.h
index 23e0e9193b7..e7769ec20a1 100644
--- a/chromium/ipc/mojo/ipc_mojo_bootstrap.h
+++ b/chromium/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 @@ class IPC_MOJO_EXPORT MojoBootstrap {
// 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/chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
index d702a6ae7b8..ce0c9b360e4 100644
--- a/chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
+++ b/chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
@@ -5,11 +5,12 @@
#include "ipc/mojo/ipc_mojo_bootstrap.h"
#include <stdint.h>
+#include <memory>
#include "base/base_paths.h"
#include "base/files/file.h"
#include "base/message_loop/message_loop.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_test_base.h"
#include "ipc/mojo/ipc.mojom.h"
@@ -58,17 +59,11 @@ void TestingDelegate::OnBootstrapError() {
quit_callback_.Run();
}
-// Times out on Android; see http://crbug.com/502290
-#if defined(OS_ANDROID)
-#define MAYBE_Connect DISABLED_Connect
-#else
-#define MAYBE_Connect Connect
-#endif
-TEST_F(IPCMojoBootstrapTest, MAYBE_Connect) {
+TEST_F(IPCMojoBootstrapTest, Connect) {
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 +81,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP(
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/chromium/ipc/mojo/ipc_mojo_perftest.cc b/chromium/ipc/mojo/ipc_mojo_perftest.cc
index b1c6c86b6c7..d68762b28ec 100644
--- a/chromium/ipc/mojo/ipc_mojo_perftest.cc
+++ b/chromium/ipc/mojo/ipc_mojo_perftest.cc
@@ -3,9 +3,11 @@
// 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 "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_perftest_support.h"
#include "ipc/mojo/ipc_channel_mojo.h"
@@ -24,7 +26,7 @@ class MojoChannelPerfTest : public test::IPCChannelPerfTestBase {
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 @@ class MojoChannelPerfTest : public test::IPCChannelPerfTestBase {
}
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 @@ class MojoPerfTestClient : public test::PingPongTestClient {
MojoPerfTestClient();
- scoped_ptr<Channel> CreateChannel(Listener* listener) override;
+ std::unique_ptr<Channel> CreateChannel(Listener* listener) override;
int Run(MojoHandle handle);
@@ -92,9 +94,9 @@ MojoPerfTestClient::MojoPerfTestClient()
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/chromium/ipc/mojo/ipc_mojo_unittests.isolate b/chromium/ipc/mojo/ipc_mojo_unittests.isolate
new file mode 100644
index 00000000000..d3309573f35
--- /dev/null
+++ b/chromium/ipc/mojo/ipc_mojo_unittests.isolate
@@ -0,0 +1,23 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+ 'includes': [
+ '../../base/base.isolate',
+ ],
+ 'conditions': [
+ ['OS=="win" or OS=="mac" or OS=="linux"', {
+ 'variables': {
+ 'command': [
+ '../../testing/test_env.py',
+ '<(PRODUCT_DIR)/ipc_mojo_unittests<(EXECUTABLE_SUFFIX)',
+ '--brave-new-test-launcher',
+ '--test-launcher-bot-mode',
+ ],
+ 'files': [
+ '../../testing/test_env.py',
+ ],
+ },
+ }],
+ ],
+}
diff --git a/chromium/ipc/mojo/run_all_unittests.cc b/chromium/ipc/mojo/run_all_unittests.cc
index 4416932e731..a831c2d2e30 100644
--- a/chromium/ipc/mojo/run_all_unittests.cc
+++ b/chromium/ipc/mojo/run_all_unittests.cc
@@ -5,6 +5,7 @@
#include "base/at_exit.h"
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
+#include "base/test/multiprocess_test.h"
#include "base/test/test_io_thread.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
@@ -18,6 +19,10 @@
int main(int argc, char** argv) {
#if defined(OS_ANDROID)
+ // Enable the alternate test child implementation. This is needed because Mojo
+ // tests need to spawn test children after initialising the Mojo system.
+ base::InitAndroidMultiProcessTestHelper(main);
+
JNIEnv* env = base::android::AttachCurrentThread();
base::RegisterContentUriTestUtils(env);
#endif
diff --git a/chromium/ipc/run_all_unittests.cc b/chromium/ipc/run_all_unittests.cc
index 26a73955eaf..5f9cc16755f 100644
--- a/chromium/ipc/run_all_unittests.cc
+++ b/chromium/ipc/run_all_unittests.cc
@@ -4,6 +4,7 @@
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
+#include "base/test/multiprocess_test.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
@@ -14,6 +15,8 @@
int main(int argc, char** argv) {
#if defined(OS_ANDROID)
+ base::InitAndroidMultiProcessTestHelper(main);
+
JNIEnv* env = base::android::AttachCurrentThread();
base::RegisterContentUriTestUtils(env);
#endif
diff --git a/chromium/ipc/sync_socket_unittest.cc b/chromium/ipc/sync_socket_unittest.cc
index 89c155b0613..3385646bd70 100644
--- a/chromium/ipc/sync_socket_unittest.cc
+++ b/chromium/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 @@ class SyncSocketServerListener : public IPC::Listener {
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());
@@ -166,12 +167,7 @@ class SyncSocketClientListener : public IPC::Listener {
class SyncSocketTest : public IPCTestBase {
};
-#if defined(OS_ANDROID)
-#define MAYBE_SanityTest DISABLED_SanityTest
-#else
-#define MAYBE_SanityTest SanityTest
-#endif
-TEST_F(SyncSocketTest, MAYBE_SanityTest) {
+TEST_F(SyncSocketTest, SanityTest) {
Init("SyncSocketServerClient");
SyncSocketClientListener listener;
@@ -253,13 +249,8 @@ TEST_F(SyncSocketTest, DisconnectTest) {
EXPECT_EQ(0U, received);
}
-#if defined(OS_ANDROID)
-#define MAYBE_BlockingReceiveTest DISABLED_BlockingReceiveTest
-#else
-#define MAYBE_BlockingReceiveTest BlockingReceiveTest
-#endif
// Tests that read is a blocking operation.
-TEST_F(SyncSocketTest, MAYBE_BlockingReceiveTest) {
+TEST_F(SyncSocketTest, BlockingReceiveTest) {
base::CancelableSyncSocket pair[2];
ASSERT_TRUE(base::CancelableSyncSocket::CreatePair(&pair[0], &pair[1]));
diff --git a/chromium/ipc/unix_domain_socket_util_unittest.cc b/chromium/ipc/unix_domain_socket_util_unittest.cc
index 2ba8cfe5a72..3fa4454638f 100644
--- a/chromium/ipc/unix_domain_socket_util_unittest.cc
+++ b/chromium/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 @@ class SocketAcceptor : public base::MessageLoopForIO::Watcher {
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 @@ class TestUnixSocketConnection {
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