OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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" { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // was actually the same physical file as the one we were expecting. | 44 // was actually the same physical file as the one we were expecting. |
45 ASSERT_EQ(inode_num, st.st_ino); | 45 ASSERT_EQ(inode_num, st.st_ino); |
46 } | 46 } |
47 | 47 |
48 class MyChannelDescriptorListener : public IPC::Channel::Listener { | 48 class MyChannelDescriptorListener : public IPC::Channel::Listener { |
49 public: | 49 public: |
50 MyChannelDescriptorListener(ino_t expected_inode_num) | 50 MyChannelDescriptorListener(ino_t expected_inode_num) |
51 : expected_inode_num_(expected_inode_num), | 51 : expected_inode_num_(expected_inode_num), |
52 num_fds_received_(0) {} | 52 num_fds_received_(0) {} |
53 | 53 |
54 virtual void OnMessageReceived(const IPC::Message& message) { | 54 virtual bool OnMessageReceived(const IPC::Message& message) { |
55 void* iter = NULL; | 55 void* iter = NULL; |
56 | 56 |
57 ++num_fds_received_; | 57 ++num_fds_received_; |
58 base::FileDescriptor descriptor; | 58 base::FileDescriptor descriptor; |
59 | 59 |
60 ASSERT_TRUE( | 60 IPC::ParamTraits<base::FileDescriptor>::Read( |
61 IPC::ParamTraits<base::FileDescriptor>::Read( | 61 &message, &iter, &descriptor); |
62 &message, &iter, &descriptor)); | |
63 | 62 |
64 VerifyAndCloseDescriptor(descriptor.fd, expected_inode_num_); | 63 VerifyAndCloseDescriptor(descriptor.fd, expected_inode_num_); |
65 if (num_fds_received_ == kNumFDsToSend) { | 64 if (num_fds_received_ == kNumFDsToSend) { |
66 MessageLoop::current()->Quit(); | 65 MessageLoop::current()->Quit(); |
67 } | 66 } |
| 67 return true; |
68 } | 68 } |
69 | 69 |
70 virtual void OnChannelError() { | 70 virtual void OnChannelError() { |
71 MessageLoop::current()->Quit(); | 71 MessageLoop::current()->Quit(); |
72 } | 72 } |
73 | 73 |
74 bool GotExpectedNumberOfDescriptors() { | 74 bool GotExpectedNumberOfDescriptors() { |
75 return kNumFDsToSend == num_fds_received_; | 75 return kNumFDsToSend == num_fds_received_; |
76 } | 76 } |
77 | 77 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER, | 193 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER, |
194 &listener); | 194 &listener); |
195 ASSERT_TRUE(chan.Connect()); | 195 ASSERT_TRUE(chan.Connect()); |
196 | 196 |
197 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT, | 197 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT, |
198 &chan); | 198 &chan); |
199 TestDescriptorServer(chan, process_handle); | 199 TestDescriptorServer(chan, process_handle); |
200 } | 200 } |
201 | 201 |
202 #endif // defined(OS_POSIX) | 202 #endif // defined(OS_POSIX) |
OLD | NEW |