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

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 2087163003: Remove calls to deprecated MessageLoop methods in ipc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual changes Created 4 years, 6 months 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_perftest_support.cc ('k') | ipc/ipc_sync_channel_unittest.cc » ('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>
11 }; 11 };
12 #endif 12 #endif
13 #include <fcntl.h> 13 #include <fcntl.h>
14 #include <stddef.h> 14 #include <stddef.h>
15 #include <sys/socket.h> 15 #include <sys/socket.h>
16 #include <sys/stat.h> 16 #include <sys/stat.h>
17 #include <unistd.h> 17 #include <unistd.h>
18 18
19 #include <memory> 19 #include <memory>
20 #include <queue> 20 #include <queue>
21 21
22 #include "base/callback.h" 22 #include "base/callback.h"
23 #include "base/file_descriptor_posix.h" 23 #include "base/file_descriptor_posix.h"
24 #include "base/location.h" 24 #include "base/location.h"
25 #include "base/pickle.h" 25 #include "base/pickle.h"
26 #include "base/posix/eintr_wrapper.h" 26 #include "base/posix/eintr_wrapper.h"
27 #include "base/run_loop.h"
27 #include "base/single_thread_task_runner.h" 28 #include "base/single_thread_task_runner.h"
28 #include "base/synchronization/waitable_event.h" 29 #include "base/synchronization/waitable_event.h"
29 #include "ipc/ipc_message_attachment_set.h" 30 #include "ipc/ipc_message_attachment_set.h"
30 #include "ipc/ipc_message_utils.h" 31 #include "ipc/ipc_message_utils.h"
31 #include "ipc/ipc_test_base.h" 32 #include "ipc/ipc_test_base.h"
32 33
33 #if defined(OS_POSIX) 34 #if defined(OS_POSIX)
34 #include "base/macros.h" 35 #include "base/macros.h"
35 #endif 36 #endif
36 37
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 for (unsigned j = 0; j < kNumFDsToSend; ++j) { 127 for (unsigned j = 0; j < kNumFDsToSend; ++j) {
127 const int fd = open(kDevZeroPath, O_RDONLY); 128 const int fd = open(kDevZeroPath, O_RDONLY);
128 ASSERT_GE(fd, 0); 129 ASSERT_GE(fd, 0);
129 base::FileDescriptor descriptor(fd, true); 130 base::FileDescriptor descriptor(fd, true);
130 IPC::ParamTraits<base::FileDescriptor>::Write(message, descriptor); 131 IPC::ParamTraits<base::FileDescriptor>::Write(message, descriptor);
131 } 132 }
132 ASSERT_TRUE(sender()->Send(message)); 133 ASSERT_TRUE(sender()->Send(message));
133 } 134 }
134 135
135 // Run message loop. 136 // Run message loop.
136 base::MessageLoop::current()->Run(); 137 base::RunLoop().Run();
137 138
138 // Close the channel so the client's OnChannelError() gets fired. 139 // Close the channel so the client's OnChannelError() gets fired.
139 channel()->Close(); 140 channel()->Close();
140 141
141 EXPECT_TRUE(WaitForClientShutdown()); 142 EXPECT_TRUE(WaitForClientShutdown());
142 DestroyChannel(); 143 DestroyChannel();
143 } 144 }
144 }; 145 };
145 146
146 TEST_F(IPCSendFdsTest, DescriptorTest) { 147 TEST_F(IPCSendFdsTest, DescriptorTest) {
147 Init("SendFdsClient"); 148 Init("SendFdsClient");
148 RunServer(); 149 RunServer();
149 } 150 }
150 151
151 int SendFdsClientCommon(const std::string& test_client_name, 152 int SendFdsClientCommon(const std::string& test_client_name,
152 ino_t expected_inode_num) { 153 ino_t expected_inode_num) {
153 base::MessageLoopForIO main_message_loop; 154 base::MessageLoopForIO main_message_loop;
154 MyChannelDescriptorListener listener(expected_inode_num); 155 MyChannelDescriptorListener listener(expected_inode_num);
155 156
156 // Set up IPC channel. 157 // Set up IPC channel.
157 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 158 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
158 IPCTestBase::GetChannelName(test_client_name), &listener)); 159 IPCTestBase::GetChannelName(test_client_name), &listener));
159 CHECK(channel->Connect()); 160 CHECK(channel->Connect());
160 161
161 // Run message loop. 162 // Run message loop.
162 base::MessageLoop::current()->Run(); 163 base::RunLoop().Run();
163 164
164 // Verify that the message loop was exited due to getting the correct number 165 // Verify that the message loop was exited due to getting the correct number
165 // of descriptors, and not because of the channel closing unexpectedly. 166 // of descriptors, and not because of the channel closing unexpectedly.
166 CHECK(listener.GotExpectedNumberOfDescriptors()); 167 CHECK(listener.GotExpectedNumberOfDescriptors());
167 168
168 return 0; 169 return 0;
169 } 170 }
170 171
171 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsClient) { 172 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendFdsClient) {
172 struct stat st; 173 struct stat st;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 base::WaitableEvent received_; 383 base::WaitableEvent received_;
383 }; 384 };
384 385
385 TEST_F(IPCMultiSendingFdsTest, StressTest) { 386 TEST_F(IPCMultiSendingFdsTest, StressTest) {
386 Run(); 387 Run();
387 } 388 }
388 389
389 } // namespace 390 } // namespace
390 391
391 #endif // defined(OS_POSIX) 392 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_perftest_support.cc ('k') | ipc/ipc_sync_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698