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

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 2494943002: Remove IPC::BrokerableAttachment. (Closed)
Patch Set: extra test output Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « ipc/ipc_platform_file_attachment_posix.cc ('k') | ipc/mach_port_attachment_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 }; 70 };
71 71
72 class MyChannelDescriptorListener : public MyChannelDescriptorListenerBase { 72 class MyChannelDescriptorListener : public MyChannelDescriptorListenerBase {
73 public: 73 public:
74 explicit MyChannelDescriptorListener(ino_t expected_inode_num) 74 explicit MyChannelDescriptorListener(ino_t expected_inode_num)
75 : MyChannelDescriptorListenerBase(), 75 : MyChannelDescriptorListenerBase(),
76 expected_inode_num_(expected_inode_num), 76 expected_inode_num_(expected_inode_num),
77 num_fds_received_(0) { 77 num_fds_received_(0) {
78 } 78 }
79 79
80 bool GotExpectedNumberOfDescriptors() const { 80 unsigned num_fds_received() const {
81 return num_fds_received_ == kNumFDsToSend * kNumMessages; 81 return num_fds_received_;
82 } 82 }
83 83
84 void OnChannelError() override { 84 void OnChannelError() override {
85 base::MessageLoop::current()->QuitWhenIdle(); 85 base::MessageLoop::current()->QuitWhenIdle();
86 } 86 }
87 87
88 protected: 88 protected:
89 void HandleFD(int fd) override { 89 void HandleFD(int fd) override {
90 ASSERT_GE(fd, 0); 90 ASSERT_GE(fd, 0);
91 // Check that we can read from the FD. 91 // Check that we can read from the FD.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 MyChannelDescriptorListener listener(expected_inode_num); 156 MyChannelDescriptorListener listener(expected_inode_num);
157 157
158 // Set up IPC channel. 158 // Set up IPC channel.
159 Connect(&listener); 159 Connect(&listener);
160 160
161 // Run message loop. 161 // Run message loop.
162 base::RunLoop().Run(); 162 base::RunLoop().Run();
163 163
164 // Verify that the message loop was exited due to getting the correct number 164 // Verify that the message loop was exited due to getting the correct number
165 // of descriptors, and not because of the channel closing unexpectedly. 165 // of descriptors, and not because of the channel closing unexpectedly.
166 EXPECT_TRUE(listener.GotExpectedNumberOfDescriptors()); 166 EXPECT_EQ(kNumFDsToSend * kNumMessages, listener.num_fds_received());
167 167
168 Close(); 168 Close();
169 } 169 }
170 }; 170 };
171 171
172 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE( 172 DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE(
173 SendFdsClient, 173 SendFdsClient,
174 SendFdsTestClientFixture) { 174 SendFdsTestClientFixture) {
175 struct stat st; 175 struct stat st;
176 int fd = open(kDevZeroPath, O_RDONLY); 176 int fd = open(kDevZeroPath, O_RDONLY);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 << "Sandbox wasn't properly enabled"; 209 << "Sandbox wasn't properly enabled";
210 210
211 // See if we can receive a file descriptor. 211 // See if we can receive a file descriptor.
212 SendFdsClientCommon("SendFdsSandboxedClient", st.st_ino); 212 SendFdsClientCommon("SendFdsSandboxedClient", st.st_ino);
213 } 213 }
214 #endif // defined(OS_MACOSX) 214 #endif // defined(OS_MACOSX)
215 215
216 } // namespace 216 } // namespace
217 217
218 #endif // defined(OS_POSIX) 218 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_platform_file_attachment_posix.cc ('k') | ipc/mach_port_attachment_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698