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