| 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 15 matching lines...) Expand all Loading... |
| 26 platform_channel_pair_.reset(); | 26 platform_channel_pair_.reset(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void MultiprocessTestHelper::StartChild(const std::string& test_child_name) { | 29 void MultiprocessTestHelper::StartChild(const std::string& test_child_name) { |
| 30 CHECK(platform_channel_pair_.get()); | 30 CHECK(platform_channel_pair_.get()); |
| 31 CHECK(!test_child_name.empty()); | 31 CHECK(!test_child_name.empty()); |
| 32 CHECK_EQ(test_child_handle_, base::kNullProcessHandle); | 32 CHECK_EQ(test_child_handle_, base::kNullProcessHandle); |
| 33 | 33 |
| 34 std::string test_child_main = test_child_name + "TestChildMain"; | 34 std::string test_child_main = test_child_name + "TestChildMain"; |
| 35 | 35 |
| 36 CommandLine command_line(base::GetMultiProcessTestChildBaseCommandLine()); | 36 base::CommandLine command_line( |
| 37 base::GetMultiProcessTestChildBaseCommandLine()); |
| 37 embedder::HandlePassingInformation handle_passing_info; | 38 embedder::HandlePassingInformation handle_passing_info; |
| 38 platform_channel_pair_->PrepareToPassClientHandleToChildProcess( | 39 platform_channel_pair_->PrepareToPassClientHandleToChildProcess( |
| 39 &command_line, &handle_passing_info); | 40 &command_line, &handle_passing_info); |
| 40 | 41 |
| 41 base::LaunchOptions options; | 42 base::LaunchOptions options; |
| 42 #if defined(OS_POSIX) | 43 #if defined(OS_POSIX) |
| 43 options.fds_to_remap = &handle_passing_info; | 44 options.fds_to_remap = &handle_passing_info; |
| 44 #elif defined(OS_WIN) | 45 #elif defined(OS_WIN) |
| 45 options.start_hidden = true; | 46 options.start_hidden = true; |
| 46 options.handles_to_inherit = &handle_passing_info; | 47 options.handles_to_inherit = &handle_passing_info; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 test_child_handle_ = base::kNullProcessHandle; | 66 test_child_handle_ = base::kNullProcessHandle; |
| 66 return rv; | 67 return rv; |
| 67 } | 68 } |
| 68 | 69 |
| 69 bool MultiprocessTestHelper::WaitForChildTestShutdown() { | 70 bool MultiprocessTestHelper::WaitForChildTestShutdown() { |
| 70 return WaitForChildShutdown() == 0; | 71 return WaitForChildShutdown() == 0; |
| 71 } | 72 } |
| 72 | 73 |
| 73 // static | 74 // static |
| 74 void MultiprocessTestHelper::ChildSetup() { | 75 void MultiprocessTestHelper::ChildSetup() { |
| 75 CHECK(CommandLine::InitializedForCurrentProcess()); | 76 CHECK(base::CommandLine::InitializedForCurrentProcess()); |
| 76 client_platform_handle = | 77 client_platform_handle = |
| 77 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( | 78 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
| 78 *CommandLine::ForCurrentProcess()); | 79 *base::CommandLine::ForCurrentProcess()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 // static | 82 // static |
| 82 embedder::ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle; | 83 embedder::ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle; |
| 83 | 84 |
| 84 } // namespace test | 85 } // namespace test |
| 85 } // namespace mojo | 86 } // namespace mojo |
| OLD | NEW |