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

Side by Side Diff: ipc/sync_socket_unittest.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/mojo/ipc_channel_mojo_unittest.cc ('k') | no next file » | 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 "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
11 #include <string> 11 #include <string>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "ipc/ipc_test_base.h" 20 #include "ipc/ipc_test_base.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 #if defined(OS_POSIX) 23 #if defined(OS_POSIX)
23 #include "base/file_descriptor_posix.h" 24 #include "base/file_descriptor_posix.h"
24 #endif 25 #endif
25 26
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 109
109 // Runs the fuzzing server child mode. Returns when the preset number of 110 // Runs the fuzzing server child mode. Returns when the preset number of
110 // messages have been received. 111 // messages have been received.
111 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) { 112 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) {
112 base::MessageLoopForIO main_message_loop; 113 base::MessageLoopForIO main_message_loop;
113 SyncSocketServerListener listener; 114 SyncSocketServerListener listener;
114 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 115 std::unique_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
115 IPCTestBase::GetChannelName("SyncSocketServerClient"), &listener)); 116 IPCTestBase::GetChannelName("SyncSocketServerClient"), &listener));
116 EXPECT_TRUE(channel->Connect()); 117 EXPECT_TRUE(channel->Connect());
117 listener.Init(channel.get()); 118 listener.Init(channel.get());
118 base::MessageLoop::current()->Run(); 119 base::RunLoop().Run();
119 return 0; 120 return 0;
120 } 121 }
121 122
122 // The SyncSocket client listener only processes one sort of message, 123 // The SyncSocket client listener only processes one sort of message,
123 // a response from the server. 124 // a response from the server.
124 class SyncSocketClientListener : public IPC::Listener { 125 class SyncSocketClientListener : public IPC::Listener {
125 public: 126 public:
126 SyncSocketClientListener() { 127 SyncSocketClientListener() {
127 } 128 }
128 129
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Set up a message to pass the handle to the server. 193 // Set up a message to pass the handle to the server.
193 IPC::Message* msg = new MsgClassSetHandle(target_handle); 194 IPC::Message* msg = new MsgClassSetHandle(target_handle);
194 #else 195 #else
195 target_handle = pair[1].handle(); 196 target_handle = pair[1].handle();
196 // Set up a message to pass the handle to the server. 197 // Set up a message to pass the handle to the server.
197 base::FileDescriptor filedesc(target_handle, false); 198 base::FileDescriptor filedesc(target_handle, false);
198 IPC::Message* msg = new MsgClassSetHandle(filedesc); 199 IPC::Message* msg = new MsgClassSetHandle(filedesc);
199 #endif // defined(OS_WIN) 200 #endif // defined(OS_WIN)
200 EXPECT_TRUE(sender()->Send(msg)); 201 EXPECT_TRUE(sender()->Send(msg));
201 // Use the current thread as the I/O thread. 202 // Use the current thread as the I/O thread.
202 base::MessageLoop::current()->Run(); 203 base::RunLoop().Run();
203 // Shut down. 204 // Shut down.
204 pair[0].Close(); 205 pair[0].Close();
205 pair[1].Close(); 206 pair[1].Close();
206 EXPECT_TRUE(WaitForClientShutdown()); 207 EXPECT_TRUE(WaitForClientShutdown());
207 DestroyChannel(); 208 DestroyChannel();
208 } 209 }
209 210
210 // A blocking read operation that will block the thread until it receives 211 // A blocking read operation that will block the thread until it receives
211 // |length| bytes of packets or Shutdown() is called on another thread. 212 // |length| bytes of packets or Shutdown() is called on another thread.
212 static void BlockingRead(base::SyncSocket* socket, char* buf, 213 static void BlockingRead(base::SyncSocket* socket, char* buf,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 303
303 // Read from another socket to free some space for a new write. 304 // Read from another socket to free some space for a new write.
304 char hello[kHelloStringLength] = {0}; 305 char hello[kHelloStringLength] = {0};
305 pair[1].Receive(&hello[0], sizeof(hello)); 306 pair[1].Receive(&hello[0], sizeof(hello));
306 307
307 // Should be able to write more data to the buffer now. 308 // Should be able to write more data to the buffer now.
308 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); 309 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength));
309 } 310 }
310 311
311 } // namespace 312 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_channel_mojo_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698