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

Side by Side Diff: mojo/common/test/multiprocess_test_base.cc

Issue 137273003: Mojo: Rename PlatformChannelHandle to PlatformHandle, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 11 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 | Annotate | Revision Log
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/common/test/multiprocess_test_base.h" 5 #include "mojo/common/test/multiprocess_test_base.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 // TODO(vtl): Remove build_config.h include when fully implemented on Windows. 11 // TODO(vtl): Remove build_config.h include when fully implemented on Windows.
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "mojo/system/platform_channel.h"
14 #include "mojo/system/platform_channel_pair.h" 13 #include "mojo/system/platform_channel_pair.h"
15 14
16 namespace mojo { 15 namespace mojo {
17 namespace test { 16 namespace test {
18 17
19 MultiprocessTestBase::MultiprocessTestBase() 18 MultiprocessTestBase::MultiprocessTestBase()
20 : test_child_handle_(base::kNullProcessHandle) { 19 : test_child_handle_(base::kNullProcessHandle) {
21 } 20 }
22 21
23 MultiprocessTestBase::~MultiprocessTestBase() { 22 MultiprocessTestBase::~MultiprocessTestBase() {
24 CHECK_EQ(test_child_handle_, base::kNullProcessHandle); 23 CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
25 } 24 }
26 25
27 void MultiprocessTestBase::SetUp() { 26 void MultiprocessTestBase::SetUp() {
28 CHECK_EQ(test_child_handle_, base::kNullProcessHandle); 27 CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
29 28
30 MultiProcessTest::SetUp(); 29 MultiProcessTest::SetUp();
31 30
32 // TODO(vtl): Not implemented on Windows yet. 31 // TODO(vtl): Not implemented on Windows yet.
33 #if defined(OS_POSIX) 32 #if defined(OS_POSIX)
34 platform_channel_pair_.reset(new system::PlatformChannelPair()); 33 platform_channel_pair_.reset(new system::PlatformChannelPair());
35 server_platform_channel = platform_channel_pair_->CreateServerChannel(); 34 server_platform_handle = platform_channel_pair_->PassServerHandle();
36 #endif 35 #endif
37 } 36 }
38 37
39 void MultiprocessTestBase::TearDown() { 38 void MultiprocessTestBase::TearDown() {
40 CHECK_EQ(test_child_handle_, base::kNullProcessHandle); 39 CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
41 40
42 server_platform_channel.reset(); 41 server_platform_handle.reset();
43 platform_channel_pair_.reset(); 42 platform_channel_pair_.reset();
44 43
45 MultiProcessTest::TearDown(); 44 MultiProcessTest::TearDown();
46 } 45 }
47 46
48 void MultiprocessTestBase::StartChild(const std::string& test_child_name) { 47 void MultiprocessTestBase::StartChild(const std::string& test_child_name) {
49 CHECK(platform_channel_pair_.get()); 48 CHECK(platform_channel_pair_.get());
50 CHECK(!test_child_name.empty()); 49 CHECK(!test_child_name.empty());
51 CHECK_EQ(test_child_handle_, base::kNullProcessHandle); 50 CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
52 51
53 std::string test_child_main = test_child_name + "TestChildMain"; 52 std::string test_child_main = test_child_name + "TestChildMain";
54 53
55 #if defined(OS_POSIX) 54 #if defined(OS_POSIX)
56 CommandLine unused(CommandLine::NO_PROGRAM); 55 CommandLine unused(CommandLine::NO_PROGRAM);
57 base::FileHandleMappingVector fds_to_map; 56 base::FileHandleMappingVector fds_to_map;
58 platform_channel_pair_->PrepareToPassClientChannelToChildProcess(&unused, 57 platform_channel_pair_->PrepareToPassClientHandleToChildProcess(&unused,
59 &fds_to_map); 58 &fds_to_map);
60 test_child_handle_ = SpawnChild(test_child_main, fds_to_map, false); 59 test_child_handle_ = SpawnChild(test_child_main, fds_to_map, false);
61 #elif defined(OS_WIN) 60 #elif defined(OS_WIN)
62 test_child_handle_ = SpawnChild(test_child_main, false); 61 test_child_handle_ = SpawnChild(test_child_main, false);
63 #else 62 #else
64 #error "Not supported yet." 63 #error "Not supported yet."
65 #endif 64 #endif
66 // TODO(vtl): Not implemented on Windows yet. 65 // TODO(vtl): Not implemented on Windows yet.
67 #if defined(OS_POSIX) 66 #if defined(OS_POSIX)
68 platform_channel_pair_->ChildProcessLaunched(); 67 platform_channel_pair_->ChildProcessLaunched();
69 #endif 68 #endif
(...skipping 15 matching lines...) Expand all
85 84
86 CommandLine MultiprocessTestBase::MakeCmdLine(const std::string& procname, 85 CommandLine MultiprocessTestBase::MakeCmdLine(const std::string& procname,
87 bool debug_on_start) { 86 bool debug_on_start) {
88 CHECK(platform_channel_pair_.get()); 87 CHECK(platform_channel_pair_.get());
89 88
90 CommandLine command_line = 89 CommandLine command_line =
91 base::MultiProcessTest::MakeCmdLine(procname, debug_on_start); 90 base::MultiProcessTest::MakeCmdLine(procname, debug_on_start);
92 // TODO(vtl): Not implemented on Windows yet. 91 // TODO(vtl): Not implemented on Windows yet.
93 #if defined(OS_POSIX) 92 #if defined(OS_POSIX)
94 base::FileHandleMappingVector unused; 93 base::FileHandleMappingVector unused;
95 platform_channel_pair_->PrepareToPassClientChannelToChildProcess( 94 platform_channel_pair_->PrepareToPassClientHandleToChildProcess(&command_line,
96 &command_line, &unused); 95 &unused);
97 #endif 96 #endif
98 return command_line; 97 return command_line;
99 } 98 }
100 99
101 // static 100 // static
102 void MultiprocessTestBase::ChildSetup() { 101 void MultiprocessTestBase::ChildSetup() {
103 CHECK(CommandLine::InitializedForCurrentProcess()); 102 CHECK(CommandLine::InitializedForCurrentProcess());
104 // TODO(vtl): Not implemented on Windows yet. 103 // TODO(vtl): Not implemented on Windows yet.
105 #if defined(OS_POSIX) 104 #if defined(OS_POSIX)
106 client_platform_channel = 105 client_platform_handle =
107 system::PlatformChannelPair::CreateClientChannelFromParentProcess( 106 system::PlatformChannelPair::PassClientHandleFromParentProcess(
108 *CommandLine::ForCurrentProcess()); 107 *CommandLine::ForCurrentProcess());
109 CHECK(client_platform_channel.get());
110 #endif 108 #endif
111 } 109 }
112 110
113 // static 111 // static
114 scoped_ptr<system::PlatformChannel> 112 system::ScopedPlatformHandle MultiprocessTestBase::client_platform_handle;
115 MultiprocessTestBase::client_platform_channel;
116 113
117 } // namespace test 114 } // namespace test
118 } // namespace mojo 115 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/test/multiprocess_test_base.h ('k') | mojo/common/test/multiprocess_test_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698