| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #if defined(OS_LINUX) && !defined(OS_ANDROID) | 25 #if defined(OS_LINUX) && !defined(OS_ANDROID) |
| 26 #include "sandbox/linux/services/namespace_sandbox.h" | 26 #include "sandbox/linux/services/namespace_sandbox.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace mojo { | 29 namespace mojo { |
| 30 namespace runner { | 30 namespace runner { |
| 31 | 31 |
| 32 ChildProcessHost::ChildProcessHost(Context* context, | 32 ChildProcessHost::ChildProcessHost(Context* context, |
| 33 bool start_sandboxed, | 33 bool start_sandboxed, |
| 34 const base::FilePath& app_path, | 34 const base::FilePath& app_path) |
| 35 bool clean_app_path) | |
| 36 : context_(context), | 35 : context_(context), |
| 37 start_sandboxed_(start_sandboxed), | 36 start_sandboxed_(start_sandboxed), |
| 38 app_path_(app_path), | 37 app_path_(app_path), |
| 39 clean_app_path_(clean_app_path), | |
| 40 channel_info_(nullptr) { | 38 channel_info_(nullptr) { |
| 41 platform_channel_ = platform_channel_pair_.PassServerHandle(); | 39 platform_channel_ = platform_channel_pair_.PassServerHandle(); |
| 42 CHECK(platform_channel_.is_valid()); | 40 CHECK(platform_channel_.is_valid()); |
| 43 } | 41 } |
| 44 | 42 |
| 45 ChildProcessHost::~ChildProcessHost() { | 43 ChildProcessHost::~ChildProcessHost() { |
| 46 if (child_process_.IsValid()) { | 44 if (child_process_.IsValid()) { |
| 47 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child"; | 45 LOG(WARNING) << "Destroying ChildProcessHost with unjoined child"; |
| 48 child_process_.Close(); | 46 child_process_.Close(); |
| 49 } | 47 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 100 } |
| 103 } | 101 } |
| 104 | 102 |
| 105 bool ChildProcessHost::DoLaunch() { | 103 bool ChildProcessHost::DoLaunch() { |
| 106 const base::CommandLine* parent_command_line = | 104 const base::CommandLine* parent_command_line = |
| 107 base::CommandLine::ForCurrentProcess(); | 105 base::CommandLine::ForCurrentProcess(); |
| 108 base::CommandLine child_command_line(parent_command_line->GetProgram()); | 106 base::CommandLine child_command_line(parent_command_line->GetProgram()); |
| 109 child_command_line.AppendArguments(*parent_command_line, false); | 107 child_command_line.AppendArguments(*parent_command_line, false); |
| 110 child_command_line.AppendSwitchPath(switches::kChildProcess, app_path_); | 108 child_command_line.AppendSwitchPath(switches::kChildProcess, app_path_); |
| 111 | 109 |
| 112 if (clean_app_path_) | |
| 113 child_command_line.AppendSwitch(switches::kDeleteAfterLoad); | |
| 114 | |
| 115 if (start_sandboxed_) | 110 if (start_sandboxed_) |
| 116 child_command_line.AppendSwitch(switches::kEnableSandbox); | 111 child_command_line.AppendSwitch(switches::kEnableSandbox); |
| 117 | 112 |
| 118 embedder::HandlePassingInformation handle_passing_info; | 113 embedder::HandlePassingInformation handle_passing_info; |
| 119 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( | 114 platform_channel_pair_.PrepareToPassClientHandleToChildProcess( |
| 120 &child_command_line, &handle_passing_info); | 115 &child_command_line, &handle_passing_info); |
| 121 | 116 |
| 122 base::LaunchOptions options; | 117 base::LaunchOptions options; |
| 123 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
| 124 options.handles_to_inherit = &handle_passing_info; | 119 options.handles_to_inherit = &handle_passing_info; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 155 |
| 161 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { | 156 void ChildProcessHost::DidCreateChannel(embedder::ChannelInfo* channel_info) { |
| 162 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; | 157 DVLOG(2) << "AppChildProcessHost::DidCreateChannel()"; |
| 163 | 158 |
| 164 CHECK(channel_info); | 159 CHECK(channel_info); |
| 165 channel_info_ = channel_info; | 160 channel_info_ = channel_info; |
| 166 } | 161 } |
| 167 | 162 |
| 168 } // namespace runner | 163 } // namespace runner |
| 169 } // namespace mojo | 164 } // namespace mojo |
| OLD | NEW |