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

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: Comments from tsepez. 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
Index: ipc/attachment_broker_mac_unittest.cc
diff --git a/ipc/attachment_broker_mac_unittest.cc b/ipc/attachment_broker_mac_unittest.cc
index 61d41d78300ce805b6881ff11dd11bb0588df038..b745be38b6cb567f621a0215575e1d9d410ec962 100644
--- a/ipc/attachment_broker_mac_unittest.cc
+++ b/ipc/attachment_broker_mac_unittest.cc
@@ -422,6 +422,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();
@@ -431,6 +437,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());
@@ -869,11 +879,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());
{
@@ -938,8 +948,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(scoped_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());
@@ -1058,11 +1072,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());
{

Powered by Google App Engine
This is Rietveld 408576698