| 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/shell/runner/host/child_process_host.h" | 5 #include "mojo/shell/runner/host/child_process_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 ChildProcessHost::~ChildProcessHost() { | 53 ChildProcessHost::~ChildProcessHost() { |
| 54 if (!app_path_.empty()) { | 54 if (!app_path_.empty()) { |
| 55 CHECK(!mojo_ipc_channel_) | 55 CHECK(!mojo_ipc_channel_) |
| 56 << "Destroying ChildProcessHost before calling Join"; | 56 << "Destroying ChildProcessHost before calling Join"; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 mojom::ShellClientPtr ChildProcessHost::Start( | 60 mojom::ShellClientPtr ChildProcessHost::Start( |
| 61 const String& name, | 61 const Identity& target, |
| 62 const ProcessReadyCallback& callback, | 62 const ProcessReadyCallback& callback, |
| 63 const base::Closure& quit_closure) { | 63 const base::Closure& quit_closure) { |
| 64 DCHECK(!child_process_.IsValid()); | 64 DCHECK(!child_process_.IsValid()); |
| 65 | 65 |
| 66 const base::CommandLine* parent_command_line = | 66 const base::CommandLine* parent_command_line = |
| 67 base::CommandLine::ForCurrentProcess(); | 67 base::CommandLine::ForCurrentProcess(); |
| 68 base::FilePath target_path = parent_command_line->GetProgram(); | 68 base::FilePath target_path = parent_command_line->GetProgram(); |
| 69 // |app_path_| can be empty in tests. | 69 // |app_path_| can be empty in tests. |
| 70 if (!app_path_.MatchesExtension(FILE_PATH_LITERAL(".mojo")) && | 70 if (!app_path_.MatchesExtension(FILE_PATH_LITERAL(".mojo")) && |
| 71 !app_path_.empty()) { | 71 !app_path_.empty()) { |
| 72 target_path = app_path_; | 72 target_path = app_path_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 scoped_ptr<base::CommandLine> child_command_line( | 75 scoped_ptr<base::CommandLine> child_command_line( |
| 76 new base::CommandLine(target_path)); | 76 new base::CommandLine(target_path)); |
| 77 | 77 |
| 78 child_command_line->AppendArguments(*parent_command_line, false); | 78 child_command_line->AppendArguments(*parent_command_line, false); |
| 79 | 79 |
| 80 #ifndef NDEBUG |
| 81 child_command_line->AppendSwitchASCII("n", target.name()); |
| 82 child_command_line->AppendSwitchASCII("u", target.user_id()); |
| 83 #endif |
| 84 |
| 80 if (target_path != app_path_) | 85 if (target_path != app_path_) |
| 81 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); | 86 child_command_line->AppendSwitchPath(switches::kChildProcess, app_path_); |
| 82 | 87 |
| 83 if (start_sandboxed_) | 88 if (start_sandboxed_) |
| 84 child_command_line->AppendSwitch(switches::kEnableSandbox); | 89 child_command_line->AppendSwitch(switches::kEnableSandbox); |
| 85 | 90 |
| 86 mojo_ipc_channel_.reset(new edk::PlatformChannelPair); | 91 mojo_ipc_channel_.reset(new edk::PlatformChannelPair); |
| 87 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( | 92 mojo_ipc_channel_->PrepareToPassClientHandleToChildProcess( |
| 88 child_command_line.get(), &handle_passing_info_); | 93 child_command_line.get(), &handle_passing_info_); |
| 89 | 94 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 child_process_.Handle(), | 188 child_process_.Handle(), |
| 184 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( | 189 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( |
| 185 mojo_ipc_channel_->PassServerHandle().release().handle))); | 190 mojo_ipc_channel_->PassServerHandle().release().handle))); |
| 186 } | 191 } |
| 187 } | 192 } |
| 188 start_child_process_event_.Signal(); | 193 start_child_process_event_.Signal(); |
| 189 } | 194 } |
| 190 | 195 |
| 191 } // namespace shell | 196 } // namespace shell |
| 192 } // namespace mojo | 197 } // namespace mojo |
| OLD | NEW |