| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 14 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 15 #include "content/browser/content_browser_client.h" | 16 #include "content/browser/content_browser_client.h" |
| 16 #include "content/common/chrome_descriptors.h" | 17 #include "content/common/chrome_descriptors.h" |
| 17 #include "content/common/content_switches.h" | 18 #include "content/common/content_switches.h" |
| 18 #include "content/common/process_watcher.h" | 19 #include "content/common/process_watcher.h" |
| 19 #include "content/common/result_codes.h" | 20 #include "content/common/result_codes.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 BrowserThread::ID client_thread_id, | 109 BrowserThread::ID client_thread_id, |
| 109 #if defined(OS_WIN) | 110 #if defined(OS_WIN) |
| 110 const FilePath& exposed_dir, | 111 const FilePath& exposed_dir, |
| 111 #elif defined(OS_POSIX) | 112 #elif defined(OS_POSIX) |
| 112 bool use_zygote, | 113 bool use_zygote, |
| 113 const base::environment_vector& env, | 114 const base::environment_vector& env, |
| 114 int ipcfd, | 115 int ipcfd, |
| 115 #endif | 116 #endif |
| 116 CommandLine* cmd_line) { | 117 CommandLine* cmd_line) { |
| 117 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); | 118 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); |
| 119 |
| 118 base::ProcessHandle handle = base::kNullProcessHandle; | 120 base::ProcessHandle handle = base::kNullProcessHandle; |
| 119 #if defined(OS_WIN) | 121 #if defined(OS_WIN) |
| 120 handle = sandbox::StartProcessWithAccess(cmd_line, exposed_dir); | 122 handle = sandbox::StartProcessWithAccess(cmd_line, exposed_dir); |
| 121 #elif defined(OS_POSIX) | 123 #elif defined(OS_POSIX) |
| 124 // We need to close the client end of the IPC channel |
| 125 // to reliably detect child termination. |
| 126 file_util::ScopedFD ipcfd_closer(&ipcfd); |
| 122 | 127 |
| 123 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 128 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 124 // On Linux, we need to add some extra file descriptors for crash handling. | 129 // On Linux, we need to add some extra file descriptors for crash handling. |
| 125 std::string process_type = | 130 std::string process_type = |
| 126 cmd_line->GetSwitchValueASCII(switches::kProcessType); | 131 cmd_line->GetSwitchValueASCII(switches::kProcessType); |
| 127 int crash_signal_fd = | 132 int crash_signal_fd = |
| 128 content::GetContentClient()->browser()->GetCrashSignalFD(process_type); | 133 content::GetContentClient()->browser()->GetCrashSignalFD(process_type); |
| 129 if (use_zygote) { | 134 if (use_zygote) { |
| 130 base::GlobalDescriptors::Mapping mapping; | 135 base::GlobalDescriptors::Mapping mapping; |
| 131 mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd)); | 136 mapping.push_back(std::pair<uint32_t, int>(kPrimaryIPCChannel, ipcfd)); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 NewRunnableFunction( | 388 NewRunnableFunction( |
| 384 &ChildProcessLauncher::Context::SetProcessBackgrounded, | 389 &ChildProcessLauncher::Context::SetProcessBackgrounded, |
| 385 GetHandle(), background)); | 390 GetHandle(), background)); |
| 386 } | 391 } |
| 387 | 392 |
| 388 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 393 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 389 bool terminate_on_shutdown) { | 394 bool terminate_on_shutdown) { |
| 390 if (context_) | 395 if (context_) |
| 391 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 396 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 392 } | 397 } |
| OLD | NEW |