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

Side by Side Diff: ipc/sync_socket_unittest.cc

Issue 464020: Add non-blocking peek for the syncsocket... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | Annotate | Revision Log
« no previous file with comments | « base/sync_socket_win.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) 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 <stdio.h> 5 #include <stdio.h>
6 #include <iostream> 6 #include <iostream>
7 #include <string> 7 #include <string>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 IPC_MESSAGE_HANDLER(MsgClassResponse, OnMsgClassResponse) 182 IPC_MESSAGE_HANDLER(MsgClassResponse, OnMsgClassResponse)
183 IPC_END_MESSAGE_MAP() 183 IPC_END_MESSAGE_MAP()
184 } 184 }
185 } 185 }
186 186
187 private: 187 private:
188 // When a response is received from the server, it sends the same 188 // When a response is received from the server, it sends the same
189 // string as was written on the SyncSocket. These are compared 189 // string as was written on the SyncSocket. These are compared
190 // and a shutdown message is sent back to the server. 190 // and a shutdown message is sent back to the server.
191 void OnMsgClassResponse(const std::string& str) { 191 void OnMsgClassResponse(const std::string& str) {
192 #if defined(OS_WIN)
193 // We rely on the order of sync_socket.Send() and chan_->Send() in
194 // the SyncSocketServerListener object.
195 EXPECT_EQ(kHelloStringLength, socket_->Peek());
196 #endif
192 char buf[kHelloStringLength]; 197 char buf[kHelloStringLength];
193 socket_->Receive(static_cast<void*>(buf), kHelloStringLength); 198 socket_->Receive(static_cast<void*>(buf), kHelloStringLength);
194 EXPECT_EQ(strcmp(str.c_str(), buf), 0); 199 EXPECT_EQ(strcmp(str.c_str(), buf), 0);
195 IPC::Message* msg = new MsgClassShutdown(); 200 IPC::Message* msg = new MsgClassShutdown();
196 EXPECT_NE(msg, reinterpret_cast<IPC::Message*>(NULL)); 201 EXPECT_NE(msg, reinterpret_cast<IPC::Message*>(NULL));
197 EXPECT_TRUE(chan_->Send(msg)); 202 EXPECT_TRUE(chan_->Send(msg));
198 MessageLoop::current()->Quit(); 203 MessageLoop::current()->Quit();
199 } 204 }
200 205
201 base::SyncSocket* socket_; 206 base::SyncSocket* socket_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_NE(msg, reinterpret_cast<IPC::Message*>(NULL)); 242 EXPECT_NE(msg, reinterpret_cast<IPC::Message*>(NULL));
238 EXPECT_TRUE(chan.Send(msg)); 243 EXPECT_TRUE(chan.Send(msg));
239 // Use the current thread as the I/O thread. 244 // Use the current thread as the I/O thread.
240 MessageLoop::current()->Run(); 245 MessageLoop::current()->Run();
241 // Shut down. 246 // Shut down.
242 delete pair[0]; 247 delete pair[0];
243 delete pair[1]; 248 delete pair[1];
244 EXPECT_TRUE(base::WaitForSingleProcess(server_process, 5000)); 249 EXPECT_TRUE(base::WaitForSingleProcess(server_process, 5000));
245 base::CloseProcessHandle(server_process); 250 base::CloseProcessHandle(server_process);
246 } 251 }
OLDNEW
« no previous file with comments | « base/sync_socket_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698