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

Side by Side Diff: mojo/edk/test/multiprocess_test_helper.cc

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup Created 5 years, 2 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
OLDNEW
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 "third_party/mojo/src/mojo/edk/test/multiprocess_test_helper.h" 5 #include "mojo/edk/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"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "third_party/mojo/src/mojo/edk/embedder/platform_channel_pair.h" 12 #include "mojo/edk/embedder/platform_channel_pair.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace edk {
15 namespace test { 16 namespace test {
16 17
17 MultiprocessTestHelper::MultiprocessTestHelper() { 18 MultiprocessTestHelper::MultiprocessTestHelper() {
18 platform_channel_pair_.reset(new embedder::PlatformChannelPair()); 19 platform_channel_pair_.reset(new PlatformChannelPair());
19 server_platform_handle = platform_channel_pair_->PassServerHandle(); 20 server_platform_handle = platform_channel_pair_->PassServerHandle();
20 } 21 }
21 22
22 MultiprocessTestHelper::~MultiprocessTestHelper() { 23 MultiprocessTestHelper::~MultiprocessTestHelper() {
23 CHECK(!test_child_.IsValid()); 24 CHECK(!test_child_.IsValid());
24 server_platform_handle.reset(); 25 server_platform_handle.reset();
25 platform_channel_pair_.reset(); 26 platform_channel_pair_.reset();
26 } 27 }
27 28
28 void MultiprocessTestHelper::StartChild(const std::string& test_child_name) { 29 void MultiprocessTestHelper::StartChild(const std::string& test_child_name) {
29 StartChildWithExtraSwitch(test_child_name, std::string(), std::string()); 30 StartChildWithExtraSwitch(test_child_name, std::string(), std::string());
30 } 31 }
31 32
32 void MultiprocessTestHelper::StartChildWithExtraSwitch( 33 void MultiprocessTestHelper::StartChildWithExtraSwitch(
33 const std::string& test_child_name, 34 const std::string& test_child_name,
34 const std::string& switch_string, 35 const std::string& switch_string,
35 const std::string& switch_value) { 36 const std::string& switch_value) {
36 CHECK(platform_channel_pair_); 37 CHECK(platform_channel_pair_);
37 CHECK(!test_child_name.empty()); 38 CHECK(!test_child_name.empty());
38 CHECK(!test_child_.IsValid()); 39 CHECK(!test_child_.IsValid());
39 40
40 std::string test_child_main = test_child_name + "TestChildMain"; 41 std::string test_child_main = test_child_name + "TestChildMain";
41 42
42 base::CommandLine command_line( 43 base::CommandLine command_line(
43 base::GetMultiProcessTestChildBaseCommandLine()); 44 base::GetMultiProcessTestChildBaseCommandLine());
44 embedder::HandlePassingInformation handle_passing_info; 45 HandlePassingInformation handle_passing_info;
45 platform_channel_pair_->PrepareToPassClientHandleToChildProcess( 46 platform_channel_pair_->PrepareToPassClientHandleToChildProcess(
46 &command_line, &handle_passing_info); 47 &command_line, &handle_passing_info);
47 48
48 if (!switch_string.empty()) { 49 if (!switch_string.empty()) {
49 CHECK(!command_line.HasSwitch(switch_string)); 50 CHECK(!command_line.HasSwitch(switch_string));
50 if (!switch_value.empty()) 51 if (!switch_value.empty())
51 command_line.AppendSwitchASCII(switch_string, switch_value); 52 command_line.AppendSwitchASCII(switch_string, switch_value);
52 else 53 else
53 command_line.AppendSwitch(switch_string); 54 command_line.AppendSwitch(switch_string);
54 } 55 }
(...skipping 26 matching lines...) Expand all
81 } 82 }
82 83
83 bool MultiprocessTestHelper::WaitForChildTestShutdown() { 84 bool MultiprocessTestHelper::WaitForChildTestShutdown() {
84 return WaitForChildShutdown() == 0; 85 return WaitForChildShutdown() == 0;
85 } 86 }
86 87
87 // static 88 // static
88 void MultiprocessTestHelper::ChildSetup() { 89 void MultiprocessTestHelper::ChildSetup() {
89 CHECK(base::CommandLine::InitializedForCurrentProcess()); 90 CHECK(base::CommandLine::InitializedForCurrentProcess());
90 client_platform_handle = 91 client_platform_handle =
91 embedder::PlatformChannelPair::PassClientHandleFromParentProcess( 92 PlatformChannelPair::PassClientHandleFromParentProcess(
92 *base::CommandLine::ForCurrentProcess()); 93 *base::CommandLine::ForCurrentProcess());
93 } 94 }
94 95
95 // static 96 // static
96 embedder::ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle; 97 ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle;
97 98
98 } // namespace test 99 } // namespace test
100 } // namespace edk
99 } // namespace mojo 101 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698