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

Side by Side Diff: shell/child_process_host.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.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "shell/child_process_host.h" 5 #include "shell/child_process_host.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 21 matching lines...) Expand all
32 using mojo::util::MakeRefCounted; 32 using mojo::util::MakeRefCounted;
33 33
34 namespace shell { 34 namespace shell {
35 35
36 struct ChildProcessHost::LaunchData { 36 struct ChildProcessHost::LaunchData {
37 LaunchData() {} 37 LaunchData() {}
38 ~LaunchData() {} 38 ~LaunchData() {}
39 39
40 NativeApplicationOptions options; 40 NativeApplicationOptions options;
41 base::FilePath child_path; 41 base::FilePath child_path;
42 PlatformPipe platform_channel_pair; 42 PlatformPipe platform_pipe;
43 std::string child_connection_id; 43 std::string child_connection_id;
44 }; 44 };
45 45
46 ChildProcessHost::ChildProcessHost(Context* context) 46 ChildProcessHost::ChildProcessHost(Context* context)
47 : context_(context), channel_info_(nullptr) { 47 : context_(context), channel_info_(nullptr) {
48 } 48 }
49 49
50 ChildProcessHost::~ChildProcessHost() { 50 ChildProcessHost::~ChildProcessHost() {
51 DCHECK(!child_process_.IsValid()); 51 DCHECK(!child_process_.IsValid());
52 } 52 }
53 53
54 void ChildProcessHost::Start(const NativeApplicationOptions& options) { 54 void ChildProcessHost::Start(const NativeApplicationOptions& options) {
55 DCHECK(!child_process_.IsValid()); 55 DCHECK(!child_process_.IsValid());
56 56
57 scoped_ptr<LaunchData> launch_data(new LaunchData()); 57 scoped_ptr<LaunchData> launch_data(new LaunchData());
58 launch_data->options = options; 58 launch_data->options = options;
59 launch_data->child_path = context_->mojo_shell_child_path(); 59 launch_data->child_path = context_->mojo_shell_child_path();
60 #if defined(ARCH_CPU_64_BITS) 60 #if defined(ARCH_CPU_64_BITS)
61 if (options.require_32_bit) { 61 if (options.require_32_bit) {
62 launch_data->child_path = 62 launch_data->child_path =
63 context_->mojo_shell_child_path().InsertBeforeExtensionASCII("_32"); 63 context_->mojo_shell_child_path().InsertBeforeExtensionASCII("_32");
64 } 64 }
65 #endif 65 #endif
66 // TODO(vtl): Add something for |slave_info|. 66 // TODO(vtl): Add something for |slave_info|.
67 // TODO(vtl): The "unretained this" is wrong (see also below). 67 // TODO(vtl): The "unretained this" is wrong (see also below).
68 // TODO(vtl): We shouldn't have to make a new 68 // TODO(vtl): We shouldn't have to make a new
69 // |base_edk::PlatformTaskRunnerImpl| for each instance. Instead, there should 69 // |base_edk::PlatformTaskRunnerImpl| for each instance. Instead, there should
70 // be one per thread. 70 // be one per thread.
71 mojo::ScopedMessagePipeHandle handle(mojo::embedder::ConnectToSlave( 71 mojo::ScopedMessagePipeHandle handle(mojo::embedder::ConnectToSlave(
72 nullptr, launch_data->platform_channel_pair.handle0.Pass(), 72 nullptr, launch_data->platform_pipe.handle0.Pass(),
73 [this]() { DidConnectToSlave(); }, 73 [this]() { DidConnectToSlave(); },
74 MakeRefCounted<base_edk::PlatformTaskRunnerImpl>( 74 MakeRefCounted<base_edk::PlatformTaskRunnerImpl>(
75 base::ThreadTaskRunnerHandle::Get()), 75 base::ThreadTaskRunnerHandle::Get()),
76 &launch_data->child_connection_id, &channel_info_)); 76 &launch_data->child_connection_id, &channel_info_));
77 // TODO(vtl): We should destroy the channel on destruction (using 77 // TODO(vtl): We should destroy the channel on destruction (using
78 // |channel_info_|, but only after the callback has been called. 78 // |channel_info_|, but only after the callback has been called.
79 CHECK(channel_info_); 79 CHECK(channel_info_);
80 80
81 controller_.Bind(mojo::InterfacePtrInfo<ChildController>(handle.Pass(), 0u)); 81 controller_.Bind(mojo::InterfacePtrInfo<ChildController>(handle.Pass(), 0u));
82 controller_.set_connection_error_handler([this]() { OnConnectionError(); }); 82 controller_.set_connection_error_handler([this]() { OnConnectionError(); });
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 base::CommandLine child_command_line(launch_data->child_path); 141 base::CommandLine child_command_line(launch_data->child_path);
142 child_command_line.CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), 142 child_command_line.CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
143 kForwardSwitches, 143 kForwardSwitches,
144 arraysize(kForwardSwitches)); 144 arraysize(kForwardSwitches));
145 child_command_line.AppendSwitchASCII(switches::kChildConnectionId, 145 child_command_line.AppendSwitchASCII(switches::kChildConnectionId,
146 launch_data->child_connection_id); 146 launch_data->child_connection_id);
147 147
148 base::FileHandleMappingVector fds_to_remap; 148 base::FileHandleMappingVector fds_to_remap;
149 fds_to_remap.push_back( 149 fds_to_remap.push_back(
150 std::pair<int, int>(launch_data->platform_channel_pair.handle1.get().fd, 150 std::pair<int, int>(launch_data->platform_pipe.handle1.get().fd,
151 base::GlobalDescriptors::kBaseDescriptor)); 151 base::GlobalDescriptors::kBaseDescriptor));
152 base::LaunchOptions options; 152 base::LaunchOptions options;
153 options.fds_to_remap = &fds_to_remap; 153 options.fds_to_remap = &fds_to_remap;
154 #if defined(OS_LINUX) 154 #if defined(OS_LINUX)
155 options.allow_new_privs = launch_data->options.allow_new_privs; 155 options.allow_new_privs = launch_data->options.allow_new_privs;
156 #endif 156 #endif
157 DVLOG(2) << "Launching child with command line: " 157 DVLOG(2) << "Launching child with command line: "
158 << child_command_line.GetCommandLineString(); 158 << child_command_line.GetCommandLineString();
159 base::Process child_process = 159 base::Process child_process =
160 base::LaunchProcess(child_command_line, options); 160 base::LaunchProcess(child_command_line, options);
161 if (child_process.IsValid()) 161 if (child_process.IsValid())
162 launch_data->platform_channel_pair.handle1.reset(); 162 launch_data->platform_pipe.handle1.reset();
163 return child_process.Pass(); 163 return child_process.Pass();
164 } 164 }
165 165
166 void ChildProcessHost::AppCompleted(int32_t result) { 166 void ChildProcessHost::AppCompleted(int32_t result) {
167 if (!on_app_complete_.is_null()) { 167 if (!on_app_complete_.is_null()) {
168 auto on_app_complete = on_app_complete_; 168 auto on_app_complete = on_app_complete_;
169 on_app_complete_.reset(); 169 on_app_complete_.reset();
170 on_app_complete.Run(result); 170 on_app_complete.Run(result);
171 } 171 }
172 } 172 }
173 173
174 void ChildProcessHost::OnConnectionError() { 174 void ChildProcessHost::OnConnectionError() {
175 AppCompleted(MOJO_RESULT_UNKNOWN); 175 AppCompleted(MOJO_RESULT_UNKNOWN);
176 } 176 }
177 177
178 } // namespace shell 178 } // namespace shell
OLDNEW
« no previous file with comments | « mojo/edk/test/multiprocess_test_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698