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

Side by Side Diff: mojo/runner/child_process_host.cc

Issue 1419293003: Allow mojo_runner to connect to arbitrary executables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 1 month 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/runner/child_process_host.h ('k') | mojo/runner/in_process_native_runner.h » ('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 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 "mojo/runner/child_process_host.h" 5 #include "mojo/runner/child_process_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 if (!child_process_.IsValid()) { 97 if (!child_process_.IsValid()) {
98 LOG(ERROR) << "Failed to start child process"; 98 LOG(ERROR) << "Failed to start child process";
99 AppCompleted(MOJO_RESULT_UNKNOWN); 99 AppCompleted(MOJO_RESULT_UNKNOWN);
100 } 100 }
101 } 101 }
102 102
103 void ChildProcessHost::DoLaunch() { 103 void ChildProcessHost::DoLaunch() {
104 const base::CommandLine* parent_command_line = 104 const base::CommandLine* parent_command_line =
105 base::CommandLine::ForCurrentProcess(); 105 base::CommandLine::ForCurrentProcess();
106 base::CommandLine child_command_line(parent_command_line->GetProgram()); 106 base::FilePath target_path = parent_command_line->GetProgram();
107 // |app_path_| can be empty in tests.
108 if (!app_path_.MatchesExtension(FILE_PATH_LITERAL(".mojo")) &&
109 !app_path_.empty()) {
110 target_path = app_path_;
111 }
112
113 base::CommandLine child_command_line(target_path);
107 child_command_line.AppendArguments(*parent_command_line, false); 114 child_command_line.AppendArguments(*parent_command_line, false);
108 child_command_line.AppendSwitchPath(switches::kChildProcess, app_path_); 115
116 if (target_path != app_path_)
117 child_command_line.AppendSwitchPath(switches::kChildProcess, app_path_);
109 118
110 if (start_sandboxed_) 119 if (start_sandboxed_)
111 child_command_line.AppendSwitch(switches::kEnableSandbox); 120 child_command_line.AppendSwitch(switches::kEnableSandbox);
112 121
113 embedder::HandlePassingInformation handle_passing_info; 122 embedder::HandlePassingInformation handle_passing_info;
114 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( 123 platform_channel_pair_.PrepareToPassClientHandleToChildProcess(
115 &child_command_line, &handle_passing_info); 124 &child_command_line, &handle_passing_info);
116 125
117 base::LaunchOptions options; 126 base::LaunchOptions options;
118 #if defined(OS_WIN) 127 #if defined(OS_WIN)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { 162 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) {
154 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; 163 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()";
155 164
156 DCHECK(channel_info || 165 DCHECK(channel_info ||
157 base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")); 166 base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk"));
158 channel_info_ = channel_info; 167 channel_info_ = channel_info;
159 } 168 }
160 169
161 } // namespace runner 170 } // namespace runner
162 } // namespace mojo 171 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/child_process_host.h ('k') | mojo/runner/in_process_native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698