| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/common/test/multiprocess_test_helper.h" | 5 #include "mojo/common/test/multiprocess_test_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 base::LaunchOptions options; | 41 base::LaunchOptions options; |
| 42 #if defined(OS_POSIX) | 42 #if defined(OS_POSIX) |
| 43 options.fds_to_remap = &handle_passing_info; | 43 options.fds_to_remap = &handle_passing_info; |
| 44 #elif defined(OS_WIN) | 44 #elif defined(OS_WIN) |
| 45 options.start_hidden = true; | 45 options.start_hidden = true; |
| 46 options.handles_to_inherit = &handle_passing_info; | 46 options.handles_to_inherit = &handle_passing_info; |
| 47 #else | 47 #else |
| 48 #error "Not supported yet." | 48 #error "Not supported yet." |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 test_child_handle_ = base::SpawnMultiProcessTestChild( | 51 test_child_handle_ = |
| 52 test_child_main, command_line, options, false); | 52 base::SpawnMultiProcessTestChild(test_child_main, command_line, options); |
| 53 platform_channel_pair_->ChildProcessLaunched(); | 53 platform_channel_pair_->ChildProcessLaunched(); |
| 54 | 54 |
| 55 CHECK_NE(test_child_handle_, base::kNullProcessHandle); | 55 CHECK_NE(test_child_handle_, base::kNullProcessHandle); |
| 56 } | 56 } |
| 57 | 57 |
| 58 int MultiprocessTestHelper::WaitForChildShutdown() { | 58 int MultiprocessTestHelper::WaitForChildShutdown() { |
| 59 CHECK_NE(test_child_handle_, base::kNullProcessHandle); | 59 CHECK_NE(test_child_handle_, base::kNullProcessHandle); |
| 60 | 60 |
| 61 int rv = -1; | 61 int rv = -1; |
| 62 CHECK(base::WaitForExitCodeWithTimeout( | 62 CHECK(base::WaitForExitCodeWithTimeout( |
| 63 test_child_handle_, &rv, TestTimeouts::action_timeout())); | 63 test_child_handle_, &rv, TestTimeouts::action_timeout())); |
| 64 base::CloseProcessHandle(test_child_handle_); | 64 base::CloseProcessHandle(test_child_handle_); |
| 65 test_child_handle_ = base::kNullProcessHandle; | 65 test_child_handle_ = base::kNullProcessHandle; |
| 66 return rv; | 66 return rv; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // static | 69 // static |
| 70 void MultiprocessTestHelper::ChildSetup() { | 70 void MultiprocessTestHelper::ChildSetup() { |
| 71 CHECK(CommandLine::InitializedForCurrentProcess()); | 71 CHECK(CommandLine::InitializedForCurrentProcess()); |
| 72 client_platform_handle = | 72 client_platform_handle = |
| 73 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( | 73 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
| 74 *CommandLine::ForCurrentProcess()); | 74 *CommandLine::ForCurrentProcess()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // static | 77 // static |
| 78 embedder::ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle; | 78 embedder::ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle; |
| 79 | 79 |
| 80 } // namespace test | 80 } // namespace test |
| 81 } // namespace mojo | 81 } // namespace mojo |
| OLD | NEW |