Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: ipc/attachment_broker_mac_unittest.cc

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (scoped_ptr->std::unique_ptr) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/child_process_host_impl.cc ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/attachment_broker_mac_unittest.cc
diff --git a/ipc/attachment_broker_mac_unittest.cc b/ipc/attachment_broker_mac_unittest.cc
index d30e8a75732eaddfeddfc6113a0b78e184ebe7f6..3be3d4397d6a49ab67e1c1ed65984e7d07bd5a63 100644
--- a/ipc/attachment_broker_mac_unittest.cc
+++ b/ipc/attachment_broker_mac_unittest.cc
@@ -423,6 +423,12 @@ class IPCAttachmentBrokerMacTest : public IPCTestBase {
// Setup shared between tests.
void CommonSetUp(const char* name) {
+ PreConnectSetUp(name);
+ PostConnectSetUp();
+ }
+
+ // All of setup before the channel is connected.
+ void PreConnectSetUp(const char* name) {
Init(name);
MachPreForkSetUp();
@@ -432,6 +438,10 @@ class IPCAttachmentBrokerMacTest : public IPCTestBase {
broker_->AddObserver(&observer_, task_runner());
CreateChannel(&proxy_listener_);
broker_->RegisterBrokerCommunicationChannel(channel());
+ }
+
+ // All of setup including the connection and everything after.
+ void PostConnectSetUp() {
ASSERT_TRUE(ConnectChannel());
ASSERT_TRUE(StartClient());
@@ -871,11 +881,11 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendPosixFDAndMachPort) {
// process sending an attachment to another unprivileged process.
TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleToSelf) {
SetBroker(new MockBroker);
- CommonSetUp("SendSharedMemoryHandleToSelf");
-
+ PreConnectSetUp("SendSharedMemoryHandleToSelf");
// Technically, the channel is an endpoint, but we need the proxy listener to
// receive the messages so that it can quit the message loop.
channel()->SetAttachmentBrokerEndpoint(false);
+ PostConnectSetUp();
get_proxy_listener()->set_listener(get_broker());
{
@@ -940,8 +950,12 @@ TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleChannelProxy) {
options.message_loop_type = base::MessageLoop::TYPE_IO;
thread->StartWithOptions(options);
- CreateChannelProxy(get_proxy_listener(), thread->task_runner().get());
+ set_channel_proxy(std::unique_ptr<IPC::ChannelProxy>(new IPC::ChannelProxy(
+ get_proxy_listener(), thread->task_runner().get())));
get_broker()->RegisterBrokerCommunicationChannel(channel_proxy());
+ channel_proxy()->Init(
+ CreateChannelFactory(GetTestChannelHandle(), thread->task_runner().get()),
+ true);
ASSERT_TRUE(StartClient());
@@ -1060,11 +1074,11 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(ShareReadOnlyToProcess) {
// not have the task port for the parent process.
TEST_F(IPCAttachmentBrokerMacTest, SendSharedMemoryHandleToSelfDelayedPort) {
SetBroker(new MockBroker);
- CommonSetUp("SendSharedMemoryHandleToSelfDelayedPort");
-
+ PreConnectSetUp("SendSharedMemoryHandleToSelfDelayedPort");
// Technically, the channel is an endpoint, but we need the proxy listener to
// receive the messages so that it can quit the message loop.
channel()->SetAttachmentBrokerEndpoint(false);
+ PostConnectSetUp();
get_proxy_listener()->set_listener(get_broker());
{
« no previous file with comments | « content/common/child_process_host_impl.cc ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698