| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #if defined(OS_MACOSX) | 8 #if defined(OS_MACOSX) |
| 9 extern "C" { | 9 extern "C" { |
| 10 #include <sandbox.h> | 10 #include <sandbox.h> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 Init("SendFdsClient"); | 127 Init("SendFdsClient"); |
| 128 RunServer(); | 128 RunServer(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 int SendFdsClientCommon(const std::string& test_client_name, | 131 int SendFdsClientCommon(const std::string& test_client_name, |
| 132 ino_t expected_inode_num) { | 132 ino_t expected_inode_num) { |
| 133 base::MessageLoopForIO main_message_loop; | 133 base::MessageLoopForIO main_message_loop; |
| 134 MyChannelDescriptorListener listener(expected_inode_num); | 134 MyChannelDescriptorListener listener(expected_inode_num); |
| 135 | 135 |
| 136 // Set up IPC channel. | 136 // Set up IPC channel. |
| 137 IPC::Channel channel(IPCTestBase::GetChannelName(test_client_name), | 137 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( |
| 138 IPC::Channel::MODE_CLIENT, | 138 IPCTestBase::GetChannelName(test_client_name), |
| 139 &listener); | 139 &listener)); |
| 140 CHECK(channel.Connect()); | 140 CHECK(channel->Connect()); |
| 141 | 141 |
| 142 // Run message loop. | 142 // Run message loop. |
| 143 base::MessageLoop::current()->Run(); | 143 base::MessageLoop::current()->Run(); |
| 144 | 144 |
| 145 // Verify that the message loop was exited due to getting the correct number | 145 // Verify that the message loop was exited due to getting the correct number |
| 146 // of descriptors, and not because of the channel closing unexpectedly. | 146 // of descriptors, and not because of the channel closing unexpectedly. |
| 147 CHECK(listener.GotExpectedNumberOfDescriptors()); | 147 CHECK(listener.GotExpectedNumberOfDescriptors()); |
| 148 | 148 |
| 149 return 0; | 149 return 0; |
| 150 } | 150 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 base::Callback<void(int)> cb, | 226 base::Callback<void(int)> cb, |
| 227 int fds_to_send) : | 227 int fds_to_send) : |
| 228 in_thread_(in_thread), | 228 in_thread_(in_thread), |
| 229 out_thread_(out_thread), | 229 out_thread_(out_thread), |
| 230 cb_listener_(cb, fds_to_send), | 230 cb_listener_(cb, fds_to_send), |
| 231 null_listener_(base::Bind(&null_cb), 0) { | 231 null_listener_(base::Bind(&null_cb), 0) { |
| 232 } | 232 } |
| 233 | 233 |
| 234 void Init() { | 234 void Init() { |
| 235 IPC::ChannelHandle in_handle("IN"); | 235 IPC::ChannelHandle in_handle("IN"); |
| 236 in.reset(new IPC::Channel(in_handle, | 236 in = IPC::Channel::CreateServer(in_handle, &null_listener_); |
| 237 IPC::Channel::MODE_SERVER, | |
| 238 &null_listener_)); | |
| 239 base::FileDescriptor out_fd(in->TakeClientFileDescriptor(), false); | 237 base::FileDescriptor out_fd(in->TakeClientFileDescriptor(), false); |
| 240 IPC::ChannelHandle out_handle("OUT", out_fd); | 238 IPC::ChannelHandle out_handle("OUT", out_fd); |
| 241 out.reset(new IPC::Channel(out_handle, | 239 out = IPC::Channel::CreateClient(out_handle, &cb_listener_); |
| 242 IPC::Channel::MODE_CLIENT, | |
| 243 &cb_listener_)); | |
| 244 // PostTask the connect calls to make sure the callbacks happens | 240 // PostTask the connect calls to make sure the callbacks happens |
| 245 // on the right threads. | 241 // on the right threads. |
| 246 in_thread_->message_loop()->PostTask( | 242 in_thread_->message_loop()->PostTask( |
| 247 FROM_HERE, | 243 FROM_HERE, |
| 248 base::Bind(&PipeChannelHelper::Connect, in.get())); | 244 base::Bind(&PipeChannelHelper::Connect, in.get())); |
| 249 out_thread_->message_loop()->PostTask( | 245 out_thread_->message_loop()->PostTask( |
| 250 FROM_HERE, | 246 FROM_HERE, |
| 251 base::Bind(&PipeChannelHelper::Connect, out.get())); | 247 base::Bind(&PipeChannelHelper::Connect, out.get())); |
| 252 } | 248 } |
| 253 | 249 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 base::WaitableEvent received_; | 367 base::WaitableEvent received_; |
| 372 }; | 368 }; |
| 373 | 369 |
| 374 TEST_F(IPCMultiSendingFdsTest, StressTest) { | 370 TEST_F(IPCMultiSendingFdsTest, StressTest) { |
| 375 Run(); | 371 Run(); |
| 376 } | 372 } |
| 377 | 373 |
| 378 } // namespace | 374 } // namespace |
| 379 | 375 |
| 380 #endif // defined(OS_POSIX) | 376 #endif // defined(OS_POSIX) |
| OLD | NEW |