| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |