summaryrefslogtreecommitdiff
path: root/chromium/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ipc')
-rw-r--r--chromium/ipc/BUILD.gn232
-rw-r--r--chromium/ipc/DEPS15
-rw-r--r--chromium/ipc/OWNERS17
-rw-r--r--chromium/ipc/SECURITY_OWNERS16
-rw-r--r--chromium/ipc/attachment_broker_mac_unittest.cc37
-rw-r--r--chromium/ipc/ipc.gyp80
-rw-r--r--chromium/ipc/ipc.gypi14
-rw-r--r--chromium/ipc/ipc.mojom (renamed from chromium/ipc/mojo/ipc.mojom)1
-rw-r--r--chromium/ipc/ipc_channel.h11
-rw-r--r--chromium/ipc/ipc_channel_common.cc36
-rw-r--r--chromium/ipc/ipc_channel_factory.cc5
-rw-r--r--chromium/ipc/ipc_channel_handle.h3
-rw-r--r--chromium/ipc/ipc_channel_mojo.cc (renamed from chromium/ipc/mojo/ipc_channel_mojo.cc)91
-rw-r--r--chromium/ipc/ipc_channel_mojo.h (renamed from chromium/ipc/mojo/ipc_channel_mojo.h)11
-rw-r--r--chromium/ipc/ipc_channel_mojo_unittest.cc (renamed from chromium/ipc/mojo/ipc_channel_mojo_unittest.cc)79
-rw-r--r--chromium/ipc/ipc_channel_posix_unittest.cc3
-rw-r--r--chromium/ipc/ipc_channel_proxy_unittest.cc7
-rw-r--r--chromium/ipc/ipc_channel_unittest.cc9
-rw-r--r--chromium/ipc/ipc_channel_win.h3
-rw-r--r--chromium/ipc/ipc_export.h13
-rw-r--r--chromium/ipc/ipc_fuzzing_tests.cc5
-rw-r--r--chromium/ipc/ipc_logging.cc8
-rw-r--r--chromium/ipc/ipc_logging.h5
-rw-r--r--chromium/ipc/ipc_message_pipe_reader.cc (renamed from chromium/ipc/mojo/ipc_message_pipe_reader.cc)4
-rw-r--r--chromium/ipc/ipc_message_pipe_reader.h (renamed from chromium/ipc/mojo/ipc_message_pipe_reader.h)2
-rw-r--r--chromium/ipc/ipc_message_start.h6
-rw-r--r--chromium/ipc/ipc_message_utils.cc24
-rw-r--r--chromium/ipc/ipc_message_utils_unittest.cc28
-rw-r--r--chromium/ipc/ipc_mojo_bootstrap.cc (renamed from chromium/ipc/mojo/ipc_mojo_bootstrap.cc)17
-rw-r--r--chromium/ipc/ipc_mojo_bootstrap.h (renamed from chromium/ipc/mojo/ipc_mojo_bootstrap.h)11
-rw-r--r--chromium/ipc/ipc_mojo_bootstrap_unittest.cc (renamed from chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc)4
-rw-r--r--chromium/ipc/ipc_mojo_handle_attachment.cc (renamed from chromium/ipc/mojo/ipc_mojo_handle_attachment.cc)15
-rw-r--r--chromium/ipc/ipc_mojo_handle_attachment.h (renamed from chromium/ipc/mojo/ipc_mojo_handle_attachment.h)21
-rw-r--r--chromium/ipc/ipc_mojo_message_helper.cc (renamed from chromium/ipc/mojo/ipc_mojo_message_helper.cc)4
-rw-r--r--chromium/ipc/ipc_mojo_message_helper.h (renamed from chromium/ipc/mojo/ipc_mojo_message_helper.h)8
-rw-r--r--chromium/ipc/ipc_mojo_param_traits.cc (renamed from chromium/ipc/mojo/ipc_mojo_param_traits.cc)15
-rw-r--r--chromium/ipc/ipc_mojo_param_traits.h (renamed from chromium/ipc/mojo/ipc_mojo_param_traits.h)18
-rw-r--r--chromium/ipc/ipc_mojo_perftest.cc (renamed from chromium/ipc/mojo/ipc_mojo_perftest.cc)2
-rw-r--r--chromium/ipc/ipc_nacl.gyp8
-rw-r--r--chromium/ipc/ipc_perftest_support.cc7
-rw-r--r--chromium/ipc/ipc_send_fds_test.cc15
-rw-r--r--chromium/ipc/ipc_sync_channel.cc23
-rw-r--r--chromium/ipc/ipc_sync_channel_unittest.cc89
-rw-r--r--chromium/ipc/ipc_sync_message.cc4
-rw-r--r--chromium/ipc/ipc_sync_message_filter.cc4
-rw-r--r--chromium/ipc/mojo/BUILD.gn89
-rw-r--r--chromium/ipc/mojo/DEPS5
-rw-r--r--chromium/ipc/mojo/OWNERS4
-rw-r--r--chromium/ipc/mojo/ipc_mojo.gyp125
-rw-r--r--chromium/ipc/mojo/ipc_mojo_unittests.isolate23
-rw-r--r--chromium/ipc/mojo/run_all_unittests.cc39
-rw-r--r--chromium/ipc/mojo/scoped_ipc_support.cc59
-rw-r--r--chromium/ipc/mojo/scoped_ipc_support.h32
-rw-r--r--chromium/ipc/mojo_event.cc39
-rw-r--r--chromium/ipc/mojo_event.h45
-rw-r--r--chromium/ipc/run_all_perftests.cc (renamed from chromium/ipc/mojo/run_all_perftests.cc)0
-rw-r--r--chromium/ipc/run_all_unittests.cc20
-rw-r--r--chromium/ipc/sync_socket_unittest.cc5
-rw-r--r--chromium/ipc/unix_domain_socket_util_unittest.cc7
59 files changed, 783 insertions, 739 deletions
diff --git a/chromium/ipc/BUILD.gn b/chromium/ipc/BUILD.gn
index 87587ec0942..34cab687770 100644
--- a/chromium/ipc/BUILD.gn
+++ b/chromium/ipc/BUILD.gn
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/config/nacl/config.gni")
+import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
@@ -38,6 +39,8 @@ component("ipc") {
"ipc_channel_factory.cc",
"ipc_channel_factory.h",
"ipc_channel_handle.h",
+ "ipc_channel_mojo.cc",
+ "ipc_channel_mojo.h",
"ipc_channel_nacl.cc",
"ipc_channel_nacl.h",
"ipc_channel_posix.cc",
@@ -66,11 +69,21 @@ component("ipc") {
"ipc_message_generator.cc",
"ipc_message_generator.h",
"ipc_message_macros.h",
+ "ipc_message_pipe_reader.cc",
+ "ipc_message_pipe_reader.h",
"ipc_message_start.h",
"ipc_message_templates.h",
"ipc_message_templates_impl.h",
"ipc_message_utils.cc",
"ipc_message_utils.h",
+ "ipc_mojo_bootstrap.cc",
+ "ipc_mojo_bootstrap.h",
+ "ipc_mojo_handle_attachment.cc",
+ "ipc_mojo_handle_attachment.h",
+ "ipc_mojo_message_helper.cc",
+ "ipc_mojo_message_helper.h",
+ "ipc_mojo_param_traits.cc",
+ "ipc_mojo_param_traits.h",
"ipc_platform_file.cc",
"ipc_platform_file.h",
"ipc_platform_file_attachment_posix.cc",
@@ -94,6 +107,8 @@ component("ipc") {
"message_filter_router.h",
"message_router.cc",
"message_router.h",
+ "mojo_event.cc",
+ "mojo_event.h",
"param_traits_log_macros.h",
"param_traits_macros.h",
"param_traits_read_macros.h",
@@ -127,12 +142,12 @@ component("ipc") {
public_deps = [
":param_traits",
+ "//mojo/public/cpp/system",
]
deps = [
+ ":mojom",
"//base",
-
- # TODO(viettrungluu): Needed for base/lazy_instance.h, which is suspect.
- "//base/third_party/dynamic_annotations",
+ "//mojo/public/cpp/bindings",
]
if (is_win || is_mac) {
@@ -146,6 +161,12 @@ component("ipc") {
}
}
+mojom("mojom") {
+ sources = [
+ "ipc.mojom",
+ ]
+}
+
# This is provided as a separate target so other targets can provide param
# traits implementations without necessarily linking to all of IPC.
source_set("param_traits") {
@@ -154,105 +175,130 @@ source_set("param_traits") {
]
}
-test("ipc_tests") {
- sources = [
- "attachment_broker_mac_unittest.cc",
- "attachment_broker_privileged_mac_unittest.cc",
- "attachment_broker_privileged_win_unittest.cc",
- "ipc_channel_posix_unittest.cc",
- "ipc_channel_proxy_unittest.cc",
- "ipc_channel_reader_unittest.cc",
- "ipc_channel_unittest.cc",
- "ipc_fuzzing_tests.cc",
- "ipc_message_attachment_set_posix_unittest.cc",
- "ipc_message_unittest.cc",
- "ipc_message_utils_unittest.cc",
- "ipc_send_fds_test.cc",
- "ipc_sync_channel_unittest.cc",
- "ipc_sync_message_unittest.cc",
- "ipc_sync_message_unittest.h",
- "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",
- ]
+if (!is_ios) {
+ source_set("run_all_unittests") {
+ testonly = true
- if (is_win || is_ios) {
- sources -= [ "unix_domain_socket_util_unittest.cc" ]
- }
+ sources = [
+ "run_all_unittests.cc",
+ ]
- if (is_android) {
- # These multiprocess tests don't work on Android.
- sources -= [ "ipc_channel_unittest.cc" ]
+ deps = [
+ "//base",
+ "//base/test:test_support",
+ "//mojo/edk/system",
+ "//mojo/edk/test:test_support",
+ ]
}
- # TODO(brettw) hook up Android testing.
- #if (is_android && gtest_target_type == "shared_library") {
- # deps += "/testing/android/native_test.gyp:native_testNative_code"
- #}
+ test("ipc_tests") {
+ sources = [
+ "attachment_broker_mac_unittest.cc",
+ "attachment_broker_privileged_mac_unittest.cc",
+ "attachment_broker_privileged_win_unittest.cc",
+ "ipc_channel_mojo_unittest.cc",
+ "ipc_channel_posix_unittest.cc",
+ "ipc_channel_proxy_unittest.cc",
+ "ipc_channel_reader_unittest.cc",
+ "ipc_fuzzing_tests.cc",
+ "ipc_message_attachment_set_posix_unittest.cc",
+ "ipc_message_unittest.cc",
+ "ipc_message_utils_unittest.cc",
+ "ipc_mojo_bootstrap_unittest.cc",
+ "ipc_sync_channel_unittest.cc",
+ "ipc_sync_message_unittest.cc",
+ "ipc_sync_message_unittest.h",
+ "ipc_test_message_generator.cc",
+ "ipc_test_message_generator.h",
+ "ipc_test_messages.h",
+ "sync_socket_unittest.cc",
+ ]
- deps = [
- ":ipc",
- ":test_support",
- "//base",
- "//base:i18n",
- "//base/test:test_support",
- "//crypto",
- "//testing/gtest",
- ]
+ if (!is_win && !is_ios) {
+ sources += [ "unix_domain_socket_util_unittest.cc" ]
+ }
+
+ if (!is_android) {
+ sources += [ "ipc_channel_unittest.cc" ]
+ }
- if (is_mac) {
- deps += [ "//sandbox/mac:seatbelt" ]
+ if (!is_ios) {
+ sources += [ "ipc_send_fds_test.cc" ]
+ }
+
+ # TODO(brettw) hook up Android testing.
+ #if (is_android && gtest_target_type == "shared_library") {
+ # deps += "/testing/android/native_test.gyp:native_testNative_code"
+ #}
+
+ deps = [
+ ":ipc",
+ ":mojom",
+ ":run_all_unittests",
+ ":test_support",
+ "//base",
+ "//base:i18n",
+ "//base/test:test_support",
+ "//crypto",
+ "//mojo/edk/system",
+ "//mojo/edk/test:test_support",
+ "//testing/gtest",
+ ]
+
+ if (is_mac) {
+ deps += [ "//sandbox/mac:seatbelt" ]
+ }
}
-}
-test("ipc_perftests") {
- sources = [
- "ipc_perftests.cc",
- ]
+ test("ipc_perftests") {
+ sources = [
+ "ipc_mojo_perftest.cc",
+ "ipc_perftests.cc",
+ "run_all_perftests.cc",
+ ]
- # TODO(brettw) hook up Android testing.
- #if (is_android && gtest_target_type == "shared_library") {
- # deps += "/testing/android/native_test.gyp:native_testNative_code"
- #}
+ # TODO(brettw) hook up Android testing.
+ #if (is_android && gtest_target_type == "shared_library") {
+ # deps += "/testing/android/native_test.gyp:native_testNative_code"
+ #}
- deps = [
- ":ipc",
- ":test_support",
- "//base",
- "//base:i18n",
- "//base/test:test_support",
- "//base/test:test_support_perf",
- "//testing/gtest",
- ]
-}
+ deps = [
+ ":ipc",
+ ":test_support",
+ "//base",
+ "//base:i18n",
+ "//base/test:test_support",
+ "//mojo/edk/system",
+ "//mojo/edk/test:test_support",
+ "//testing/gtest",
+ ]
+ }
-source_set("test_support") {
- testonly = true
- sources = [
- "ipc_multiprocess_test.cc",
- "ipc_multiprocess_test.h",
- "ipc_perftest_support.cc",
- "ipc_perftest_support.h",
- "ipc_security_test_util.cc",
- "ipc_security_test_util.h",
- "ipc_test_base.cc",
- "ipc_test_base.h",
- "ipc_test_channel_listener.cc",
- "ipc_test_channel_listener.h",
- "ipc_test_sink.cc",
- "ipc_test_sink.h",
- "test_util_mac.cc",
- "test_util_mac.h",
- ]
- public_deps = [
- ":ipc",
- ]
- deps = [
- "//base",
- "//base/test:test_support",
- "//testing/gtest",
- ]
+ source_set("test_support") {
+ testonly = true
+ sources = [
+ "ipc_multiprocess_test.cc",
+ "ipc_multiprocess_test.h",
+ "ipc_perftest_support.cc",
+ "ipc_perftest_support.h",
+ "ipc_security_test_util.cc",
+ "ipc_security_test_util.h",
+ "ipc_test_base.cc",
+ "ipc_test_base.h",
+ "ipc_test_channel_listener.cc",
+ "ipc_test_channel_listener.h",
+ "ipc_test_sink.cc",
+ "ipc_test_sink.h",
+ "test_util_mac.cc",
+ "test_util_mac.h",
+ ]
+ public_deps = [
+ ":ipc",
+ ]
+ deps = [
+ "//base",
+ "//base/test:test_support",
+ "//testing/gtest",
+ ]
+ }
}
diff --git a/chromium/ipc/DEPS b/chromium/ipc/DEPS
index b8caf57633e..421d8f7cc24 100644
--- a/chromium/ipc/DEPS
+++ b/chromium/ipc/DEPS
@@ -1,6 +1,21 @@
include_rules = [
"+crypto",
+ "+mojo/public",
# For ipc_channel_nacl.cc:
"+native_client/src/public",
"+sandbox/mac/seatbelt.h",
]
+
+specific_include_rules = {
+ "ipc_channel_mojo_unittest\.cc": [
+ "+mojo/edk/test",
+ ],
+ "ipc_mojo_(bootstrap_unittest|perftest)\.cc": [
+ "+mojo/edk/embedder",
+ "+mojo/edk/test",
+ ],
+ "run_all_(unit|perf)tests\.cc": [
+ "+mojo/edk/embedder",
+ "+mojo/edk/test",
+ ]
+}
diff --git a/chromium/ipc/OWNERS b/chromium/ipc/OWNERS
index 76fd94129fb..9bdaa196d73 100644
--- a/chromium/ipc/OWNERS
+++ b/chromium/ipc/OWNERS
@@ -1,18 +1,15 @@
+amistry@chromium.org
cpu@chromium.org
darin@chromium.org
jam@chromium.org
-jeremy@chromium.org
+rockot@chromium.org
tsepez@chromium.org
# New IPC message files require a security review to avoid introducing
# new sandbox escapes.
per-file ipc_message_start.h=set noparent
-per-file ipc_message_start.h=dcheng@chromium.org
-per-file ipc_message_start.h=jln@chromium.org
-per-file ipc_message_start.h=jschuh@chromium.org
-per-file ipc_message_start.h=palmer@chromium.org
-per-file ipc_message_start.h=tsepez@chromium.org
-per-file ipc_message_start.h=kenrb@chromium.org
-per-file ipc_message_start.h=mkwst@chromium.org
-per-file ipc_message_start.h=nasko@chromium.org
-per-file ipc_message_start.h=wfh@chromium.org
+per-file ipc_message_start.h=file://ipc/SECURITY_OWNERS
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
+per-file *_param_traits*.*=set noparent
+per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ipc/SECURITY_OWNERS b/chromium/ipc/SECURITY_OWNERS
new file mode 100644
index 00000000000..bcaea004926
--- /dev/null
+++ b/chromium/ipc/SECURITY_OWNERS
@@ -0,0 +1,16 @@
+# Changes to IPC messages require a security review to avoid introducing
+# new sandbox escapes.
+dcheng@chromium.org
+jln@chromium.org
+jschuh@chromium.org
+kenrb@chromium.org
+meacer@chromium.org
+mbarbella@chromium.org
+mkwst@chromium.org
+nasko@chromium.org
+ochang@chromium.org
+palmer@chromium.org
+rickyz@chromium.org
+rsesek@chromium.org
+tsepez@chromium.org
+wfh@chromium.org
diff --git a/chromium/ipc/attachment_broker_mac_unittest.cc b/chromium/ipc/attachment_broker_mac_unittest.cc
index 3be3d4397d6..62b7d1132f0 100644
--- a/chromium/ipc/attachment_broker_mac_unittest.cc
+++ b/chromium/ipc/attachment_broker_mac_unittest.cc
@@ -20,6 +20,7 @@
#include "base/mac/mach_logging.h"
#include "base/memory/free_deleter.h"
#include "base/memory/shared_memory.h"
+#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/spin_wait.h"
#include "base/time/time.h"
@@ -584,7 +585,7 @@ int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback,
while (true) {
if (globals->message_logging)
LOG(INFO) << "Privileged process spinning run loop.";
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
ProxyListener::Reason reason = listener.get_reason();
if (reason == ProxyListener::CHANNEL_ERROR)
break;
@@ -613,7 +614,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandle) {
CommonSetUp("SendSharedMemoryHandle");
SendMessage1(kDataBuffer1);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -636,7 +637,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleLong) {
std::string buffer(1 << 23, 'a');
SendMessage1(buffer);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -660,7 +661,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendTwoMessagesDifferentSharedMemoryHandle) {
SendMessage1(kDataBuffer1);
SendMessage1(kDataBuffer2);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -701,7 +702,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendTwoMessagesSameSharedMemoryHandle) {
}
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -745,7 +746,7 @@ TEST_F(IPCAttachmentBrokerMacTest,
shared_memory1->handle(), shared_memory2->handle());
sender()->Send(message);
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -786,7 +787,7 @@ TEST_F(IPCAttachmentBrokerMacTest,
shared_memory->handle(), shared_memory->handle());
sender()->Send(message);
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -841,7 +842,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendPosixFDAndMachPort) {
sender()->Send(message);
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -899,10 +900,10 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleToSelf) {
sender()->Send(message);
// Wait until the child process has sent this process a message.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Wait for any asynchronous activity to complete.
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// Get the received attachment.
IPC::BrokerableAttachment::AttachmentId* id = get_observer()->get_id();
@@ -964,7 +965,7 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleChannelProxy) {
get_proxy_listener()->set_listener(get_result_listener());
SendMessage1(kDataBuffer1);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CheckChildResult();
@@ -1006,7 +1007,7 @@ TEST_F(IPCAttachmentBrokerMacTest, ShareToProcess) {
sender()->Send(message);
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -1036,7 +1037,7 @@ TEST_F(IPCAttachmentBrokerMacTest, ShareReadOnlyToProcess) {
sender()->Send(message);
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -1105,10 +1106,10 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleToSelfDelayedPort) {
int received_message_count = 0;
while (received_message_count < kMessagesToTest) {
// Wait until the child process has sent this process a message.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Wait for any asynchronous activity to complete.
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
while (get_proxy_listener()->has_message()) {
get_proxy_listener()->pop_first_message();
@@ -1173,7 +1174,7 @@ TEST_F(IPCAttachmentBrokerMacTest, MemoryUsageLargeMessage) {
std::string test_string(g_large_message_size, 'a');
SendMessage1(test_string);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
@@ -1229,11 +1230,11 @@ TEST_F(IPCAttachmentBrokerMacTest, MemoryUsageManyMessages) {
std::fill(message.begin() + end, message.end(), 'a');
SendMessage1(message);
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
if (get_result_listener()->get_result() == RESULT_UNKNOWN)
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
CommonTearDown();
}
diff --git a/chromium/ipc/ipc.gyp b/chromium/ipc/ipc.gyp
index a11ffe3e0bd..3226899d996 100644
--- a/chromium/ipc/ipc.gyp
+++ b/chromium/ipc/ipc.gyp
@@ -17,9 +17,10 @@
'ipc_target': 1,
},
'dependencies': [
+ 'ipc_interfaces',
'../base/base.gyp:base',
- # TODO(viettrungluu): Needed for base/lazy_instance.h, which is suspect.
- '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../mojo/mojo_public.gyp:mojo_cpp_bindings',
+ '../mojo/mojo_public.gyp:mojo_cpp_system',
],
# TODO(gregoryd): direct_dependent_settings should be shared with the
# 64-bit target, but it doesn't work due to a bug in gyp
@@ -37,15 +38,58 @@
],
},
{
+ 'target_name': 'ipc_interfaces_mojom',
+ 'type': 'none',
+ 'variables': {
+ 'require_interface_bindings': 0,
+ 'mojom_files': [
+ 'ipc.mojom',
+ ],
+ },
+ 'includes': [ '../mojo/mojom_bindings_generator_explicit.gypi' ],
+ },
+ {
+ 'target_name': 'ipc_interfaces',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'ipc_interfaces_mojom',
+ '../base/base.gyp:base',
+ '../mojo/mojo_public.gyp:mojo_interface_bindings_generation',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ },
+ {
+ 'target_name': 'ipc_run_all_unittests',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../base/base.gyp:test_support_base',
+ '../mojo/mojo_edk.gyp:mojo_common_test_support',
+ '../mojo/mojo_edk.gyp:mojo_system_impl',
+ '../testing/gtest.gyp:gtest',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'run_all_unittests.cc',
+ ],
+ },
+ {
'target_name': 'ipc_tests',
'type': '<(gtest_target_type)',
'dependencies': [
'ipc',
+ 'ipc_run_all_unittests',
'test_support_ipc',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base',
'../crypto/crypto.gyp:crypto',
+ '../mojo/mojo_public.gyp:mojo_cpp_bindings',
+ '../mojo/mojo_public.gyp:mojo_cpp_system',
'../testing/gtest.gyp:gtest',
],
'include_dirs': [
@@ -55,6 +99,7 @@
'attachment_broker_mac_unittest.cc',
'attachment_broker_privileged_mac_unittest.cc',
'attachment_broker_privileged_win_unittest.cc',
+ 'ipc_channel_mojo_unittest.cc',
'ipc_channel_posix_unittest.cc',
'ipc_channel_proxy_unittest.cc',
'ipc_channel_reader_unittest.cc',
@@ -63,6 +108,7 @@
'ipc_message_attachment_set_posix_unittest.cc',
'ipc_message_unittest.cc',
'ipc_message_utils_unittest.cc',
+ 'ipc_mojo_bootstrap_unittest.cc',
'ipc_send_fds_test.cc',
'ipc_sync_channel_unittest.cc',
'ipc_sync_message_unittest.cc',
@@ -70,7 +116,6 @@
'ipc_test_messages.h',
'ipc_test_message_generator.cc',
'ipc_test_message_generator.h',
- 'run_all_unittests.cc',
'sync_socket_unittest.cc',
'unix_domain_socket_util_unittest.cc',
],
@@ -106,16 +151,20 @@
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base',
- '../base/base.gyp:test_support_perf',
+ '../mojo/mojo_edk.gyp:mojo_common_test_support',
+ '../mojo/mojo_edk.gyp:mojo_system_impl',
+ '../mojo/mojo_public.gyp:mojo_cpp_bindings',
'../testing/gtest.gyp:gtest',
],
'include_dirs': [
'..'
],
'sources': [
+ 'ipc_mojo_perftest.cc',
'ipc_perftests.cc',
'ipc_test_base.cc',
'ipc_test_base.h',
+ 'run_all_perftests.cc',
],
'conditions': [
['OS == "android"', {
@@ -155,17 +204,34 @@
['OS=="win" and target_arch=="ia32"', {
'targets': [
{
+ 'target_name': 'ipc_interfaces_win64',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'ipc_interfaces_mojom',
+ '../base/base.gyp:base_win64',
+ '../mojo/mojo_public.gyp:mojo_interface_bindings_generation',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'configurations': {
+ 'Common_Base': {
+ 'msvs_target_platform': 'x64',
+ },
+ },
+ },
+ {
'target_name': 'ipc_win64',
'type': '<(component)',
'variables': {
'ipc_target': 1,
},
'dependencies': [
+ 'ipc_interfaces_win64',
'../base/base.gyp:base_win64',
- # TODO(viettrungluu): Needed for base/lazy_instance.h, which is
- # suspect.
- '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64',
'../crypto/crypto.gyp:crypto_nacl_win64',
+ '../mojo/mojo_public.gyp:mojo_cpp_bindings_win64',
+ '../mojo/mojo_public.gyp:mojo_cpp_system_win64',
],
# TODO(gregoryd): direct_dependent_settings should be shared with the
# 32-bit target, but it doesn't work due to a bug in gyp
diff --git a/chromium/ipc/ipc.gypi b/chromium/ipc/ipc.gypi
index da570d230bf..fbfa62f889e 100644
--- a/chromium/ipc/ipc.gypi
+++ b/chromium/ipc/ipc.gypi
@@ -41,6 +41,8 @@
'ipc_channel_factory.h',
'ipc_channel_common.cc',
'ipc_channel_handle.h',
+ 'ipc_channel_mojo.cc',
+ 'ipc_channel_mojo.h',
'ipc_channel_nacl.cc',
'ipc_channel_nacl.h',
'ipc_channel_posix.cc',
@@ -69,11 +71,21 @@
'ipc_message_generator.cc',
'ipc_message_generator.h',
'ipc_message_macros.h',
+ 'ipc_message_pipe_reader.cc',
+ 'ipc_message_pipe_reader.h',
'ipc_message_start.h',
'ipc_message_templates.h',
'ipc_message_templates_impl.h',
'ipc_message_utils.cc',
'ipc_message_utils.h',
+ 'ipc_mojo_bootstrap.cc',
+ 'ipc_mojo_bootstrap.h',
+ 'ipc_mojo_handle_attachment.cc',
+ 'ipc_mojo_handle_attachment.h',
+ 'ipc_mojo_message_helper.cc',
+ 'ipc_mojo_message_helper.h',
+ 'ipc_mojo_param_traits.cc',
+ 'ipc_mojo_param_traits.h',
'ipc_param_traits.h',
'ipc_platform_file.cc',
'ipc_platform_file.h',
@@ -98,6 +110,8 @@
'message_filter_router.h',
'message_router.cc',
'message_router.h',
+ 'mojo_event.cc',
+ 'mojo_event.h',
'param_traits_log_macros.h',
'param_traits_macros.h',
'param_traits_read_macros.h',
diff --git a/chromium/ipc/mojo/ipc.mojom b/chromium/ipc/ipc.mojom
index d15a23c3e95..681da120f70 100644
--- a/chromium/ipc/mojo/ipc.mojom
+++ b/chromium/ipc/ipc.mojom
@@ -9,6 +9,7 @@ struct SerializedHandle {
enum Type {
MOJO_HANDLE,
+ PLATFORM_FILE,
WIN_HANDLE,
MACH_PORT,
};
diff --git a/chromium/ipc/ipc_channel.h b/chromium/ipc/ipc_channel.h
index fdd0b352964..09baf6cf140 100644
--- a/chromium/ipc/ipc_channel.h
+++ b/chromium/ipc/ipc_channel.h
@@ -223,6 +223,17 @@ class IPC_EXPORT Channel : public Endpoint {
static std::string GenerateVerifiedChannelID(const std::string& prefix);
#endif
+ // Generates a pair of channel handles that can be used as the client and
+ // server ends of a ChannelMojo. |name_postfix| is appended to the end of the
+ // handle name to help identify the handles.
+ //
+ // Note, when using ChannelMojo, |ChannelHandle::name| serves no functional
+ // purpose other than to identify the channel in logging.
+ static void GenerateMojoChannelHandlePair(
+ const std::string& name_postfix,
+ IPC::ChannelHandle* handle0,
+ IPC::ChannelHandle* handle1);
+
#if defined(OS_LINUX)
// Sandboxed processes live in a PID namespace, so when sending the IPC hello
// message from client to server we need to send the PID from the global
diff --git a/chromium/ipc/ipc_channel_common.cc b/chromium/ipc/ipc_channel_common.cc
index b5dcb1ab4bf..3002b665985 100644
--- a/chromium/ipc/ipc_channel_common.cc
+++ b/chromium/ipc/ipc_channel_common.cc
@@ -4,6 +4,8 @@
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_channel_mojo.h"
+#include "mojo/public/cpp/system/message_pipe.h"
namespace IPC {
@@ -11,6 +13,11 @@ namespace IPC {
std::unique_ptr<Channel> Channel::CreateClient(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
+ if (channel_handle.mojo_handle.is_valid()) {
+ return ChannelMojo::Create(
+ mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
+ Channel::MODE_CLIENT, listener);
+ }
return Channel::Create(channel_handle, Channel::MODE_CLIENT, listener);
}
@@ -42,9 +49,38 @@ std::unique_ptr<Channel> Channel::CreateOpenNamedServer(
std::unique_ptr<Channel> Channel::CreateServer(
const IPC::ChannelHandle& channel_handle,
Listener* listener) {
+ if (channel_handle.mojo_handle.is_valid()) {
+ return ChannelMojo::Create(
+ mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
+ Channel::MODE_SERVER, listener);
+ }
return Channel::Create(channel_handle, Channel::MODE_SERVER, listener);
}
+// static
+void Channel::GenerateMojoChannelHandlePair(
+ const std::string& name_postfix,
+ IPC::ChannelHandle* handle0,
+ IPC::ChannelHandle* handle1) {
+ DCHECK_NE(handle0, handle1);
+ // |name| is only used for logging and to aid developers in debugging. It
+ // doesn't _need_ to be unique, but this string is probably more useful than a
+ // generic "ChannelMojo".
+#if !defined(OS_NACL_SFI)
+ std::string name = "ChannelMojo-" + GenerateUniqueRandomChannelID();
+#else
+ std::string name = "ChannelMojo";
+#endif
+ if (!name_postfix.empty()) {
+ name += "-" + name_postfix;
+ }
+ mojo::MessagePipe message_pipe;
+ *handle0 = ChannelHandle(name);
+ handle0->mojo_handle = message_pipe.handle0.release();
+ *handle1 = ChannelHandle(name);
+ handle1->mojo_handle = message_pipe.handle1.release();
+}
+
Channel::~Channel() {
}
diff --git a/chromium/ipc/ipc_channel_factory.cc b/chromium/ipc/ipc_channel_factory.cc
index 746b19a3844..dbb24c087e0 100644
--- a/chromium/ipc/ipc_channel_factory.cc
+++ b/chromium/ipc/ipc_channel_factory.cc
@@ -5,6 +5,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "ipc/ipc_channel_factory.h"
+#include "ipc/ipc_channel_mojo.h"
namespace IPC {
@@ -20,6 +21,10 @@ class PlatformChannelFactory : public ChannelFactory {
}
std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
+ if (handle_.mojo_handle.is_valid()) {
+ return ChannelMojo::Create(
+ mojo::ScopedMessagePipeHandle(handle_.mojo_handle), mode_, listener);
+ }
return Channel::Create(handle_, mode_, listener);
}
diff --git a/chromium/ipc/ipc_channel_handle.h b/chromium/ipc/ipc_channel_handle.h
index 1b6fd8ca205..2e9dc3e57f3 100644
--- a/chromium/ipc/ipc_channel_handle.h
+++ b/chromium/ipc/ipc_channel_handle.h
@@ -8,6 +8,7 @@
#include <string>
#include "build/build_config.h"
+#include "mojo/public/cpp/system/message_pipe.h"
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
@@ -47,6 +48,7 @@ struct ChannelHandle {
ChannelHandle(const std::string& n, const base::FileDescriptor& s)
: name(n), socket(s) {}
#endif // defined(OS_POSIX)
+ ChannelHandle(mojo::MessagePipeHandle h) : mojo_handle(h) {}
std::string name;
#if defined(OS_POSIX)
@@ -60,6 +62,7 @@ struct ChannelHandle {
};
PipeHandle pipe;
#endif // defined (OS_WIN)
+ mojo::MessagePipeHandle mojo_handle;
};
} // namespace IPC
diff --git a/chromium/ipc/mojo/ipc_channel_mojo.cc b/chromium/ipc/ipc_channel_mojo.cc
index 74fec87c6ee..66b0768ca1f 100644
--- a/chromium/ipc/mojo/ipc_channel_mojo.cc
+++ b/chromium/ipc/ipc_channel_mojo.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_channel_mojo.h"
+#include "ipc/ipc_channel_mojo.h"
#include <stddef.h>
#include <stdint.h>
@@ -22,12 +22,12 @@
#include "ipc/ipc_logging.h"
#include "ipc/ipc_message_attachment_set.h"
#include "ipc/ipc_message_macros.h"
-#include "ipc/mojo/ipc_mojo_bootstrap.h"
-#include "ipc/mojo/ipc_mojo_handle_attachment.h"
-#include "mojo/edk/embedder/embedder.h"
+#include "ipc/ipc_mojo_bootstrap.h"
+#include "ipc/ipc_mojo_handle_attachment.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/system/platform_handle.h"
-#if defined(OS_POSIX) && !defined(OS_NACL)
+#if defined(OS_POSIX)
#include "ipc/ipc_platform_file_attachment_posix.h"
#endif
@@ -70,21 +70,40 @@ mojom::SerializedHandlePtr CreateSerializedHandle(
return serialized_handle;
}
-MojoResult WrapPlatformHandle(mojo::edk::ScopedPlatformHandle handle,
+MojoResult WrapPlatformHandle(base::PlatformFile handle,
mojom::SerializedHandle::Type type,
mojom::SerializedHandlePtr* serialized) {
+ mojo::ScopedHandle wrapped_handle = mojo::WrapPlatformFile(handle);
+ if (!wrapped_handle.is_valid())
+ return MOJO_RESULT_UNKNOWN;
+
+ *serialized = CreateSerializedHandle(std::move(wrapped_handle), type);
+ return MOJO_RESULT_OK;
+}
+
+#if defined(OS_MACOSX)
+
+MojoResult WrapMachPort(mach_port_t mach_port,
+ mojom::SerializedHandlePtr* serialized) {
+ MojoPlatformHandle platform_handle = {
+ sizeof(MojoPlatformHandle), MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT,
+ static_cast<uint64_t>(mach_port)
+ };
+
MojoHandle wrapped_handle;
- MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper(
- std::move(handle), &wrapped_handle);
- if (wrap_result != MOJO_RESULT_OK)
- return wrap_result;
+ MojoResult result = MojoWrapPlatformHandle(&platform_handle, &wrapped_handle);
+ if (result != MOJO_RESULT_OK)
+ return result;
*serialized = CreateSerializedHandle(
- mojo::MakeScopedHandle(mojo::Handle(wrapped_handle)), type);
+ mojo::MakeScopedHandle(mojo::Handle(wrapped_handle)),
+ mojom::SerializedHandle::Type::MACH_PORT);
return MOJO_RESULT_OK;
}
-#if defined(OS_POSIX) && !defined(OS_NACL)
+#endif
+
+#if defined(OS_POSIX)
base::ScopedFD TakeOrDupFile(internal::PlatformFileAttachment* attachment) {
return attachment->Owns() ? base::ScopedFD(attachment->TakePlatformFile())
@@ -101,7 +120,7 @@ MojoResult WrapAttachmentImpl(MessageAttachment* attachment,
mojom::SerializedHandle::Type::MOJO_HANDLE);
return MOJO_RESULT_OK;
}
-#if defined(OS_POSIX) && !defined(OS_NACL)
+#if defined(OS_POSIX)
if (attachment->GetType() == MessageAttachment::TYPE_PLATFORM_FILE) {
// We dup() the handles in IPC::Message to transmit.
// IPC::MessageAttachmentSet has intricate lifecycle semantics
@@ -113,9 +132,8 @@ MojoResult WrapAttachmentImpl(MessageAttachment* attachment,
return MOJO_RESULT_UNKNOWN;
}
- return WrapPlatformHandle(mojo::edk::ScopedPlatformHandle(
- mojo::edk::PlatformHandle(file.release())),
- mojom::SerializedHandle::Type::MOJO_HANDLE,
+ return WrapPlatformHandle(file.release(),
+ mojom::SerializedHandle::Type::PLATFORM_FILE,
serialized);
}
#endif
@@ -126,10 +144,8 @@ MojoResult WrapAttachmentImpl(MessageAttachment* attachment,
BrokerableAttachment::MACH_PORT);
internal::MachPortAttachmentMac& mach_port_attachment =
static_cast<internal::MachPortAttachmentMac&>(*attachment);
- MojoResult result = WrapPlatformHandle(
- mojo::edk::ScopedPlatformHandle(
- mojo::edk::PlatformHandle(mach_port_attachment.get_mach_port())),
- mojom::SerializedHandle::Type::MACH_PORT, serialized);
+ MojoResult result = WrapMachPort(mach_port_attachment.get_mach_port(),
+ serialized);
mach_port_attachment.reset_mach_port_ownership();
return result;
#elif defined(OS_WIN)
@@ -140,8 +156,7 @@ MojoResult WrapAttachmentImpl(MessageAttachment* attachment,
internal::HandleAttachmentWin& handle_attachment =
static_cast<internal::HandleAttachmentWin&>(*attachment);
MojoResult result = WrapPlatformHandle(
- mojo::edk::ScopedPlatformHandle(
- mojo::edk::PlatformHandle(handle_attachment.get_handle())),
+ handle_attachment.get_handle(),
mojom::SerializedHandle::Type::WIN_HANDLE, serialized);
handle_attachment.reset_handle_ownership();
return result;
@@ -170,25 +185,37 @@ MojoResult UnwrapAttachment(mojom::SerializedHandlePtr handle,
new IPC::internal::MojoHandleAttachment(std::move(handle->the_handle));
return MOJO_RESULT_OK;
}
- mojo::edk::ScopedPlatformHandle platform_handle;
- MojoResult unwrap_result = mojo::edk::PassWrappedPlatformHandle(
+ MojoPlatformHandle platform_handle = { sizeof(MojoPlatformHandle), 0, 0 };
+ MojoResult unwrap_result = MojoUnwrapPlatformHandle(
handle->the_handle.release().value(), &platform_handle);
if (unwrap_result != MOJO_RESULT_OK)
return unwrap_result;
+#if defined(OS_POSIX)
+ if (handle->type == mojom::SerializedHandle::Type::PLATFORM_FILE) {
+ base::PlatformFile file = base::kInvalidPlatformFile;
+ if (platform_handle.type == MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR)
+ file = static_cast<base::PlatformFile>(platform_handle.value);
+ *attachment = new internal::PlatformFileAttachment(file);
+ return MOJO_RESULT_OK;
+ }
+#endif // defined(OS_POSIX)
#if defined(OS_MACOSX)
- if (handle->type == mojom::SerializedHandle::Type::MACH_PORT &&
- platform_handle.get().type == mojo::edk::PlatformHandle::Type::MACH) {
+ if (handle->type == mojom::SerializedHandle::Type::MACH_PORT) {
+ mach_port_t mach_port = MACH_PORT_NULL;
+ if (platform_handle.type == MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT)
+ mach_port = static_cast<mach_port_t>(platform_handle.value);
*attachment = new internal::MachPortAttachmentMac(
- platform_handle.release().port,
- internal::MachPortAttachmentMac::FROM_WIRE);
+ mach_port, internal::MachPortAttachmentMac::FROM_WIRE);
return MOJO_RESULT_OK;
}
#endif // defined(OS_MACOSX)
#if defined(OS_WIN)
if (handle->type == mojom::SerializedHandle::Type::WIN_HANDLE) {
+ base::PlatformFile handle = base::kInvalidPlatformFile;
+ if (platform_handle.type == MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE)
+ handle = reinterpret_cast<base::PlatformFile>(platform_handle.value);
*attachment = new internal::HandleAttachmentWin(
- platform_handle.release().handle,
- internal::HandleAttachmentWin::FROM_WIRE);
+ handle, internal::HandleAttachmentWin::FROM_WIRE);
return MOJO_RESULT_OK;
}
#endif // defined(OS_WIN)
@@ -379,7 +406,7 @@ void ChannelMojo::OnMessageReceived(const Message& message) {
listener_->OnBadMessageReceived(message);
}
-#if defined(OS_POSIX) && !defined(OS_NACL)
+#if defined(OS_POSIX) && !defined(OS_NACL_SFI)
int ChannelMojo::GetClientFileDescriptor() const {
return -1;
}
@@ -387,7 +414,7 @@ int ChannelMojo::GetClientFileDescriptor() const {
base::ScopedFD ChannelMojo::TakeClientFileDescriptor() {
return base::ScopedFD(GetClientFileDescriptor());
}
-#endif // defined(OS_POSIX) && !defined(OS_NACL)
+#endif // defined(OS_POSIX) && !defined(OS_NACL_SFI)
// static
MojoResult ChannelMojo::ReadFromMessageAttachmentSet(
diff --git a/chromium/ipc/mojo/ipc_channel_mojo.h b/chromium/ipc/ipc_channel_mojo.h
index a8a28ecc7fc..774a82a2627 100644
--- a/chromium/ipc/mojo/ipc_channel_mojo.h
+++ b/chromium/ipc/ipc_channel_mojo.h
@@ -20,9 +20,8 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_factory.h"
#include "ipc/ipc_export.h"
-#include "ipc/mojo/ipc_message_pipe_reader.h"
-#include "ipc/mojo/ipc_mojo_bootstrap.h"
-#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "ipc/ipc_message_pipe_reader.h"
+#include "ipc/ipc_mojo_bootstrap.h"
#include "mojo/public/cpp/system/core.h"
namespace IPC {
@@ -36,7 +35,7 @@ namespace IPC {
// TODO(morrita): Add APIs to create extra MessagePipes to let
// Mojo-based objects talk over this Channel.
//
-class IPC_MOJO_EXPORT ChannelMojo
+class IPC_EXPORT ChannelMojo
: public Channel,
public MojoBootstrap::Delegate,
public NON_EXPORTED_BASE(internal::MessagePipeReader::Delegate) {
@@ -64,10 +63,10 @@ class IPC_MOJO_EXPORT ChannelMojo
base::ProcessId GetPeerPID() const override;
base::ProcessId GetSelfPID() const override;
-#if defined(OS_POSIX) && !defined(OS_NACL)
+#if defined(OS_POSIX) && !defined(OS_NACL_SFI)
int GetClientFileDescriptor() const override;
base::ScopedFD TakeClientFileDescriptor() override;
-#endif // defined(OS_POSIX) && !defined(OS_NACL)
+#endif // defined(OS_POSIX) && !defined(OS_NACL_SFI)
// These access protected API of IPC::Message, which has ChannelMojo
// as a friend class.
diff --git a/chromium/ipc/mojo/ipc_channel_mojo_unittest.cc b/chromium/ipc/ipc_channel_mojo_unittest.cc
index 613b2e26116..eec011b7704 100644
--- a/chromium/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/chromium/ipc/ipc_channel_mojo_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_channel_mojo.h"
+#include "ipc/ipc_channel_mojo.h"
#include <stddef.h>
#include <stdint.h>
@@ -11,6 +11,7 @@
#include "base/base_paths.h"
#include "base/files/file.h"
+#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
#include "base/path_service.h"
#include "base/pickle.h"
@@ -22,12 +23,11 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_message.h"
+#include "ipc/ipc_mojo_handle_attachment.h"
+#include "ipc/ipc_mojo_message_helper.h"
+#include "ipc/ipc_mojo_param_traits.h"
#include "ipc/ipc_test_base.h"
#include "ipc/ipc_test_channel_listener.h"
-#include "ipc/mojo/ipc_channel_mojo.h"
-#include "ipc/mojo/ipc_mojo_handle_attachment.h"
-#include "ipc/mojo/ipc_mojo_message_helper.h"
-#include "ipc/mojo/ipc_mojo_param_traits.h"
#include "mojo/edk/test/mojo_test_base.h"
#include "mojo/edk/test/multiprocess_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -182,7 +182,7 @@ TEST_F(IPCChannelMojoTest, ConnectedFromClient) {
IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
@@ -200,7 +200,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoTestClient, ChannelClient) {
listener.Init(channel());
IPC::TestChannelListener::SendOneMessage(channel(), "hello from child");
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(listener.is_connected_called());
EXPECT_TRUE(listener.HasSentAll());
@@ -245,7 +245,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoErraticTestClient,
ListenerThatQuits listener;
Connect(&listener);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
Close();
}
@@ -267,7 +267,7 @@ TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) {
overly_large_data.c_str());
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
@@ -325,11 +325,8 @@ class HandleSendingHelper {
}
#if defined(OS_POSIX)
- static base::FilePath GetSendingFilePath() {
- base::FilePath path;
- bool ok = PathService::Get(base::DIR_CACHE, &path);
- EXPECT_TRUE(ok);
- return path.Append("ListenerThatExpectsFile.txt");
+ static base::FilePath GetSendingFilePath(const base::FilePath& dir_path) {
+ return dir_path.Append("ListenerThatExpectsFile.txt");
}
static void WriteFile(IPC::Message* message, base::File& file) {
@@ -362,6 +359,9 @@ class HandleSendingHelper {
base::ScopedFD fd;
scoped_refptr<base::Pickle::Attachment> attachment;
EXPECT_TRUE(message.ReadAttachment(iter, &attachment));
+ EXPECT_EQ(IPC::MessageAttachment::TYPE_PLATFORM_FILE,
+ static_cast<IPC::MessageAttachment*>(attachment.get())
+ ->GetType());
base::File file(static_cast<IPC::MessageAttachment*>(attachment.get())
->TakePlatformFile());
std::string content(GetSendingFileContent().size(), ' ');
@@ -380,12 +380,13 @@ class ListenerThatExpectsMessagePipe : public IPC::Listener {
bool OnMessageReceived(const IPC::Message& message) override {
base::PickleIterator iter(message);
HandleSendingHelper::ReadReceivedPipe(message, &iter);
- base::MessageLoop::current()->QuitWhenIdle();
ListenerThatExpectsOK::SendOK(sender_);
return true;
}
- void OnChannelError() override { NOTREACHED(); }
+ void OnChannelError() override {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
void set_sender(IPC::Sender* sender) { sender_ = sender; }
@@ -403,7 +404,7 @@ TEST_F(IPCChannelMojoTest, SendMessagePipe) {
TestingMessagePipe pipe;
HandleSendingHelper::WritePipeThenSend(channel(), &pipe);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
EXPECT_TRUE(WaitForClientShutdown());
@@ -416,7 +417,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoTestSendMessagePipeClient,
Connect(&listener);
listener.set_sender(channel());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
Close();
}
@@ -457,12 +458,14 @@ class ListenerThatExpectsMessagePipeUsingParamTrait : public IPC::Listener {
MojoClose(handle.value());
}
- base::MessageLoop::current()->QuitWhenIdle();
ListenerThatExpectsOK::SendOK(sender_);
return true;
}
- void OnChannelError() override { NOTREACHED(); }
+ void OnChannelError() override {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
+
void set_sender(IPC::Sender* sender) { sender_ = sender; }
private:
@@ -478,7 +481,7 @@ class ParamTraitMessagePipeClient : public ChannelClient {
Connect(&listener);
listener.set_sender(channel());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
Close();
}
@@ -499,7 +502,7 @@ TEST_F(IPCChannelMojoTest, ParamTraitValidMessagePipe) {
WriteOK(pipe.self.get());
channel()->Send(message.release());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
EXPECT_TRUE(WaitForClientShutdown());
@@ -524,7 +527,7 @@ TEST_F(IPCChannelMojoTest, ParamTraitInvalidMessagePipe) {
invalid_handle);
channel()->Send(message.release());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
EXPECT_TRUE(WaitForClientShutdown());
@@ -543,7 +546,7 @@ TEST_F(IPCChannelMojoTest, SendFailAfterClose) {
CreateChannel(&listener);
ASSERT_TRUE(ConnectChannel());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
ASSERT_FALSE(channel()->Send(new IPC::Message()));
@@ -574,7 +577,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoTestSendOkClient,
Connect(&listener);
listener.set_sender(channel());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
Close();
}
@@ -589,12 +592,13 @@ class ListenerThatExpectsFile : public IPC::Listener {
bool OnMessageReceived(const IPC::Message& message) override {
base::PickleIterator iter(message);
HandleSendingHelper::ReadReceivedFile(message, &iter);
- base::MessageLoop::current()->QuitWhenIdle();
ListenerThatExpectsOK::SendOK(sender_);
return true;
}
- void OnChannelError() override { NOTREACHED(); }
+ void OnChannelError() override {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
void set_sender(IPC::Sender* sender) { sender_ = sender; }
@@ -609,11 +613,13 @@ TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
CreateChannel(&listener);
ASSERT_TRUE(ConnectChannel());
- base::File file(HandleSendingHelper::GetSendingFilePath(),
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ base::File file(HandleSendingHelper::GetSendingFilePath(temp_dir.path()),
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
base::File::FLAG_READ);
HandleSendingHelper::WriteFileThenSend(channel(), file);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
@@ -627,7 +633,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(IPCChannelMojoTestSendPlatformHandleClient,
Connect(&listener);
listener.set_sender(channel());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
Close();
}
@@ -642,12 +648,13 @@ class ListenerThatExpectsFileAndPipe : public IPC::Listener {
base::PickleIterator iter(message);
HandleSendingHelper::ReadReceivedFile(message, &iter);
HandleSendingHelper::ReadReceivedPipe(message, &iter);
- base::MessageLoop::current()->QuitWhenIdle();
ListenerThatExpectsOK::SendOK(sender_);
return true;
}
- void OnChannelError() override { NOTREACHED(); }
+ void OnChannelError() override {
+ base::MessageLoop::current()->QuitWhenIdle();
+ }
void set_sender(IPC::Sender* sender) { sender_ = sender; }
@@ -662,13 +669,15 @@ TEST_F(IPCChannelMojoTest, SendPlatformHandleAndPipe) {
CreateChannel(&listener);
ASSERT_TRUE(ConnectChannel());
- base::File file(HandleSendingHelper::GetSendingFilePath(),
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ base::File file(HandleSendingHelper::GetSendingFilePath(temp_dir.path()),
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
base::File::FLAG_READ);
TestingMessagePipe pipe;
HandleSendingHelper::WriteFileAndPipeThenSend(channel(), file, &pipe);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
channel()->Close();
EXPECT_TRUE(WaitForClientShutdown());
@@ -682,7 +691,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(
Connect(&listener);
listener.set_sender(channel());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
Close();
}
diff --git a/chromium/ipc/ipc_channel_posix_unittest.cc b/chromium/ipc/ipc_channel_posix_unittest.cc
index 0ed66797aa1..830ea300399 100644
--- a/chromium/ipc/ipc_channel_posix_unittest.cc
+++ b/chromium/ipc/ipc_channel_posix_unittest.cc
@@ -23,6 +23,7 @@
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/process.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
@@ -177,7 +178,7 @@ void IPCChannelPosixTest::SpinRunLoop(base::TimeDelta delay) {
// current run loop on any channel activity.
loop->task_runner()->PostDelayedTask(FROM_HERE, loop->QuitWhenIdleClosure(),
delay);
- loop->Run();
+ base::RunLoop().Run();
}
TEST_F(IPCChannelPosixTest, BasicListen) {
diff --git a/chromium/ipc/ipc_channel_proxy_unittest.cc b/chromium/ipc/ipc_channel_proxy_unittest.cc
index 5367157ec40..75e6b95b520 100644
--- a/chromium/ipc/ipc_channel_proxy_unittest.cc
+++ b/chromium/ipc/ipc_channel_proxy_unittest.cc
@@ -9,6 +9,7 @@
#include <memory>
#include "base/pickle.h"
+#include "base/run_loop.h"
#include "base/threading/thread.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_test_base.h"
@@ -260,7 +261,7 @@ class IPCChannelProxyTest : public IPCTestBase {
void SendQuitMessageAndWaitForIdle() {
sender()->Send(new WorkerMsg_Quit);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(WaitForClientShutdown());
}
@@ -400,7 +401,7 @@ class IPCChannelBadMessageTest : public IPCTestBase {
void SendQuitMessageAndWaitForIdle() {
sender()->Send(new WorkerMsg_Quit);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(WaitForClientShutdown());
}
@@ -431,7 +432,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ChannelProxyClient) {
CHECK(channel->Connect());
listener.Init(channel.get());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
return 0;
}
diff --git a/chromium/ipc/ipc_channel_unittest.cc b/chromium/ipc/ipc_channel_unittest.cc
index e423b896475..f5ee2061006 100644
--- a/chromium/ipc/ipc_channel_unittest.cc
+++ b/chromium/ipc/ipc_channel_unittest.cc
@@ -14,6 +14,7 @@
#include <string>
#include "base/pickle.h"
+#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
@@ -38,7 +39,7 @@ TEST_F(IPCChannelTest, ChannelTest) {
IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Close the channel so the client's OnChannelError() gets fired.
channel()->Close();
@@ -105,7 +106,7 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(WaitForClientShutdown());
@@ -145,7 +146,7 @@ TEST_F(IPCChannelTest, MAYBE_SendMessageInChannelConnected) {
IPC::TestChannelListener::SendOneMessage(sender(), "hello from parent");
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Close the channel so the client's OnChannelError() gets fired.
channel()->Close();
@@ -165,7 +166,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(GenericClient) {
listener.Init(channel.get());
IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child");
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
return 0;
}
diff --git a/chromium/ipc/ipc_channel_win.h b/chromium/ipc/ipc_channel_win.h
index 2ea865ea178..8e36ea98cdc 100644
--- a/chromium/ipc/ipc_channel_win.h
+++ b/chromium/ipc/ipc_channel_win.h
@@ -121,9 +121,6 @@ class ChannelWin : public Channel,
// Determines if we should validate a client's secret on connection.
bool validate_client_;
- // Tracks the lifetime of this object, for debugging purposes.
- uint32_t debug_flags_;
-
// This is a unique per-channel value used to authenticate the client end of
// a connection. If the value is non-zero, the client passes it in the hello
// and the host validates. (We don't send the zero value fto preserve IPC
diff --git a/chromium/ipc/ipc_export.h b/chromium/ipc/ipc_export.h
index 9f8411c3cee..e1cbe8891f1 100644
--- a/chromium/ipc/ipc_export.h
+++ b/chromium/ipc/ipc_export.h
@@ -17,12 +17,6 @@
#define IPC_EXPORT __declspec(dllimport)
#endif // defined(IPC_IMPLEMENTATION)
-#if defined(IPC_MOJO_IMPLEMENTATION)
-#define IPC_MOJO_EXPORT __declspec(dllexport)
-#else
-#define IPC_MOJO_EXPORT __declspec(dllimport)
-#endif // defined(IPC_MOJO_IMPLEMENTATION)
-
#else // defined(WIN32)
#if defined(IPC_IMPLEMENTATION)
@@ -31,17 +25,10 @@
#define IPC_EXPORT
#endif
-#if defined(IPC_MOJO_IMPLEMENTATION)
-#define IPC_MOJO_EXPORT __attribute__((visibility("default")))
-#else
-#define IPC_MOJO_EXPORT
-#endif
-
#endif
#else // defined(COMPONENT_BUILD)
#define IPC_EXPORT
-#define IPC_MOJO_EXPORT
#endif
#endif // IPC_IPC_EXPORT_H_
diff --git a/chromium/ipc/ipc_fuzzing_tests.cc b/chromium/ipc/ipc_fuzzing_tests.cc
index f197a6b8164..373b2a7fe6d 100644
--- a/chromium/ipc/ipc_fuzzing_tests.cc
+++ b/chromium/ipc/ipc_fuzzing_tests.cc
@@ -11,6 +11,7 @@
#include <string>
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
@@ -244,7 +245,7 @@ class FuzzerClientListener : public SimpleListener {
private:
bool MsgHandlerInternal(uint32_t type_id) {
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
if (NULL == last_msg_)
return false;
if (FUZZER_ROUTING_ID != last_msg_->routing_id())
@@ -264,7 +265,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(FuzzServerClient) {
IPCTestBase::GetChannelName("FuzzServerClient"), &listener));
CHECK(channel->Connect());
listener.Init(channel.get());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
return 0;
}
diff --git a/chromium/ipc/ipc_logging.cc b/chromium/ipc/ipc_logging.cc
index 693c71d072b..faf4a434184 100644
--- a/chromium/ipc/ipc_logging.cc
+++ b/chromium/ipc/ipc_logging.cc
@@ -16,11 +16,11 @@
#include "base/command_line.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.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"
@@ -50,7 +50,7 @@ Logging::Logging()
enabled_color_(false),
queue_invoke_later_pending_(false),
sender_(NULL),
- main_thread_(base::MessageLoop::current()),
+ main_thread_(base::ThreadTaskRunnerHandle::Get()),
consumer_(NULL) {
#if defined(OS_WIN)
// getenv triggers an unsafe warning. Simply check how big of a buffer
@@ -163,10 +163,10 @@ void Logging::OnPostDispatchMessage(const Message& message,
LogData data;
GenerateLogData(channel_id, message, &data, true);
- if (base::MessageLoop::current() == main_thread_) {
+ if (main_thread_->BelongsToCurrentThread()) {
Log(data);
} else {
- main_thread_->task_runner()->PostTask(
+ main_thread_->PostTask(
FROM_HERE, base::Bind(&Logging::Log, base::Unretained(this), data));
}
}
diff --git a/chromium/ipc/ipc_logging.h b/chromium/ipc/ipc_logging.h
index 523413501d1..e567921624e 100644
--- a/chromium/ipc/ipc_logging.h
+++ b/chromium/ipc/ipc_logging.h
@@ -14,8 +14,9 @@
#include <vector>
#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop.h"
+#include "base/single_thread_task_runner.h"
#include "ipc/ipc_export.h"
// Logging function. |name| is a string in ASCII and |params| is a string in
@@ -114,7 +115,7 @@ class IPC_EXPORT Logging {
bool queue_invoke_later_pending_;
Sender* sender_;
- base::MessageLoop* main_thread_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
Consumer* consumer_;
diff --git a/chromium/ipc/mojo/ipc_message_pipe_reader.cc b/chromium/ipc/ipc_message_pipe_reader.cc
index 08bbcd4c2c2..da2d85d981a 100644
--- a/chromium/ipc/mojo/ipc_message_pipe_reader.cc
+++ b/chromium/ipc/ipc_message_pipe_reader.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_message_pipe_reader.h"
+#include "ipc/ipc_message_pipe_reader.h"
#include <stdint.h>
@@ -15,7 +15,7 @@
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
-#include "ipc/mojo/ipc_channel_mojo.h"
+#include "ipc/ipc_channel_mojo.h"
#include "mojo/public/cpp/bindings/message.h"
namespace IPC {
diff --git a/chromium/ipc/mojo/ipc_message_pipe_reader.h b/chromium/ipc/ipc_message_pipe_reader.h
index 661ffde1a07..b15579df3c8 100644
--- a/chromium/ipc/mojo/ipc_message_pipe_reader.h
+++ b/chromium/ipc/ipc_message_pipe_reader.h
@@ -14,8 +14,8 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/threading/thread_checker.h"
+#include "ipc/ipc.mojom.h"
#include "ipc/ipc_message.h"
-#include "ipc/mojo/ipc.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/message_pipe.h"
diff --git a/chromium/ipc/ipc_message_start.h b/chromium/ipc/ipc_message_start.h
index 453a4bddd15..5ee4fe1486a 100644
--- a/chromium/ipc/ipc_message_start.h
+++ b/chromium/ipc/ipc_message_start.h
@@ -27,12 +27,10 @@ enum IPCMessageStart {
PpapiMsgStart,
FirefoxImporterUnittestMsgStart,
FileUtilitiesMsgStart,
- MimeRegistryMsgStart,
DatabaseMsgStart,
DOMStorageMsgStart,
IndexedDBMsgStart,
SpeechRecognitionMsgStart,
- PepperMsgStart,
AutofillMsgStart,
SafeBrowsingMsgStart,
P2PMsgStart,
@@ -92,7 +90,6 @@ enum IPCMessageStart {
MediaStreamTrackMetricsHostMsgStart,
ChromeExtensionMsgStart,
TranslateMsgStart,
- CldDataProviderMsgStart,
PushMessagingMsgStart,
GinJavaBridgeMsgStart,
ChromeUtilityPrintingMsgStart,
@@ -127,11 +124,12 @@ enum IPCMessageStart {
ArcInstanceMsgStart,
ArcInstanceHostMsgStart,
DistillerMsgStart,
- StartupMetricMsgStart,
ArcCameraMsgStart,
DWriteFontProxyMsgStart,
MediaPlayerDelegateMsgStart,
SurfaceViewManagerMsgStart,
+ ExtensionWorkerMsgStart,
+ SubresourceFilterMsgStart,
LastIPCMsgStart // Must come last.
};
diff --git a/chromium/ipc/ipc_message_utils.cc b/chromium/ipc/ipc_message_utils.cc
index f31add1da14..60c12ab60f9 100644
--- a/chromium/ipc/ipc_message_utils.cc
+++ b/chromium/ipc/ipc_message_utils.cc
@@ -18,6 +18,7 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_attachment.h"
#include "ipc/ipc_message_attachment_set.h"
+#include "ipc/ipc_mojo_param_traits.h"
#if defined(OS_POSIX)
#include "ipc/ipc_platform_file_attachment_posix.h"
@@ -126,9 +127,8 @@ void GetValueSize(base::PickleSizer* sizer,
case base::Value::TYPE_LIST: {
sizer->AddInt();
const base::ListValue* list = static_cast<const base::ListValue*>(value);
- for (base::ListValue::const_iterator it = list->begin();
- it != list->end(); ++it) {
- GetValueSize(sizer, *it, recursion + 1);
+ for (const auto& entry : *list) {
+ GetValueSize(sizer, entry.get(), recursion + 1);
}
break;
}
@@ -199,9 +199,8 @@ void WriteValue(base::Pickle* m, const base::Value* value, int recursion) {
case base::Value::TYPE_LIST: {
const base::ListValue* list = static_cast<const base::ListValue*>(value);
WriteParam(m, static_cast<int>(list->GetSize()));
- for (base::ListValue::const_iterator it = list->begin();
- it != list->end(); ++it) {
- WriteValue(m, *it, recursion + 1);
+ for (const auto& entry : *list) {
+ WriteValue(m, entry.get(), recursion + 1);
}
break;
}
@@ -300,7 +299,9 @@ bool ReadValue(const base::Pickle* m,
int length;
if (!iter->ReadData(&data, &length))
return false;
- *value = base::BinaryValue::CreateWithCopiedBuffer(data, length);
+ std::unique_ptr<base::BinaryValue> val =
+ base::BinaryValue::CreateWithCopiedBuffer(data, length);
+ *value = val.release();
break;
}
case base::Value::TYPE_DICTIONARY: {
@@ -638,7 +639,8 @@ void ParamTraits<base::DictionaryValue>::Log(const param_type& p,
void ParamTraits<base::FileDescriptor>::GetSize(base::PickleSizer* sizer,
const param_type& p) {
GetParamSize(sizer, p.fd >= 0);
- sizer->AddAttachment();
+ if (p.fd >= 0)
+ sizer->AddAttachment();
}
void ParamTraits<base::FileDescriptor>::Write(base::Pickle* m,
@@ -1002,6 +1004,7 @@ void ParamTraits<IPC::ChannelHandle>::GetSize(base::PickleSizer* sizer,
#if defined(OS_POSIX)
GetParamSize(sizer, p.socket);
#endif
+ GetParamSize(sizer, p.mojo_handle);
}
void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m,
@@ -1014,6 +1017,7 @@ void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m,
#if defined(OS_POSIX)
WriteParam(m, p.socket);
#endif
+ WriteParam(m, p.mojo_handle);
}
bool ParamTraits<IPC::ChannelHandle>::Read(const base::Pickle* m,
@@ -1023,7 +1027,7 @@ bool ParamTraits<IPC::ChannelHandle>::Read(const base::Pickle* m,
#if defined(OS_POSIX)
&& ReadParam(m, iter, &r->socket)
#endif
- ;
+ && ReadParam(m, iter, &r->mojo_handle);
}
void ParamTraits<IPC::ChannelHandle>::Log(const param_type& p,
@@ -1033,6 +1037,8 @@ void ParamTraits<IPC::ChannelHandle>::Log(const param_type& p,
l->append(", ");
ParamTraits<base::FileDescriptor>::Log(p.socket, l);
#endif
+ l->append(", ");
+ LogParam(p.mojo_handle, l);
l->append(")");
}
diff --git a/chromium/ipc/ipc_message_utils_unittest.cc b/chromium/ipc/ipc_message_utils_unittest.cc
index 51e8336a010..7b77c52d563 100644
--- a/chromium/ipc/ipc_message_utils_unittest.cc
+++ b/chromium/ipc/ipc_message_utils_unittest.cc
@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
+#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -105,8 +106,8 @@ TEST(IPCMessageUtilsTest, ValueSize) {
value->SetWithoutPathExpansion("nested", std::move(nested_dict));
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"));
+ list_value->AppendString("im a string");
+ list_value->AppendString("im another string");
value->SetWithoutPathExpansion("awesome-list", std::move(list_value));
base::Pickle pickle;
@@ -134,5 +135,28 @@ TEST(IPCMessageUtilsTest, JsonValueSize) {
EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
}
+TEST(IPCMessageUtilsTest, MojoChannelHandle) {
+ mojo::MessagePipe message_pipe;
+ IPC::ChannelHandle channel_handle(message_pipe.handle0.release());
+
+ IPC::Message message;
+ IPC::WriteParam(&message, channel_handle);
+
+ base::PickleSizer sizer;
+ IPC::GetParamSize(&sizer, channel_handle);
+ EXPECT_EQ(sizer.payload_size(), message.payload_size());
+
+ base::PickleIterator iter(message);
+ IPC::ChannelHandle result_handle;
+ EXPECT_TRUE(IPC::ReadParam(&message, &iter, &result_handle));
+ EXPECT_TRUE(result_handle.name.empty());
+#if defined(OS_POSIX)
+ EXPECT_EQ(-1, result_handle.socket.fd);
+#elif defined(OS_WIN)
+ EXPECT_EQ(nullptr, result_handle.pipe.handle);
+#endif
+ EXPECT_EQ(channel_handle.mojo_handle, result_handle.mojo_handle);
+}
+
} // namespace
} // namespace IPC
diff --git a/chromium/ipc/mojo/ipc_mojo_bootstrap.cc b/chromium/ipc/ipc_mojo_bootstrap.cc
index 91883238ba4..ba0ea46fe57 100644
--- a/chromium/ipc/mojo/ipc_mojo_bootstrap.cc
+++ b/chromium/ipc/ipc_mojo_bootstrap.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_mojo_bootstrap.h"
+#include "ipc/ipc_mojo_bootstrap.h"
#include <stdint.h>
#include <utility>
+#include "base/callback.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
@@ -14,8 +15,6 @@
#include "build/build_config.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_platform_file.h"
-#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace IPC {
@@ -76,7 +75,7 @@ void MojoServerBootstrap::OnInitDone(int32_t peer_pid) {
}
set_state(STATE_READY);
- bootstrap_.set_connection_error_handler(mojo::Closure());
+ bootstrap_.set_connection_error_handler(base::Closure());
delegate()->OnPipesAvailable(std::move(send_channel_),
std::move(receive_channel_request_), peer_pid);
}
@@ -95,7 +94,7 @@ class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap {
void Init(mojom::ChannelAssociatedRequest receive_channel,
mojom::ChannelAssociatedPtrInfo send_channel,
int32_t peer_pid,
- const mojo::Callback<void(int32_t)>& callback) override;
+ const InitCallback& callback) override;
mojo::Binding<mojom::Bootstrap> binding_;
@@ -113,10 +112,10 @@ void MojoClientBootstrap::Connect() {
void MojoClientBootstrap::Init(mojom::ChannelAssociatedRequest receive_channel,
mojom::ChannelAssociatedPtrInfo send_channel,
int32_t peer_pid,
- const mojo::Callback<void(int32_t)>& callback) {
+ const InitCallback& callback) {
callback.Run(GetSelfPID());
set_state(STATE_READY);
- binding_.set_connection_error_handler(mojo::Closure());
+ binding_.set_connection_error_handler(base::Closure());
delegate()->OnPipesAvailable(std::move(send_channel),
std::move(receive_channel), peer_pid);
}
@@ -156,7 +155,11 @@ base::ProcessId MojoBootstrap::GetSelfPID() const {
if (int global_pid = Channel::GetGlobalPid())
return global_pid;
#endif // OS_LINUX
+#if defined(OS_NACL)
+ return -1;
+#else
return base::GetCurrentProcId();
+#endif // defined(OS_NACL)
}
void MojoBootstrap::Fail() {
diff --git a/chromium/ipc/mojo/ipc_mojo_bootstrap.h b/chromium/ipc/ipc_mojo_bootstrap.h
index e7769ec20a1..312003aedb2 100644
--- a/chromium/ipc/mojo/ipc_mojo_bootstrap.h
+++ b/chromium/ipc/ipc_mojo_bootstrap.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
-#define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
+#ifndef IPC_IPC_MOJO_BOOTSTRAP_H_
+#define IPC_IPC_MOJO_BOOTSTRAP_H_
#include <stdint.h>
@@ -12,10 +12,9 @@
#include "base/macros.h"
#include "base/process/process_handle.h"
#include "build/build_config.h"
+#include "ipc/ipc.mojom.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_listener.h"
-#include "ipc/mojo/ipc.mojom.h"
-#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/public/cpp/system/message_pipe.h"
namespace IPC {
@@ -28,7 +27,7 @@ namespace IPC {
//
// This lives on IO thread other than Create(), which can be called from
// UI thread as Channel::Create() can be.
-class IPC_MOJO_EXPORT MojoBootstrap {
+class IPC_EXPORT MojoBootstrap {
public:
class Delegate {
public:
@@ -82,4 +81,4 @@ class IPC_MOJO_EXPORT MojoBootstrap {
} // namespace IPC
-#endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
+#endif // IPC_IPC_MOJO_BOOTSTRAP_H_
diff --git a/chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/chromium/ipc/ipc_mojo_bootstrap_unittest.cc
index ce0c9b360e4..876ce67bfef 100644
--- a/chromium/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
+++ b/chromium/ipc/ipc_mojo_bootstrap_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_mojo_bootstrap.h"
+#include "ipc/ipc_mojo_bootstrap.h"
#include <stdint.h>
#include <memory>
@@ -12,8 +12,8 @@
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
+#include "ipc/ipc.mojom.h"
#include "ipc/ipc_test_base.h"
-#include "ipc/mojo/ipc.mojom.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/test/mojo_test_base.h"
#include "mojo/edk/test/multiprocess_test_helper.h"
diff --git a/chromium/ipc/mojo/ipc_mojo_handle_attachment.cc b/chromium/ipc/ipc_mojo_handle_attachment.cc
index b2e16f121c5..819a12b890a 100644
--- a/chromium/ipc/mojo/ipc_mojo_handle_attachment.cc
+++ b/chromium/ipc/ipc_mojo_handle_attachment.cc
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_mojo_handle_attachment.h"
+#include "ipc/ipc_mojo_handle_attachment.h"
#include <utility>
#include "build/build_config.h"
-#include "ipc/ipc_message_attachment_set.h"
-#include "mojo/edk/embedder/embedder.h"
namespace IPC {
namespace internal {
@@ -25,15 +23,8 @@ MessageAttachment::Type MojoHandleAttachment::GetType() const {
#if defined(OS_POSIX)
base::PlatformFile MojoHandleAttachment::TakePlatformFile() {
- mojo::edk::ScopedPlatformHandle platform_handle;
- MojoResult unwrap_result = mojo::edk::PassWrappedPlatformHandle(
- handle_.release().value(), &platform_handle);
- if (unwrap_result != MOJO_RESULT_OK) {
- LOG(ERROR) << "Pipe failed to covert handles. Closing: " << unwrap_result;
- return -1;
- }
-
- return platform_handle.release().handle;
+ NOTREACHED();
+ return base::kInvalidPlatformFile;
}
#endif // OS_POSIX
diff --git a/chromium/ipc/mojo/ipc_mojo_handle_attachment.h b/chromium/ipc/ipc_mojo_handle_attachment.h
index 2d51879c7af..6aa1888c02d 100644
--- a/chromium/ipc/mojo/ipc_mojo_handle_attachment.h
+++ b/chromium/ipc/ipc_mojo_handle_attachment.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef IPC_MOJO_IPC_MOJO_HANDLE_ATTACHMENT_H_
-#define IPC_MOJO_IPC_MOJO_HANDLE_ATTACHMENT_H_
+#ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
+#define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
#include "base/files/file.h"
#include "base/macros.h"
@@ -17,22 +17,17 @@ namespace IPC {
namespace internal {
// A MessageAttachment that holds a MojoHandle.
-// * On the sending side, every Mojo handle is a MessagePipe. This is because
-// any platform files are wrapped by PlatformFileAttachment.
-// * On the receiving side, the handle can be either MessagePipe or wrapped
-// platform file: All files, not only MessagePipes are wrapped as a
-// MojoHandle. The message deserializer should know which type of the object
-// the handle wraps.
-class IPC_MOJO_EXPORT MojoHandleAttachment : public MessageAttachment {
+// This can hold any type of transferrable Mojo handle (i.e. message pipe, data
+// pipe, etc), but the receiver is expected to know what type of handle to
+// expect.
+class IPC_EXPORT MojoHandleAttachment : public MessageAttachment {
public:
explicit MojoHandleAttachment(mojo::ScopedHandle handle);
Type GetType() const override;
#if defined(OS_POSIX)
- // Returns wrapped file if it wraps a file, or
- // an invalid fd otherwise. The ownership of handle
- // is passed to the caller.
+ // Should not be called.
base::PlatformFile TakePlatformFile() override;
#endif // OS_POSIX
@@ -49,4 +44,4 @@ class IPC_MOJO_EXPORT MojoHandleAttachment : public MessageAttachment {
} // namespace internal
} // namespace IPC
-#endif // IPC_MOJO_IPC_MOJO_HANDLE_ATTACHMENT_H_
+#endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_
diff --git a/chromium/ipc/mojo/ipc_mojo_message_helper.cc b/chromium/ipc/ipc_mojo_message_helper.cc
index ae5e83a2cdb..8f869455ba2 100644
--- a/chromium/ipc/mojo/ipc_mojo_message_helper.cc
+++ b/chromium/ipc/ipc_mojo_message_helper.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_mojo_message_helper.h"
+#include "ipc/ipc_mojo_message_helper.h"
#include <utility>
-#include "ipc/mojo/ipc_mojo_handle_attachment.h"
+#include "ipc/ipc_mojo_handle_attachment.h"
namespace IPC {
diff --git a/chromium/ipc/mojo/ipc_mojo_message_helper.h b/chromium/ipc/ipc_mojo_message_helper.h
index e0e44d075d0..4a71b5c96cd 100644
--- a/chromium/ipc/mojo/ipc_mojo_message_helper.h
+++ b/chromium/ipc/ipc_mojo_message_helper.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef IPC_MOJO_IPC_MOJO_MESSAGE_HELPER_H_
-#define IPC_MOJO_IPC_MOJO_MESSAGE_HELPER_H_
+#ifndef IPC_IPC_MOJO_MESSAGE_HELPER_H_
+#define IPC_IPC_MOJO_MESSAGE_HELPER_H_
#include "ipc/ipc_export.h"
#include "ipc/ipc_message.h"
@@ -12,7 +12,7 @@
namespace IPC {
// Reads and writes |mojo::MessagePipe| from/to |Message|.
-class IPC_MOJO_EXPORT MojoMessageHelper {
+class IPC_EXPORT MojoMessageHelper {
public:
static bool WriteMessagePipeTo(base::Pickle* message,
mojo::ScopedMessagePipeHandle handle);
@@ -26,4 +26,4 @@ class IPC_MOJO_EXPORT MojoMessageHelper {
} // namespace IPC
-#endif // IPC_MOJO_IPC_MOJO_MESSAGE_HELPER_H_
+#endif // IPC_IPC_MOJO_MESSAGE_HELPER_H_
diff --git a/chromium/ipc/mojo/ipc_mojo_param_traits.cc b/chromium/ipc/ipc_mojo_param_traits.cc
index 1bb5256a742..189af3511d3 100644
--- a/chromium/ipc/mojo/ipc_mojo_param_traits.cc
+++ b/chromium/ipc/ipc_mojo_param_traits.cc
@@ -2,21 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ipc/mojo/ipc_mojo_param_traits.h"
+#include "ipc/ipc_mojo_param_traits.h"
#include "ipc/ipc_message_utils.h"
-#include "ipc/mojo/ipc_mojo_message_helper.h"
+#include "ipc/ipc_mojo_message_helper.h"
namespace IPC {
-void ParamTraits<mojo::MessagePipeHandle>::Write(Message* m,
+void ParamTraits<mojo::MessagePipeHandle>::GetSize(base::PickleSizer* sizer,
+ const param_type& p) {
+ GetParamSize(sizer, p.is_valid());
+ if (p.is_valid())
+ sizer->AddAttachment();
+}
+
+void ParamTraits<mojo::MessagePipeHandle>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, p.is_valid());
if (p.is_valid())
MojoMessageHelper::WriteMessagePipeTo(m, mojo::ScopedMessagePipeHandle(p));
}
-bool ParamTraits<mojo::MessagePipeHandle>::Read(const Message* m,
+bool ParamTraits<mojo::MessagePipeHandle>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
bool is_valid;
diff --git a/chromium/ipc/mojo/ipc_mojo_param_traits.h b/chromium/ipc/ipc_mojo_param_traits.h
index f0b8b515b6f..39be43e217a 100644
--- a/chromium/ipc/mojo/ipc_mojo_param_traits.h
+++ b/chromium/ipc/ipc_mojo_param_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef IPC_MOJO_IPC_MOJO_PARAM_TRAITS_H_
-#define IPC_MOJO_IPC_MOJO_PARAM_TRAITS_H_
+#ifndef IPC_IPC_MOJO_PARAM_TRAITS_H_
+#define IPC_IPC_MOJO_PARAM_TRAITS_H_
#include <string>
@@ -12,21 +12,23 @@
#include "mojo/public/cpp/system/message_pipe.h"
namespace base {
+class Pickle;
class PickleIterator;
+class PickleSizer;
}
namespace IPC {
-class Message;
-
template <>
-struct IPC_MOJO_EXPORT ParamTraits<mojo::MessagePipeHandle> {
+struct IPC_EXPORT ParamTraits<mojo::MessagePipeHandle> {
typedef mojo::MessagePipeHandle param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, base::PickleIterator* iter, param_type* r);
+ 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,
+ param_type* r);
static void Log(const param_type& p, std::string* l);
};
} // namespace IPC
-#endif // IPC_MOJO_IPC_MOJO_PARAM_TRAITS_H_
+#endif // IPC_IPC_MOJO_PARAM_TRAITS_H_
diff --git a/chromium/ipc/mojo/ipc_mojo_perftest.cc b/chromium/ipc/ipc_mojo_perftest.cc
index d68762b28ec..c09608c59a9 100644
--- a/chromium/ipc/mojo/ipc_mojo_perftest.cc
+++ b/chromium/ipc/ipc_mojo_perftest.cc
@@ -9,8 +9,8 @@
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
+#include "ipc/ipc_channel_mojo.h"
#include "ipc/ipc_perftest_support.h"
-#include "ipc/mojo/ipc_channel_mojo.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/test/multiprocess_test_helper.h"
diff --git a/chromium/ipc/ipc_nacl.gyp b/chromium/ipc/ipc_nacl.gyp
index 5faf9af1f4c..b15dba2de13 100644
--- a/chromium/ipc/ipc_nacl.gyp
+++ b/chromium/ipc/ipc_nacl.gyp
@@ -25,7 +25,11 @@
'build_irt': 1,
},
'dependencies': [
+ 'ipc.gyp:ipc_interfaces_mojom',
'../base/base_nacl.gyp:base_nacl',
+ '../mojo/mojo_public.gyp:mojo_interface_bindings_generation',
+ '../mojo/mojo_public_nacl.gyp:mojo_cpp_bindings_nacl',
+ '../mojo/mojo_public_nacl.gyp:mojo_cpp_system_nacl',
],
},
{
@@ -54,7 +58,11 @@
'ipc_channel_nacl.cc',
],
'dependencies': [
+ 'ipc.gyp:ipc_interfaces_mojom',
'../base/base_nacl.gyp:base_nacl_nonsfi',
+ '../mojo/mojo_public.gyp:mojo_interface_bindings_generation',
+ '../mojo/mojo_public_nacl.gyp:mojo_cpp_bindings_nacl',
+ '../mojo/mojo_public_nacl.gyp:mojo_cpp_system_nacl',
],
},
],
diff --git a/chromium/ipc/ipc_perftest_support.cc b/chromium/ipc/ipc_perftest_support.cc
index 050b541330f..2932ce838f3 100644
--- a/chromium/ipc/ipc_perftest_support.cc
+++ b/chromium/ipc/ipc_perftest_support.cc
@@ -15,6 +15,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/pickle.h"
+#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/perf_time_logger.h"
#include "base/test/test_io_thread.h"
@@ -269,7 +270,7 @@ void IPCChannelPerfTestBase::RunTestChannelPingPong(
sender()->Send(message);
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
}
// Send quit message.
@@ -309,7 +310,7 @@ void IPCChannelPerfTestBase::RunTestChannelProxyPingPong(
sender()->Send(message);
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
}
// Send quit message.
@@ -344,7 +345,7 @@ int PingPongTestClient::RunMain() {
listener_->Init(channel.get());
CHECK(channel->Connect());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
return 0;
}
diff --git a/chromium/ipc/ipc_send_fds_test.cc b/chromium/ipc/ipc_send_fds_test.cc
index 9480d0e6232..a65601512d8 100644
--- a/chromium/ipc/ipc_send_fds_test.cc
+++ b/chromium/ipc/ipc_send_fds_test.cc
@@ -24,6 +24,7 @@ extern "C" {
#include "base/location.h"
#include "base/pickle.h"
#include "base/posix/eintr_wrapper.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "ipc/ipc_message_attachment_set.h"
@@ -133,7 +134,7 @@ class IPCSendFdsTest : public IPCTestBase {
}
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Close the channel so the client's OnChannelError() gets fired.
channel()->Close();
@@ -159,7 +160,7 @@ int SendFdsClientCommon(const std::string& test_client_name,
CHECK(channel->Connect());
// Run message loop.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Verify that the message loop was exited due to getting the correct number
// of descriptors, and not because of the channel closing unexpectedly.
@@ -269,8 +270,10 @@ class PipeChannelHelper {
}
~PipeChannelHelper() {
- base::WaitableEvent a(true, false);
- base::WaitableEvent b(true, false);
+ base::WaitableEvent a(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ base::WaitableEvent b(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
in_thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&PipeChannelHelper::DestroyChannel, &in, &a));
out_thread_->task_runner()->PostTask(
@@ -315,7 +318,9 @@ class PipeChannelHelper {
// http://crbug.com/298276
class IPCMultiSendingFdsTest : public testing::Test {
public:
- IPCMultiSendingFdsTest() : received_(true, false) {}
+ IPCMultiSendingFdsTest()
+ : received_(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED) {}
void Producer(PipeChannelHelper* dest,
base::Thread* t,
diff --git a/chromium/ipc/ipc_sync_channel.cc b/chromium/ipc/ipc_sync_channel.cc
index de54755f892..8e3f4115b5a 100644
--- a/chromium/ipc/ipc_sync_channel.cc
+++ b/chromium/ipc/ipc_sync_channel.cc
@@ -190,14 +190,14 @@ class SyncChannel::ReceivedSyncMsgQueue :
// See the comment in SyncChannel::SyncChannel for why this event is created
// as manual reset.
- ReceivedSyncMsgQueue() :
- message_queue_version_(0),
- dispatch_event_(true, false),
- listener_task_runner_(base::ThreadTaskRunnerHandle::Get()),
- task_pending_(false),
- listener_count_(0),
- top_send_done_watcher_(NULL) {
- }
+ ReceivedSyncMsgQueue()
+ : message_queue_version_(0),
+ dispatch_event_(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
+ listener_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ task_pending_(false),
+ listener_count_(0),
+ top_send_done_watcher_(NULL) {}
~ReceivedSyncMsgQueue() {}
@@ -260,9 +260,10 @@ void SyncChannel::SyncContext::Push(SyncMessage* sync_msg) {
// OnObjectSignalled, another Send can happen which would stop the watcher
// from being called. The event would get watched later, when the nested
// Send completes, so the event will need to remain set.
- PendingSyncMsg pending(SyncMessage::GetMessageId(*sync_msg),
- sync_msg->GetReplyDeserializer(),
- new WaitableEvent(true, false));
+ PendingSyncMsg pending(
+ SyncMessage::GetMessageId(*sync_msg), sync_msg->GetReplyDeserializer(),
+ new WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED));
base::AutoLock auto_lock(deserializers_lock_);
deserializers_.push_back(pending);
}
diff --git a/chromium/ipc/ipc_sync_channel_unittest.cc b/chromium/ipc/ipc_sync_channel_unittest.cc
index 4048825349c..150459007f9 100644
--- a/chromium/ipc/ipc_sync_channel_unittest.cc
+++ b/chromium/ipc/ipc_sync_channel_unittest.cc
@@ -42,28 +42,37 @@ class Worker : public Listener, public Sender {
Worker(Channel::Mode mode,
const std::string& thread_name,
const std::string& channel_name)
- : done_(new WaitableEvent(false, false)),
- channel_created_(new WaitableEvent(false, false)),
+ : done_(
+ new WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED)),
+ channel_created_(
+ new WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED)),
channel_name_(channel_name),
mode_(mode),
ipc_thread_((thread_name + "_ipc").c_str()),
listener_thread_((thread_name + "_listener").c_str()),
overrided_thread_(NULL),
- shutdown_event_(true, false),
+ shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
is_shutdown_(false) {}
// Will create a named channel and use this name for the threads' name.
Worker(const std::string& channel_name, Channel::Mode mode)
- : done_(new WaitableEvent(false, false)),
- channel_created_(new WaitableEvent(false, false)),
+ : done_(
+ new WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED)),
+ channel_created_(
+ new WaitableEvent(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED)),
channel_name_(channel_name),
mode_(mode),
ipc_thread_((channel_name + "_ipc").c_str()),
listener_thread_((channel_name + "_listener").c_str()),
overrided_thread_(NULL),
- shutdown_event_(true, false),
- is_shutdown_(false) {
- }
+ shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
+ is_shutdown_(false) {}
~Worker() override {
// Shutdown() must be called before destruction.
@@ -74,7 +83,7 @@ class Worker : public Listener, public Sender {
bool Send(Message* msg) override { return channel_->Send(msg); }
void WaitForChannelCreation() { channel_created_->Wait(); }
void CloseChannel() {
- DCHECK(base::MessageLoop::current() == ListenerThread()->message_loop());
+ DCHECK(ListenerThread()->task_runner()->BelongsToCurrentThread());
channel_->Close();
}
void Start() {
@@ -86,7 +95,11 @@ class Worker : public Listener, public Sender {
// The IPC thread needs to outlive SyncChannel. We can't do this in
// ~Worker(), since that'll reset the vtable pointer (to Worker's), which
// may result in a race conditions. See http://crbug.com/25841.
- WaitableEvent listener_done(false, false), ipc_done(false, false);
+ WaitableEvent listener_done(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
+ ipc_done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
ListenerThread()->task_runner()->PostTask(
FROM_HERE, base::Bind(&Worker::OnListenerThreadShutdown1, this,
&listener_done, &ipc_done));
@@ -187,7 +200,7 @@ class Worker : public Listener, public Sender {
base::RunLoop().RunUntilIdle();
- ipc_thread_.message_loop()->PostTask(
+ ipc_thread_.task_runner()->PostTask(
FROM_HERE, base::Bind(&Worker::OnIPCThreadShutdown, this,
listener_event, ipc_event));
}
@@ -454,7 +467,9 @@ class NoHangClient : public Worker {
};
void NoHang(bool pump_during_send) {
- WaitableEvent got_first_reply(false, false);
+ WaitableEvent got_first_reply(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
std::vector<Worker*> workers;
workers.push_back(
new NoHangServer(&got_first_reply, pump_during_send, "NoHang"));
@@ -730,8 +745,12 @@ void Multiple(bool server_pump, bool client_pump) {
// Server1 sends a sync msg to client1, which blocks the reply until
// server2 (which runs on the same worker thread as server1) responds
// to a sync msg from client2.
- WaitableEvent client1_msg_received(false, false);
- WaitableEvent client1_can_reply(false, false);
+ WaitableEvent client1_msg_received(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent client1_can_reply(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
Worker* worker;
@@ -1255,8 +1274,11 @@ class RestrictedDispatchClient : public Worker {
};
TEST_F(IPCSyncChannelTest, RestrictedDispatch) {
- WaitableEvent sent_ping_event(false, false);
- WaitableEvent wait_event(false, false);
+ WaitableEvent sent_ping_event(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent wait_event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
RestrictedDispatchServer* server =
new RestrictedDispatchServer(&sent_ping_event, &wait_event);
NonRestrictedDispatchServer* server2 =
@@ -1486,13 +1508,19 @@ TEST_F(IPCSyncChannelTest, RestrictedDispatchDeadlock) {
base::Thread worker_thread("RestrictedDispatchDeadlock");
ASSERT_TRUE(worker_thread.Start());
- WaitableEvent server1_ready(false, false);
- WaitableEvent server2_ready(false, false);
-
- WaitableEvent event0(false, false);
- WaitableEvent event1(false, false);
- WaitableEvent event2(false, false);
- WaitableEvent event3(false, false);
+ WaitableEvent server1_ready(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent server2_ready(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+
+ WaitableEvent event0(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent event1(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent event2(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent event3(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
WaitableEvent* events[4] = {&event0, &event1, &event2, &event3};
RestrictedDispatchDeadlockServer* server1;
@@ -1616,10 +1644,14 @@ class RestrictedDispatchPipeWorker : public Worker {
TEST_F(IPCSyncChannelTest, MAYBE_RestrictedDispatch4WayDeadlock) {
int success = 0;
std::vector<Worker*> workers;
- WaitableEvent event0(true, false);
- WaitableEvent event1(true, false);
- WaitableEvent event2(true, false);
- WaitableEvent event3(true, false);
+ WaitableEvent event0(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent event1(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent event2(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ WaitableEvent event3(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
workers.push_back(new RestrictedDispatchPipeWorker(
"channel0", &event0, "channel1", &event1, 1, &success));
workers.push_back(new RestrictedDispatchPipeWorker(
@@ -1734,7 +1766,8 @@ class ReentrantReplyClient : public Worker {
TEST_F(IPCSyncChannelTest, ReentrantReply) {
std::vector<Worker*> workers;
- WaitableEvent server_ready(false, false);
+ WaitableEvent server_ready(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
workers.push_back(new ReentrantReplyServer2());
workers.push_back(new ReentrantReplyServer1(&server_ready));
workers.push_back(new ReentrantReplyClient(&server_ready));
diff --git a/chromium/ipc/ipc_sync_message.cc b/chromium/ipc/ipc_sync_message.cc
index 884dd8029d5..7f9df7bd9bc 100644
--- a/chromium/ipc/ipc_sync_message.cc
+++ b/chromium/ipc/ipc_sync_message.cc
@@ -20,7 +20,9 @@ struct WaitableEventLazyInstanceTraits
: public base::DefaultLazyInstanceTraits<base::WaitableEvent> {
static base::WaitableEvent* New(void* instance) {
// Use placement new to initialize our instance in our preallocated space.
- return new (instance) base::WaitableEvent(true, true);
+ return new (instance)
+ base::WaitableEvent(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::SIGNALED);
}
};
diff --git a/chromium/ipc/ipc_sync_message_filter.cc b/chromium/ipc/ipc_sync_message_filter.cc
index da883f6fd68..1d17432a319 100644
--- a/chromium/ipc/ipc_sync_message_filter.cc
+++ b/chromium/ipc/ipc_sync_message_filter.cc
@@ -33,7 +33,9 @@ bool SyncMessageFilter::Send(Message* message) {
return true;
}
- base::WaitableEvent done_event(true, false);
+ base::WaitableEvent done_event(
+ base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
PendingSyncMsg pending_message(
SyncMessage::GetMessageId(*message),
static_cast<SyncMessage*>(message)->GetReplyDeserializer(),
diff --git a/chromium/ipc/mojo/BUILD.gn b/chromium/ipc/mojo/BUILD.gn
deleted file mode 100644
index 22f063aaf83..00000000000
--- a/chromium/ipc/mojo/BUILD.gn
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2014 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.
-
-import("//mojo/public/tools/bindings/mojom.gni")
-import("//testing/test.gni")
-
-mojom("mojom") {
- sources = [
- "ipc.mojom",
- ]
-}
-
-component("mojo") {
- sources = [
- "ipc_channel_mojo.cc",
- "ipc_channel_mojo.h",
- "ipc_message_pipe_reader.cc",
- "ipc_message_pipe_reader.h",
- "ipc_mojo_bootstrap.cc",
- "ipc_mojo_bootstrap.h",
- "ipc_mojo_handle_attachment.cc",
- "ipc_mojo_handle_attachment.h",
- "ipc_mojo_message_helper.cc",
- "ipc_mojo_message_helper.h",
- "ipc_mojo_param_traits.cc",
- "ipc_mojo_param_traits.h",
- "scoped_ipc_support.cc",
- "scoped_ipc_support.h",
- ]
-
- defines = [ "IPC_MOJO_IMPLEMENTATION" ]
-
- deps = [
- ":mojom",
- "//base",
- "//base/third_party/dynamic_annotations",
- "//ipc",
- "//mojo/edk/system",
- "//mojo/public/cpp/bindings",
- ]
-}
-
-test("ipc_mojo_unittests") {
- sources = [
- "ipc_channel_mojo_unittest.cc",
- "ipc_mojo_bootstrap_unittest.cc",
- "run_all_unittests.cc",
- ]
-
- deps = [
- ":mojo",
- ":mojom",
- "//base",
- "//base/test:test_support",
- "//base/third_party/dynamic_annotations",
- "//ipc",
- "//ipc:test_support",
- "//mojo/edk/system",
- "//mojo/edk/test:test_support",
- "//testing/gtest",
- "//url",
- ]
-}
-
-test("ipc_mojo_perftests") {
- sources = [
- "ipc_mojo_perftest.cc",
- "run_all_perftests.cc",
- ]
-
- deps = [
- ":mojo",
- ":mojom",
- "//base",
- "//base/test:test_support",
- "//base/third_party/dynamic_annotations",
- "//ipc",
- "//ipc:test_support",
- "//mojo/edk/system",
- "//mojo/edk/test:test_support",
- "//mojo/edk/test:test_support_impl",
- "//url",
- ]
-
- if (is_linux && !is_component_build) {
- public_configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
- }
-}
diff --git a/chromium/ipc/mojo/DEPS b/chromium/ipc/mojo/DEPS
deleted file mode 100644
index 00f925a060d..00000000000
--- a/chromium/ipc/mojo/DEPS
+++ /dev/null
@@ -1,5 +0,0 @@
-include_rules = [
- "+mojo/edk/embedder",
- "+mojo/edk/test",
- "+mojo/public",
-]
diff --git a/chromium/ipc/mojo/OWNERS b/chromium/ipc/mojo/OWNERS
deleted file mode 100644
index ae47a47a0f7..00000000000
--- a/chromium/ipc/mojo/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-amistry@chromium.org
-morrita@chromium.org
-rockot@chromium.org
-viettrungluu@chromium.org
diff --git a/chromium/ipc/mojo/ipc_mojo.gyp b/chromium/ipc/mojo/ipc_mojo.gyp
deleted file mode 100644
index e925d7ba856..00000000000
--- a/chromium/ipc/mojo/ipc_mojo.gyp
+++ /dev/null
@@ -1,125 +0,0 @@
-# Copyright 2014 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.
-
-{
- 'variables': {
- 'chromium_code': 1,
- },
- 'includes': [
- ],
- 'targets': [
- {
- 'target_name': 'ipc_mojo',
- 'type': '<(component)',
- 'variables': {
- },
- 'defines': [
- 'IPC_MOJO_IMPLEMENTATION',
- ],
- 'includes': [ '../../mojo/mojom_bindings_generator.gypi' ],
- 'dependencies': [
- '../ipc.gyp:ipc',
- '../../base/base.gyp:base',
- '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '../../mojo/mojo_edk.gyp:mojo_system_impl',
- '../../mojo/mojo_public.gyp:mojo_cpp_bindings',
- ],
- 'sources': [
- 'ipc_channel_mojo.cc',
- 'ipc_channel_mojo.h',
- 'ipc_mojo_bootstrap.cc',
- 'ipc_mojo_bootstrap.h',
- 'ipc_mojo_handle_attachment.cc',
- 'ipc_mojo_handle_attachment.h',
- 'ipc_mojo_message_helper.cc',
- 'ipc_mojo_message_helper.h',
- 'ipc_mojo_param_traits.cc',
- 'ipc_mojo_param_traits.h',
- 'ipc_message_pipe_reader.cc',
- 'ipc_message_pipe_reader.h',
- 'ipc.mojom',
- 'scoped_ipc_support.cc',
- 'scoped_ipc_support.h',
- ],
- # TODO(gregoryd): direct_dependent_settings should be shared with the
- # 64-bit target, but it doesn't work due to a bug in gyp
- 'direct_dependent_settings': {
- 'include_dirs': [
- '..',
- ],
- },
- },
- {
- 'target_name': 'ipc_mojo_unittests',
- 'type': '<(gtest_target_type)',
- 'dependencies': [
- '../ipc.gyp:ipc',
- '../ipc.gyp:test_support_ipc',
- '../../base/base.gyp:base',
- '../../base/base.gyp:base_i18n',
- '../../base/base.gyp:test_support_base',
- '../../mojo/mojo_edk.gyp:mojo_common_test_support',
- '../../mojo/mojo_edk.gyp:mojo_system_impl',
- '../../mojo/mojo_public.gyp:mojo_cpp_bindings',
- '../../testing/gtest.gyp:gtest',
- 'ipc_mojo',
- ],
- 'include_dirs': [
- '..'
- ],
- 'sources': [
- 'run_all_unittests.cc',
-
- "ipc_channel_mojo_unittest.cc",
- 'ipc_mojo_bootstrap_unittest.cc',
- ],
- 'conditions': [
- ],
- },
- {
- 'target_name': 'ipc_mojo_perftests',
- 'type': '<(gtest_target_type)',
- 'dependencies': [
- '../ipc.gyp:ipc',
- '../ipc.gyp:test_support_ipc',
- '../../base/base.gyp:base',
- '../../base/base.gyp:base_i18n',
- '../../base/base.gyp:test_support_base',
- '../../base/base.gyp:test_support_perf',
- '../../mojo/mojo_edk.gyp:mojo_common_test_support',
- '../../mojo/mojo_edk.gyp:mojo_system_impl',
- '../../mojo/mojo_public.gyp:mojo_cpp_bindings',
- '../../testing/gtest.gyp:gtest',
- 'ipc_mojo',
- ],
- 'include_dirs': [
- '..'
- ],
- 'sources': [
- 'ipc_mojo_perftest.cc',
- ],
- 'conditions': [
- ],
- },
- ],
- '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_unittests.isolate b/chromium/ipc/mojo/ipc_mojo_unittests.isolate
deleted file mode 100644
index d3309573f35..00000000000
--- a/chromium/ipc/mojo/ipc_mojo_unittests.isolate
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
deleted file mode 100644
index a831c2d2e30..00000000000
--- a/chromium/ipc/mojo/run_all_unittests.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2014 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.
-
-#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"
-#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/test/scoped_ipc_support.h"
-
-#if defined(OS_ANDROID)
-#include "base/android/jni_android.h"
-#include "base/test/test_file_util.h"
-#endif
-
-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
- base::TestSuite test_suite(argc, argv);
- mojo::edk::Init();
- base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
- // Leak this because its destructor calls mojo::edk::ShutdownIPCSupport which
- // really does nothing in the new EDK but does depend on the current message
- // loop, which is destructed inside base::LaunchUnitTests.
- new mojo::edk::test::ScopedIPCSupport(test_io_thread.task_runner());
- return base::LaunchUnitTestsSerially(
- argc, argv,
- base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
-}
diff --git a/chromium/ipc/mojo/scoped_ipc_support.cc b/chromium/ipc/mojo/scoped_ipc_support.cc
deleted file mode 100644
index 65947bece9c..00000000000
--- a/chromium/ipc/mojo/scoped_ipc_support.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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.
-
-#include "ipc/mojo/scoped_ipc_support.h"
-
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/process_delegate.h"
-
-namespace IPC {
-
-namespace {
-class IPCSupportInitializer : public mojo::edk::ProcessDelegate {
- public:
- IPCSupportInitializer() {}
- ~IPCSupportInitializer() override {}
-
- void Init(scoped_refptr<base::TaskRunner> io_thread_task_runner) {
- CHECK(!io_thread_task_runner_);
- CHECK(io_thread_task_runner);
- io_thread_task_runner_ = io_thread_task_runner;
-
- mojo::edk::InitIPCSupport(this, io_thread_task_runner_);
- }
-
- void ShutDown() {
- CHECK(io_thread_task_runner_);
- mojo::edk::ShutdownIPCSupport();
- }
-
- private:
- // mojo::edk::ProcessDelegate:
- void OnShutdownComplete() override {
- // TODO(rockot): We should ensure that IO runner shutdown is blocked until
- // this is called.
- }
-
- scoped_refptr<base::TaskRunner> io_thread_task_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(IPCSupportInitializer);
-};
-
-base::LazyInstance<IPCSupportInitializer>::Leaky ipc_support_initializer;
-
-} // namespace
-
-ScopedIPCSupport::ScopedIPCSupport(
- scoped_refptr<base::TaskRunner> io_thread_task_runner) {
- ipc_support_initializer.Get().Init(io_thread_task_runner);
-}
-
-ScopedIPCSupport::~ScopedIPCSupport() {
- ipc_support_initializer.Get().ShutDown();
-}
-
-} // namespace IPC
diff --git a/chromium/ipc/mojo/scoped_ipc_support.h b/chromium/ipc/mojo/scoped_ipc_support.h
deleted file mode 100644
index 29c50bf4a48..00000000000
--- a/chromium/ipc/mojo/scoped_ipc_support.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-#ifndef IPC_MOJO_SCOPED_IPC_SUPPORT_H_
-#define IPC_MOJO_SCOPED_IPC_SUPPORT_H_
-
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/task_runner.h"
-#include "ipc/ipc_export.h"
-
-namespace IPC {
-
-// Performs any necessary Mojo IPC initialization on construction, and shuts
-// down Mojo IPC on destruction.
-//
-// This should be instantiated once per process and retained as long as Mojo IPC
-// is needed. The TaskRunner passed to the constructor should outlive this
-// object.
-class IPC_MOJO_EXPORT ScopedIPCSupport {
- public:
- ScopedIPCSupport(scoped_refptr<base::TaskRunner> io_thread_task_runner);
- ~ScopedIPCSupport();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
-};
-
-} // namespace IPC
-
-#endif // IPC_MOJO_SCOPED_IPC_SUPPORT_H_
diff --git a/chromium/ipc/mojo_event.cc b/chromium/ipc/mojo_event.cc
new file mode 100644
index 00000000000..5d802b8bff9
--- /dev/null
+++ b/chromium/ipc/mojo_event.cc
@@ -0,0 +1,39 @@
+// Copyright 2016 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.
+
+#include "ipc/mojo_event.h"
+
+namespace IPC {
+
+MojoEvent::MojoEvent() {
+ mojo::MessagePipe pipe;
+ signal_handle_ = std::move(pipe.handle0);
+ wait_handle_ = std::move(pipe.handle1);
+}
+
+MojoEvent::~MojoEvent() {}
+
+void MojoEvent::Signal() {
+ base::AutoLock lock(lock_);
+ if (is_signaled_)
+ return;
+ is_signaled_ = true;
+ MojoResult rv = mojo::WriteMessageRaw(
+ signal_handle_.get(), nullptr, 0, nullptr, 0,
+ MOJO_WRITE_MESSAGE_FLAG_NONE);
+ CHECK_EQ(rv, MOJO_RESULT_OK);
+}
+
+void MojoEvent::Reset() {
+ base::AutoLock lock(lock_);
+ if (!is_signaled_)
+ return;
+ is_signaled_ = false;
+ MojoResult rv = mojo::ReadMessageRaw(
+ wait_handle_.get(), nullptr, nullptr, nullptr, nullptr,
+ MOJO_READ_MESSAGE_FLAG_NONE);
+ CHECK_EQ(rv, MOJO_RESULT_OK);
+}
+
+} // namespace IPC
diff --git a/chromium/ipc/mojo_event.h b/chromium/ipc/mojo_event.h
new file mode 100644
index 00000000000..079de284fc9
--- /dev/null
+++ b/chromium/ipc/mojo_event.h
@@ -0,0 +1,45 @@
+// Copyright 2016 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.
+
+#ifndef IPC_MOJO_EVENT_H_
+#define IPC_MOJO_EVENT_H_
+
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+
+namespace IPC {
+
+// A MojoEvent is a simple wrapper around a Mojo message pipe which supports
+// common WaitableEvent-like methods of Signal() and Reset(). This class exists
+// to support the transition from legacy IPC to Mojo IPC and is not intended for
+// general use outside of src/ipc. Unlike base::WaitableEvent, all MojoEvents
+// must be manually reset.
+class MojoEvent {
+ public:
+ // Constructs a new MojoEvent that is initially not signaled.
+ MojoEvent();
+
+ ~MojoEvent();
+
+ // Gets a Handle that can be waited on for this MojoEvent. When the Event is
+ // signaled, this handle will have |MOJO_HANDLE_SIGNAL_READABLE| satisfied.
+ const mojo::Handle& GetHandle() const { return wait_handle_.get(); }
+
+ void Signal();
+ void Reset();
+
+ private:
+ mojo::ScopedMessagePipeHandle signal_handle_;
+ mojo::ScopedMessagePipeHandle wait_handle_;
+
+ base::Lock lock_;
+ bool is_signaled_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoEvent);
+};
+
+} // namespace IPC
+
+#endif // IPC_MOJO_EVENT_H_
diff --git a/chromium/ipc/mojo/run_all_perftests.cc b/chromium/ipc/run_all_perftests.cc
index a942b8b5749..a942b8b5749 100644
--- a/chromium/ipc/mojo/run_all_perftests.cc
+++ b/chromium/ipc/run_all_perftests.cc
diff --git a/chromium/ipc/run_all_unittests.cc b/chromium/ipc/run_all_unittests.cc
index 5f9cc16755f..44bbf60dc6d 100644
--- a/chromium/ipc/run_all_unittests.cc
+++ b/chromium/ipc/run_all_unittests.cc
@@ -5,14 +5,21 @@
#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"
+#include "mojo/edk/embedder/embedder.h"
+#include "mojo/edk/test/scoped_ipc_support.h"
#if defined(OS_ANDROID)
#include "base/android/jni_android.h"
#include "base/test/test_file_util.h"
#endif
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include "base/mac/mach_port_broker.h"
+#endif
+
int main(int argc, char** argv) {
#if defined(OS_ANDROID)
base::InitAndroidMultiProcessTestHelper(main);
@@ -21,6 +28,19 @@ int main(int argc, char** argv) {
base::RegisterContentUriTestUtils(env);
#endif
base::TestSuite test_suite(argc, argv);
+ mojo::edk::Init();
+ base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart);
+ // Leak this because its destructor calls mojo::edk::ShutdownIPCSupport which
+ // really does nothing in the new EDK but does depend on the current message
+ // loop, which is destructed inside base::LaunchUnitTests.
+ new mojo::edk::test::ScopedIPCSupport(test_io_thread.task_runner());
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ base::MachPortBroker mach_broker("mojo_test");
+ CHECK(mach_broker.Init());
+ mojo::edk::SetMachPortProvider(&mach_broker);
+#endif
+
return base::LaunchUnitTests(
argc, argv,
base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
diff --git a/chromium/ipc/sync_socket_unittest.cc b/chromium/ipc/sync_socket_unittest.cc
index 3385646bd70..dfcd025f046 100644
--- a/chromium/ipc/sync_socket_unittest.cc
+++ b/chromium/ipc/sync_socket_unittest.cc
@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/macros.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
@@ -115,7 +116,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) {
IPCTestBase::GetChannelName("SyncSocketServerClient"), &listener));
EXPECT_TRUE(channel->Connect());
listener.Init(channel.get());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
return 0;
}
@@ -199,7 +200,7 @@ TEST_F(SyncSocketTest, SanityTest) {
#endif // defined(OS_WIN)
EXPECT_TRUE(sender()->Send(msg));
// Use the current thread as the I/O thread.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Shut down.
pair[0].Close();
pair[1].Close();
diff --git a/chromium/ipc/unix_domain_socket_util_unittest.cc b/chromium/ipc/unix_domain_socket_util_unittest.cc
index 3fa4454638f..d4ff127dfae 100644
--- a/chromium/ipc/unix_domain_socket_util_unittest.cc
+++ b/chromium/ipc/unix_domain_socket_util_unittest.cc
@@ -28,8 +28,11 @@ class SocketAcceptor : public base::MessageLoopForIO::Watcher {
SocketAcceptor(int fd, base::SingleThreadTaskRunner* target_thread)
: server_fd_(-1),
target_thread_(target_thread),
- started_watching_event_(false, false),
- accepted_event_(false, false) {
+ started_watching_event_(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
+ accepted_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED) {
target_thread->PostTask(FROM_HERE,
base::Bind(&SocketAcceptor::StartWatching, base::Unretained(this), fd));
}