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

Side by Side Diff: ipc/sync_socket_unittest.cc

Issue 10692155: Switch to TimeDelta interfaces for process waiting functions in net and ipc. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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_tests.cc ('k') | net/base/file_stream_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 "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string> 8 #include <string>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Set up a message to pass the handle to the server. 196 // Set up a message to pass the handle to the server.
197 base::FileDescriptor filedesc(target_handle, false); 197 base::FileDescriptor filedesc(target_handle, false);
198 IPC::Message* msg = new MsgClassSetHandle(filedesc); 198 IPC::Message* msg = new MsgClassSetHandle(filedesc);
199 #endif // defined(OS_WIN) 199 #endif // defined(OS_WIN)
200 EXPECT_TRUE(chan.Send(msg)); 200 EXPECT_TRUE(chan.Send(msg));
201 // Use the current thread as the I/O thread. 201 // Use the current thread as the I/O thread.
202 MessageLoop::current()->Run(); 202 MessageLoop::current()->Run();
203 // Shut down. 203 // Shut down.
204 pair[0].Close(); 204 pair[0].Close();
205 pair[1].Close(); 205 pair[1].Close();
206 EXPECT_TRUE(base::WaitForSingleProcess(server_process, 5000)); 206 EXPECT_TRUE(base::WaitForSingleProcess(
207 server_process, base::TimeDelta::FromSeconds(5)));
207 base::CloseProcessHandle(server_process); 208 base::CloseProcessHandle(server_process);
208 } 209 }
209 210
210 211
211 // A blocking read operation that will block the thread until it receives 212 // A blocking read operation that will block the thread until it receives
212 // |length| bytes of packets or Shutdown() is called on another thread. 213 // |length| bytes of packets or Shutdown() is called on another thread.
213 static void BlockingRead(base::SyncSocket* socket, char* buf, 214 static void BlockingRead(base::SyncSocket* socket, char* buf,
214 size_t length, size_t* received) { 215 size_t length, size_t* received) {
215 DCHECK(buf != NULL); 216 DCHECK(buf != NULL);
216 // Notify the parent thread that we're up and running. 217 // Notify the parent thread that we're up and running.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 EXPECT_EQ(0U, pair[0].Send(kHelloString, kHelloStringLength)); 301 EXPECT_EQ(0U, pair[0].Send(kHelloString, kHelloStringLength));
301 EXPECT_EQ(bytes_in_buffer, pair[1].Peek()); 302 EXPECT_EQ(bytes_in_buffer, pair[1].Peek());
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 }
OLDNEW
« no previous file with comments | « ipc/ipc_tests.cc ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698