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

Side by Side Diff: ipc/ipc_tests.cc

Issue 10698057: Remove Message::Sender and Channel::Listener typedefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_test_sink.cc ('k') | ipc/sync_socket_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_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Make sure we can handle large messages. 175 // Make sure we can handle large messages.
176 char junk[kLongMessageStringNumBytes]; 176 char junk[kLongMessageStringNumBytes];
177 memset(junk, 'a', sizeof(junk)-1); 177 memset(junk, 'a', sizeof(junk)-1);
178 junk[sizeof(junk)-1] = 0; 178 junk[sizeof(junk)-1] = 0;
179 message->WriteString(std::string(junk)); 179 message->WriteString(std::string(junk));
180 180
181 // DEBUG: printf("[%u] sending message [%s]\n", GetCurrentProcessId(), text); 181 // DEBUG: printf("[%u] sending message [%s]\n", GetCurrentProcessId(), text);
182 sender->Send(message); 182 sender->Send(message);
183 } 183 }
184 184
185 class MyChannelListener : public IPC::Channel::Listener { 185 class MyChannelListener : public IPC::Listener {
186 public: 186 public:
187 virtual bool OnMessageReceived(const IPC::Message& message) { 187 virtual bool OnMessageReceived(const IPC::Message& message) {
188 IPC::MessageIterator iter(message); 188 IPC::MessageIterator iter(message);
189 189
190 iter.NextInt(); 190 iter.NextInt();
191 const std::string data = iter.NextString(); 191 const std::string data = iter.NextString();
192 const std::string big_string = iter.NextString(); 192 const std::string big_string = iter.NextString();
193 EXPECT_EQ(kLongMessageStringNumBytes - 1, big_string.length()); 193 EXPECT_EQ(kLongMessageStringNumBytes - 1, big_string.length());
194 194
195 195
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // run message loop 322 // run message loop
323 MessageLoop::current()->Run(); 323 MessageLoop::current()->Run();
324 324
325 // cleanup child process 325 // cleanup child process
326 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); 326 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000));
327 base::CloseProcessHandle(process_handle); 327 base::CloseProcessHandle(process_handle);
328 } 328 }
329 thread.Stop(); 329 thread.Stop();
330 } 330 }
331 331
332 class ChannelListenerWithOnConnectedSend : public IPC::Channel::Listener { 332 class ChannelListenerWithOnConnectedSend : public IPC::Listener {
333 public: 333 public:
334 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { 334 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE {
335 SendNextMessage(); 335 SendNextMessage();
336 } 336 }
337 337
338 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 338 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
339 IPC::MessageIterator iter(message); 339 IPC::MessageIterator iter(message);
340 340
341 iter.NextInt(); 341 iter.NextInt();
342 const std::string data = iter.NextString(); 342 const std::string data = iter.NextString();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // regular unit tests. 432 // regular unit tests.
433 // 433 //
434 // This test is not automated. To test, you will want to vary the message 434 // This test is not automated. To test, you will want to vary the message
435 // count and message size in TEST to get the numbers you want. 435 // count and message size in TEST to get the numbers you want.
436 // 436 //
437 // FIXME(brettw): Automate this test and have it run by default. 437 // FIXME(brettw): Automate this test and have it run by default.
438 438
439 // This channel listener just replies to all messages with the exact same 439 // This channel listener just replies to all messages with the exact same
440 // message. It assumes each message has one string parameter. When the string 440 // message. It assumes each message has one string parameter. When the string
441 // "quit" is sent, it will exit. 441 // "quit" is sent, it will exit.
442 class ChannelReflectorListener : public IPC::Channel::Listener { 442 class ChannelReflectorListener : public IPC::Listener {
443 public: 443 public:
444 explicit ChannelReflectorListener(IPC::Channel *channel) : 444 explicit ChannelReflectorListener(IPC::Channel *channel) :
445 channel_(channel), 445 channel_(channel),
446 count_messages_(0), 446 count_messages_(0),
447 latency_messages_(0) { 447 latency_messages_(0) {
448 std::cout << "Reflector up" << std::endl; 448 std::cout << "Reflector up" << std::endl;
449 } 449 }
450 450
451 ~ChannelReflectorListener() { 451 ~ChannelReflectorListener() {
452 std::cout << "Client Messages: " << count_messages_ << std::endl; 452 std::cout << "Client Messages: " << count_messages_ << std::endl;
(...skipping 21 matching lines...) Expand all
474 channel_->Send(msg); 474 channel_->Send(msg);
475 return true; 475 return true;
476 } 476 }
477 477
478 private: 478 private:
479 IPC::Channel *channel_; 479 IPC::Channel *channel_;
480 int count_messages_; 480 int count_messages_;
481 int latency_messages_; 481 int latency_messages_;
482 }; 482 };
483 483
484 class ChannelPerfListener : public IPC::Channel::Listener { 484 class ChannelPerfListener : public IPC::Listener {
485 public: 485 public:
486 ChannelPerfListener(IPC::Channel* channel, int msg_count, int msg_size) : 486 ChannelPerfListener(IPC::Channel* channel, int msg_count, int msg_size) :
487 count_down_(msg_count), 487 count_down_(msg_count),
488 channel_(channel), 488 channel_(channel),
489 count_messages_(0), 489 count_messages_(0),
490 latency_messages_(0) { 490 latency_messages_(0) {
491 payload_.resize(msg_size); 491 payload_.resize(msg_size);
492 for (int i = 0; i < static_cast<int>(payload_.size()); i++) 492 for (int i = 0; i < static_cast<int>(payload_.size()); i++)
493 payload_[i] = 'a'; 493 payload_[i] = 'a';
494 std::cout << "perflistener up" << std::endl; 494 std::cout << "perflistener up" << std::endl;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 #endif // PERFORMANCE_TEST 587 #endif // PERFORMANCE_TEST
588 588
589 int main(int argc, char** argv) { 589 int main(int argc, char** argv) {
590 #ifdef PERFORMANCE_TEST 590 #ifdef PERFORMANCE_TEST
591 int retval = base::PerfTestSuite(argc, argv).Run(); 591 int retval = base::PerfTestSuite(argc, argv).Run();
592 #else 592 #else
593 int retval = base::TestSuite(argc, argv).Run(); 593 int retval = base::TestSuite(argc, argv).Run();
594 #endif 594 #endif
595 return retval; 595 return retval;
596 } 596 }
OLDNEW
« no previous file with comments | « ipc/ipc_test_sink.cc ('k') | ipc/sync_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698