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 #include "ipc/ipc_tests.h" | 7 #include "ipc/ipc_tests.h" |
8 | 8 |
9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
10 extern "C" { | 10 extern "C" { |
11 #include <sandbox.h> | 11 #include <sandbox.h> |
12 } | 12 } |
13 #endif | 13 #endif |
14 #include <fcntl.h> | 14 #include <fcntl.h> |
15 #include <sys/stat.h> | 15 #include <sys/stat.h> |
16 | 16 |
17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
18 #include "base/posix/eintr_wrapper.h" | 18 #include "base/posix/eintr_wrapper.h" |
19 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
| 20 #include "ipc/ipc_listener.h" |
20 #include "ipc/ipc_message_utils.h" | 21 #include "ipc/ipc_message_utils.h" |
21 #include "ipc/ipc_multiprocess_test.h" | 22 #include "ipc/ipc_multiprocess_test.h" |
22 #include "testing/multiprocess_func_list.h" | 23 #include "testing/multiprocess_func_list.h" |
23 | 24 |
24 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
25 #include "base/file_descriptor_posix.h" | 26 #include "base/file_descriptor_posix.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 const unsigned kNumFDsToSend = 20; | 30 const unsigned kNumFDsToSend = 20; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 75 |
75 bool GotExpectedNumberOfDescriptors() { | 76 bool GotExpectedNumberOfDescriptors() { |
76 return kNumFDsToSend == num_fds_received_; | 77 return kNumFDsToSend == num_fds_received_; |
77 } | 78 } |
78 | 79 |
79 private: | 80 private: |
80 ino_t expected_inode_num_; | 81 ino_t expected_inode_num_; |
81 unsigned num_fds_received_; | 82 unsigned num_fds_received_; |
82 }; | 83 }; |
83 | 84 |
84 void TestDescriptorServer(IPC::Channel &chan, | 85 void TestDescriptorServer(IPC::Channel& chan, |
85 base::ProcessHandle process_handle) { | 86 base::ProcessHandle process_handle) { |
86 ASSERT_TRUE(process_handle); | 87 ASSERT_TRUE(process_handle); |
87 | 88 |
88 for (unsigned i = 0; i < kNumFDsToSend; ++i) { | 89 for (unsigned i = 0; i < kNumFDsToSend; ++i) { |
89 base::FileDescriptor descriptor; | 90 base::FileDescriptor descriptor; |
90 const int fd = open(kDevZeroPath, O_RDONLY); | 91 const int fd = open(kDevZeroPath, O_RDONLY); |
91 ASSERT_GE(fd, 0); | 92 ASSERT_GE(fd, 0); |
92 descriptor.auto_close = true; | 93 descriptor.auto_close = true; |
93 descriptor.fd = fd; | 94 descriptor.fd = fd; |
94 | 95 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER, | 196 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER, |
196 &listener); | 197 &listener); |
197 ASSERT_TRUE(chan.Connect()); | 198 ASSERT_TRUE(chan.Connect()); |
198 | 199 |
199 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT, | 200 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT, |
200 &chan); | 201 &chan); |
201 TestDescriptorServer(chan, process_handle); | 202 TestDescriptorServer(chan, process_handle); |
202 } | 203 } |
203 | 204 |
204 #endif // defined(OS_POSIX) | 205 #endif // defined(OS_POSIX) |
OLD | NEW |