| OLD | NEW |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return NULL; | 77 return NULL; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 #elif defined(OS_POSIX) | 80 #elif defined(OS_POSIX) |
| 81 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type, | 81 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type, |
| 82 IPC::Channel *channel) { | 82 IPC::Channel *channel) { |
| 83 // kDebugChildren support. | 83 // kDebugChildren support. |
| 84 bool debug_on_start = | 84 bool debug_on_start = |
| 85 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); | 85 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); |
| 86 | 86 |
| 87 base::file_handle_mapping_vector fds_to_map; | 87 base::FileHandleMappingVector fds_to_map; |
| 88 const int ipcfd = channel->GetClientFileDescriptor(); | 88 const int ipcfd = channel->GetClientFileDescriptor(); |
| 89 if (ipcfd > -1) { | 89 if (ipcfd > -1) { |
| 90 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); | 90 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 base::ProcessHandle ret = base::kNullProcessHandle; | 93 base::ProcessHandle ret = base::kNullProcessHandle; |
| 94 switch (child_type) { | 94 switch (child_type) { |
| 95 case TEST_CLIENT: | 95 case TEST_CLIENT: |
| 96 ret = MultiProcessTest::SpawnChild("RunTestClient", | 96 ret = MultiProcessTest::SpawnChild("RunTestClient", |
| 97 fds_to_map, | 97 fds_to_map, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 IPC::ChannelProxy chan(kTestClientChannel, IPC::Channel::MODE_SERVER, | 294 IPC::ChannelProxy chan(kTestClientChannel, IPC::Channel::MODE_SERVER, |
| 295 &channel_listener, thread.message_loop_proxy()); | 295 &channel_listener, thread.message_loop_proxy()); |
| 296 | 296 |
| 297 channel_listener.Init(&chan); | 297 channel_listener.Init(&chan); |
| 298 | 298 |
| 299 #if defined(OS_WIN) | 299 #if defined(OS_WIN) |
| 300 base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL); | 300 base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL); |
| 301 #elif defined(OS_POSIX) | 301 #elif defined(OS_POSIX) |
| 302 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( | 302 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( |
| 303 switches::kDebugChildren); | 303 switches::kDebugChildren); |
| 304 base::file_handle_mapping_vector fds_to_map; | 304 base::FileHandleMappingVector fds_to_map; |
| 305 const int ipcfd = chan.GetClientFileDescriptor(); | 305 const int ipcfd = chan.GetClientFileDescriptor(); |
| 306 if (ipcfd > -1) { | 306 if (ipcfd > -1) { |
| 307 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); | 307 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 base::ProcessHandle process_handle = MultiProcessTest::SpawnChild( | 310 base::ProcessHandle process_handle = MultiProcessTest::SpawnChild( |
| 311 "RunTestClient", | 311 "RunTestClient", |
| 312 fds_to_map, | 312 fds_to_map, |
| 313 debug_on_start); | 313 debug_on_start); |
| 314 #endif // defined(OS_POSIX) | 314 #endif // defined(OS_POSIX) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 459 |
| 460 IPC::Message* msg = new IPC::Message(0, | 460 IPC::Message* msg = new IPC::Message(0, |
| 461 2, | 461 2, |
| 462 IPC::Message::PRIORITY_NORMAL); | 462 IPC::Message::PRIORITY_NORMAL); |
| 463 msg->WriteInt(GetTickCount()); | 463 msg->WriteInt(GetTickCount()); |
| 464 msg->WriteInt(msgid); | 464 msg->WriteInt(msgid); |
| 465 msg->WriteString(payload); | 465 msg->WriteString(payload); |
| 466 channel_->Send(msg); | 466 channel_->Send(msg); |
| 467 return true; | 467 return true; |
| 468 } | 468 } |
| 469 |
| 469 private: | 470 private: |
| 470 IPC::Channel *channel_; | 471 IPC::Channel *channel_; |
| 471 int count_messages_; | 472 int count_messages_; |
| 472 int latency_messages_; | 473 int latency_messages_; |
| 473 }; | 474 }; |
| 474 | 475 |
| 475 class ChannelPerfListener : public IPC::Channel::Listener { | 476 class ChannelPerfListener : public IPC::Channel::Listener { |
| 476 public: | 477 public: |
| 477 ChannelPerfListener(IPC::Channel* channel, int msg_count, int msg_size) : | 478 ChannelPerfListener(IPC::Channel* channel, int msg_count, int msg_size) : |
| 478 count_down_(msg_count), | 479 count_down_(msg_count), |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 #endif // PERFORMANCE_TEST | 579 #endif // PERFORMANCE_TEST |
| 579 | 580 |
| 580 int main(int argc, char** argv) { | 581 int main(int argc, char** argv) { |
| 581 #ifdef PERFORMANCE_TEST | 582 #ifdef PERFORMANCE_TEST |
| 582 int retval = base::PerfTestSuite(argc, argv).Run(); | 583 int retval = base::PerfTestSuite(argc, argv).Run(); |
| 583 #else | 584 #else |
| 584 int retval = base::TestSuite(argc, argv).Run(); | 585 int retval = base::TestSuite(argc, argv).Run(); |
| 585 #endif | 586 #endif |
| 586 return retval; | 587 return retval; |
| 587 } | 588 } |
| OLD | NEW |