Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/child_process_launcher.h" | 5 #include "content/browser/child_process_launcher.h" |
| 6 | 6 |
| 7 #include <utility> // For std::pair. | 7 #include <utility> // For std::pair. |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 #endif | 159 #endif |
| 160 CommandLine* cmd_line) { | 160 CommandLine* cmd_line) { |
| 161 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); | 161 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); |
| 162 | 162 |
| 163 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
| 164 base::ProcessHandle handle = sandbox::StartProcessWithAccess( | 164 base::ProcessHandle handle = sandbox::StartProcessWithAccess( |
| 165 cmd_line, exposed_dir); | 165 cmd_line, exposed_dir); |
| 166 #elif defined(OS_ANDROID) | 166 #elif defined(OS_ANDROID) |
| 167 std::string process_type = | 167 std::string process_type = |
| 168 cmd_line->GetSwitchValueASCII(switches::kProcessType); | 168 cmd_line->GetSwitchValueASCII(switches::kProcessType); |
| 169 base::GlobalDescriptors::Mapping files_to_register; | 169 std::vector<content::FileDescriptorInfo> files_to_register; |
| 170 files_to_register.push_back(std::pair<base::GlobalDescriptors::Key, int>( | 170 files_to_register.push_back( |
| 171 kPrimaryIPCChannel, ipcfd)); | 171 content::FileDescriptorInfo(kPrimaryIPCChannel, |
| 172 base::FileDescriptor(ipcfd, false))); | |
| 173 | |
| 172 content::GetContentClient()->browser()-> | 174 content::GetContentClient()->browser()-> |
| 173 GetAdditionalMappedFilesForChildProcess(*cmd_line, &files_to_register); | 175 GetAdditionalMappedFilesForChildProcess(*cmd_line, &files_to_register); |
| 174 | 176 |
| 175 content::StartSandboxedProcess(cmd_line->argv(), | 177 content::StartSandboxedProcess(cmd_line->argv(), files_to_register, |
| 176 ipcfd, files_to_register, | |
| 177 base::Bind(&ChildProcessLauncher::Context::OnSandboxedProcessStarted, | 178 base::Bind(&ChildProcessLauncher::Context::OnSandboxedProcessStarted, |
| 178 this_object, client_thread_id)); | 179 this_object, client_thread_id)); |
| 179 | 180 |
| 180 #elif defined(OS_POSIX) | 181 #elif defined(OS_POSIX) |
| 181 base::ProcessHandle handle = base::kNullProcessHandle; | 182 base::ProcessHandle handle = base::kNullProcessHandle; |
| 182 // We need to close the client end of the IPC channel | 183 // We need to close the client end of the IPC channel |
| 183 // to reliably detect child termination. | 184 // to reliably detect child termination. |
| 184 file_util::ScopedFD ipcfd_closer(&ipcfd); | 185 file_util::ScopedFD ipcfd_closer(&ipcfd); |
| 185 | 186 |
| 186 std::string process_type = | 187 std::string process_type = |
| 187 cmd_line->GetSwitchValueASCII(switches::kProcessType); | 188 cmd_line->GetSwitchValueASCII(switches::kProcessType); |
| 188 base::GlobalDescriptors::Mapping files_to_register; | 189 base::GlobalDescriptors::Mapping files_to_register; |
| 189 files_to_register.push_back(std::pair<base::GlobalDescriptors::Key, int>( | 190 files_to_register.push_back(std::pair<base::GlobalDescriptors::Key, int>( |
| 190 kPrimaryIPCChannel, ipcfd)); | 191 kPrimaryIPCChannel, ipcfd)); |
| 191 #if !defined(OS_MACOSX) | 192 #if !defined(OS_MACOSX) |
| 192 content::GetContentClient()->browser()-> | 193 content::GetContentClient()->browser()-> |
| 193 GetAdditionalMappedFilesForChildProcess(*cmd_line, &files_to_register); | 194 GetAdditionalMappedFilesForChildProcess(*cmd_line, &files_to_register); |
|
piman
2012/09/21 02:31:02
Shouldn't this call site here change too?
Jay Civelli
2012/09/21 22:12:06
Sorry, in my haste I had forgotten that.
| |
| 194 if (use_zygote) { | 195 if (use_zygote) { |
| 195 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(), | 196 handle = ZygoteHostImpl::GetInstance()->ForkRequest(cmd_line->argv(), |
| 196 files_to_register, | 197 files_to_register, |
| 197 process_type); | 198 process_type); |
| 198 } else | 199 } else |
| 199 // Fall through to the normal posix case below when we're not zygoting. | 200 // Fall through to the normal posix case below when we're not zygoting. |
| 200 #endif // !defined(OS_MACOSX) | 201 #endif // !defined(OS_MACOSX) |
| 201 { | 202 { |
| 202 // Convert FD mapping to FileHandleMappingVector | 203 // Convert FD mapping to FileHandleMappingVector |
| 203 base::FileHandleMappingVector fds_to_map; | 204 base::FileHandleMappingVector fds_to_map; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 base::Bind( | 446 base::Bind( |
| 446 &ChildProcessLauncher::Context::SetProcessBackgrounded, | 447 &ChildProcessLauncher::Context::SetProcessBackgrounded, |
| 447 GetHandle(), background)); | 448 GetHandle(), background)); |
| 448 } | 449 } |
| 449 | 450 |
| 450 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 451 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 451 bool terminate_on_shutdown) { | 452 bool terminate_on_shutdown) { |
| 452 if (context_) | 453 if (context_) |
| 453 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 454 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 454 } | 455 } |
| OLD | NEW |