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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 RunServer(); | 147 RunServer(); |
148 } | 148 } |
149 | 149 |
150 int SendFdsClientCommon(const std::string& test_client_name, | 150 int SendFdsClientCommon(const std::string& test_client_name, |
151 ino_t expected_inode_num) { | 151 ino_t expected_inode_num) { |
152 base::MessageLoopForIO main_message_loop; | 152 base::MessageLoopForIO main_message_loop; |
153 MyChannelDescriptorListener listener(expected_inode_num); | 153 MyChannelDescriptorListener listener(expected_inode_num); |
154 | 154 |
155 // Set up IPC channel. | 155 // Set up IPC channel. |
156 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( | 156 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( |
157 IPCTestBase::GetChannelName(test_client_name), &listener, nullptr)); | 157 IPCTestBase::GetChannelName(test_client_name), &listener)); |
158 CHECK(channel->Connect()); | 158 CHECK(channel->Connect()); |
159 | 159 |
160 // Run message loop. | 160 // Run message loop. |
161 base::MessageLoop::current()->Run(); | 161 base::MessageLoop::current()->Run(); |
162 | 162 |
163 // Verify that the message loop was exited due to getting the correct number | 163 // Verify that the message loop was exited due to getting the correct number |
164 // of descriptors, and not because of the channel closing unexpectedly. | 164 // of descriptors, and not because of the channel closing unexpectedly. |
165 CHECK(listener.GotExpectedNumberOfDescriptors()); | 165 CHECK(listener.GotExpectedNumberOfDescriptors()); |
166 | 166 |
167 return 0; | 167 return 0; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 base::Callback<void(int)> cb, | 242 base::Callback<void(int)> cb, |
243 int fds_to_send) : | 243 int fds_to_send) : |
244 in_thread_(in_thread), | 244 in_thread_(in_thread), |
245 out_thread_(out_thread), | 245 out_thread_(out_thread), |
246 cb_listener_(cb, fds_to_send), | 246 cb_listener_(cb, fds_to_send), |
247 null_listener_(base::Bind(&null_cb), 0) { | 247 null_listener_(base::Bind(&null_cb), 0) { |
248 } | 248 } |
249 | 249 |
250 void Init() { | 250 void Init() { |
251 IPC::ChannelHandle in_handle("IN"); | 251 IPC::ChannelHandle in_handle("IN"); |
252 in = IPC::Channel::CreateServer(in_handle, &null_listener_, nullptr); | 252 in = IPC::Channel::CreateServer(in_handle, &null_listener_); |
253 IPC::ChannelHandle out_handle( | 253 IPC::ChannelHandle out_handle( |
254 "OUT", base::FileDescriptor(in->TakeClientFileDescriptor())); | 254 "OUT", base::FileDescriptor(in->TakeClientFileDescriptor())); |
255 out = IPC::Channel::CreateClient(out_handle, &cb_listener_, nullptr); | 255 out = IPC::Channel::CreateClient(out_handle, &cb_listener_); |
256 // PostTask the connect calls to make sure the callbacks happens | 256 // PostTask the connect calls to make sure the callbacks happens |
257 // on the right threads. | 257 // on the right threads. |
258 in_thread_->task_runner()->PostTask( | 258 in_thread_->task_runner()->PostTask( |
259 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, in.get())); | 259 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, in.get())); |
260 out_thread_->task_runner()->PostTask( | 260 out_thread_->task_runner()->PostTask( |
261 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, out.get())); | 261 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, out.get())); |
262 } | 262 } |
263 | 263 |
264 static void DestroyChannel(scoped_ptr<IPC::Channel> *c, | 264 static void DestroyChannel(scoped_ptr<IPC::Channel> *c, |
265 base::WaitableEvent *event) { | 265 base::WaitableEvent *event) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 base::WaitableEvent received_; | 377 base::WaitableEvent received_; |
378 }; | 378 }; |
379 | 379 |
380 TEST_F(IPCMultiSendingFdsTest, StressTest) { | 380 TEST_F(IPCMultiSendingFdsTest, StressTest) { |
381 Run(); | 381 Run(); |
382 } | 382 } |
383 | 383 |
384 } // namespace | 384 } // namespace |
385 | 385 |
386 #endif // defined(OS_POSIX) | 386 #endif // defined(OS_POSIX) |
OLD | NEW |