| 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/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 16 #include "content/browser/content_browser_client.h" | 16 #include "content/browser/content_browser_client.h" |
| 17 #include "content/common/chrome_descriptors.h" | 17 #include "content/common/chrome_descriptors.h" |
| 18 #include "content/common/content_switches.h" | 18 #include "content/common/content_switches.h" |
| 19 #include "content/common/process_watcher.h" | 19 #include "content/common/process_watcher.h" |
| 20 #include "content/common/result_codes.h" | 20 #include "content/common/result_codes.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include "base/file_path.h" | 23 #include "base/file_path.h" |
| 24 #include "content/browser/handle_enumerator_win.h" | |
| 25 #include "content/common/sandbox_policy.h" | 24 #include "content/common/sandbox_policy.h" |
| 26 #elif defined(OS_MACOSX) | 25 #elif defined(OS_MACOSX) |
| 27 #include "content/browser/mach_broker_mac.h" | 26 #include "content/browser/mach_broker_mac.h" |
| 28 #elif defined(OS_POSIX) | 27 #elif defined(OS_POSIX) |
| 29 #include "base/memory/singleton.h" | 28 #include "base/memory/singleton.h" |
| 30 #include "content/browser/zygote_host_linux.h" | 29 #include "content/browser/zygote_host_linux.h" |
| 31 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 30 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
| 32 #endif | 31 #endif |
| 33 | 32 |
| 34 #if defined(OS_POSIX) | 33 #if defined(OS_POSIX) |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 | 231 |
| 233 void Terminate() { | 232 void Terminate() { |
| 234 if (!process_.handle()) | 233 if (!process_.handle()) |
| 235 return; | 234 return; |
| 236 | 235 |
| 237 if (!terminate_child_on_shutdown_) | 236 if (!terminate_child_on_shutdown_) |
| 238 return; | 237 return; |
| 239 | 238 |
| 240 #if defined(OS_WIN) | |
| 241 const CommandLine& browser_command_line = | |
| 242 *CommandLine::ForCurrentProcess(); | |
| 243 if (browser_command_line.HasSwitch(switches::kAuditHandles) || | |
| 244 browser_command_line.HasSwitch(switches::kAuditAllHandles)) { | |
| 245 scoped_refptr<content::HandleEnumerator> handle_enum( | |
| 246 new content::HandleEnumerator(process_.handle(), | |
| 247 browser_command_line.HasSwitch(switches::kAuditAllHandles))); | |
| 248 handle_enum->RunHandleEnumeration(); | |
| 249 process_.set_handle(base::kNullProcessHandle); | |
| 250 return; | |
| 251 } | |
| 252 #endif | |
| 253 | |
| 254 // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So | 239 // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So |
| 255 // don't this on the UI/IO threads. | 240 // don't this on the UI/IO threads. |
| 256 BrowserThread::PostTask( | 241 BrowserThread::PostTask( |
| 257 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, | 242 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 258 NewRunnableFunction( | 243 NewRunnableFunction( |
| 259 &Context::TerminateInternal, | 244 &Context::TerminateInternal, |
| 260 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 245 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 261 zygote_, | 246 zygote_, |
| 262 #endif | 247 #endif |
| 263 process_.handle())); | 248 process_.handle())); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 NewRunnableFunction( | 373 NewRunnableFunction( |
| 389 &ChildProcessLauncher::Context::SetProcessBackgrounded, | 374 &ChildProcessLauncher::Context::SetProcessBackgrounded, |
| 390 GetHandle(), background)); | 375 GetHandle(), background)); |
| 391 } | 376 } |
| 392 | 377 |
| 393 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 378 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 394 bool terminate_on_shutdown) { | 379 bool terminate_on_shutdown) { |
| 395 if (context_) | 380 if (context_) |
| 396 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 381 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 397 } | 382 } |
| OLD | NEW |