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

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

Issue 1665573002: Rename some variables platform_channel_pair -> platform_pipe. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « mojo/edk/test/multiprocess_test_helper.h ('k') | shell/child_process_host.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 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/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/posix/global_descriptors.h" 9 #include "base/posix/global_descriptors.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
11 #include "mojo/edk/platform/platform_handle.h" 11 #include "mojo/edk/platform/platform_handle.h"
12 #include "mojo/edk/platform/platform_pipe.h" 12 #include "mojo/edk/platform/platform_pipe.h"
13 #include "mojo/edk/platform/scoped_platform_handle.h" 13 #include "mojo/edk/platform/scoped_platform_handle.h"
14 14
15 using mojo::platform::PlatformHandle; 15 using mojo::platform::PlatformHandle;
16 using mojo::platform::PlatformPipe; 16 using mojo::platform::PlatformPipe;
17 using mojo::platform::ScopedPlatformHandle; 17 using mojo::platform::ScopedPlatformHandle;
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace test { 20 namespace test {
21 21
22 MultiprocessTestHelper::MultiprocessTestHelper() 22 MultiprocessTestHelper::MultiprocessTestHelper()
23 : platform_channel_pair_(new PlatformPipe()) { 23 : platform_pipe_(new PlatformPipe()) {
24 server_platform_handle = platform_channel_pair_->handle0.Pass(); 24 server_platform_handle = platform_pipe_->handle0.Pass();
25 } 25 }
26 26
27 MultiprocessTestHelper::~MultiprocessTestHelper() { 27 MultiprocessTestHelper::~MultiprocessTestHelper() {
28 CHECK(!test_child_.IsValid()); 28 CHECK(!test_child_.IsValid());
29 server_platform_handle.reset(); 29 server_platform_handle.reset();
30 platform_channel_pair_.reset(); 30 platform_pipe_.reset();
31 } 31 }
32 32
33 void MultiprocessTestHelper::StartChild(const std::string& test_child_name) { 33 void MultiprocessTestHelper::StartChild(const std::string& test_child_name) {
34 StartChildWithExtraSwitch(test_child_name, std::string(), std::string()); 34 StartChildWithExtraSwitch(test_child_name, std::string(), std::string());
35 } 35 }
36 36
37 void MultiprocessTestHelper::StartChildWithExtraSwitch( 37 void MultiprocessTestHelper::StartChildWithExtraSwitch(
38 const std::string& test_child_name, 38 const std::string& test_child_name,
39 const std::string& switch_string, 39 const std::string& switch_string,
40 const std::string& switch_value) { 40 const std::string& switch_value) {
41 CHECK(platform_channel_pair_); 41 CHECK(platform_pipe_);
42 CHECK(!test_child_name.empty()); 42 CHECK(!test_child_name.empty());
43 CHECK(!test_child_.IsValid()); 43 CHECK(!test_child_.IsValid());
44 44
45 std::string test_child_main = test_child_name + "TestChildMain"; 45 std::string test_child_main = test_child_name + "TestChildMain";
46 46
47 base::CommandLine command_line( 47 base::CommandLine command_line(
48 base::GetMultiProcessTestChildBaseCommandLine()); 48 base::GetMultiProcessTestChildBaseCommandLine());
49 if (!switch_string.empty()) { 49 if (!switch_string.empty()) {
50 CHECK(!command_line.HasSwitch(switch_string)); 50 CHECK(!command_line.HasSwitch(switch_string));
51 if (!switch_value.empty()) 51 if (!switch_value.empty())
52 command_line.AppendSwitchASCII(switch_string, switch_value); 52 command_line.AppendSwitchASCII(switch_string, switch_value);
53 else 53 else
54 command_line.AppendSwitch(switch_string); 54 command_line.AppendSwitch(switch_string);
55 } 55 }
56 56
57 base::FileHandleMappingVector fds_to_remap; 57 base::FileHandleMappingVector fds_to_remap;
58 fds_to_remap.push_back( 58 fds_to_remap.push_back(
59 std::pair<int, int>(platform_channel_pair_->handle1.get().fd, 59 std::pair<int, int>(platform_pipe_->handle1.get().fd,
60 base::GlobalDescriptors::kBaseDescriptor)); 60 base::GlobalDescriptors::kBaseDescriptor));
61 base::LaunchOptions options; 61 base::LaunchOptions options;
62 options.fds_to_remap = &fds_to_remap; 62 options.fds_to_remap = &fds_to_remap;
63 63
64 test_child_ = 64 test_child_ =
65 base::SpawnMultiProcessTestChild(test_child_main, command_line, options); 65 base::SpawnMultiProcessTestChild(test_child_main, command_line, options);
66 platform_channel_pair_->handle1.reset(); 66 platform_pipe_->handle1.reset();
67 67
68 CHECK(test_child_.IsValid()); 68 CHECK(test_child_.IsValid());
69 } 69 }
70 70
71 int MultiprocessTestHelper::WaitForChildShutdown() { 71 int MultiprocessTestHelper::WaitForChildShutdown() {
72 CHECK(test_child_.IsValid()); 72 CHECK(test_child_.IsValid());
73 73
74 int rv = -1; 74 int rv = -1;
75 CHECK( 75 CHECK(
76 test_child_.WaitForExitWithTimeout(TestTimeouts::action_timeout(), &rv)); 76 test_child_.WaitForExitWithTimeout(TestTimeouts::action_timeout(), &rv));
(...skipping 10 matching lines...) Expand all
87 CHECK(base::CommandLine::InitializedForCurrentProcess()); 87 CHECK(base::CommandLine::InitializedForCurrentProcess());
88 client_platform_handle = ScopedPlatformHandle( 88 client_platform_handle = ScopedPlatformHandle(
89 PlatformHandle(base::GlobalDescriptors::kBaseDescriptor)); 89 PlatformHandle(base::GlobalDescriptors::kBaseDescriptor));
90 } 90 }
91 91
92 // static 92 // static
93 ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle; 93 ScopedPlatformHandle MultiprocessTestHelper::client_platform_handle;
94 94
95 } // namespace test 95 } // namespace test
96 } // namespace mojo 96 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/test/multiprocess_test_helper.h ('k') | shell/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698