Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: content/browser/child_process_launcher.cc

Issue 7054080: Add a flag to print the handles held by a child process when it shuts down. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "build/build_config.h"
22 #include "base/file_path.h" 23 #include "base/file_path.h"
24 #include "chrome/common/chrome_switches.h"
jam 2011/06/09 21:44:29 this isn't needed
Cris Neckar 2011/06/09 22:17:16 Done.
25 #include "content/browser/handle_enumerator_win.h"
23 #include "content/common/sandbox_policy.h" 26 #include "content/common/sandbox_policy.h"
24 #elif defined(OS_MACOSX) 27 #elif defined(OS_MACOSX)
25 #include "chrome/browser/mach_broker_mac.h" 28 #include "chrome/browser/mach_broker_mac.h"
26 #elif defined(OS_POSIX) 29 #elif defined(OS_POSIX)
27 #include "base/memory/singleton.h" 30 #include "base/memory/singleton.h"
28 #include "content/browser/zygote_host_linux.h" 31 #include "content/browser/zygote_host_linux.h"
29 #include "content/browser/renderer_host/render_sandbox_host_linux.h" 32 #include "content/browser/renderer_host/render_sandbox_host_linux.h"
30 #endif 33 #endif
31 34
32 #if defined(OS_POSIX) 35 #if defined(OS_POSIX)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 212 }
210 } 213 }
211 214
212 void Terminate() { 215 void Terminate() {
213 if (!process_.handle()) 216 if (!process_.handle())
214 return; 217 return;
215 218
216 if (!terminate_child_on_shutdown_) 219 if (!terminate_child_on_shutdown_)
217 return; 220 return;
218 221
222 #if defined(OS_WIN)
223 const CommandLine& browser_command_line =
224 *CommandLine::ForCurrentProcess();
225 if (browser_command_line.HasSwitch(switches::kAuditHandles) ||
226 browser_command_line.HasSwitch(switches::kAuditAllHandles)) {
227 scoped_refptr<content::HandleEnumerator> handle_enum(
228 new content::HandleEnumerator(process_.handle(),
229 browser_command_line.HasSwitch(switches::kAuditAllHandles)));
230 handle_enum->RunHandleEnumeration();
231 process_.set_handle(base::kNullProcessHandle);
232 return;
233 }
234 #endif
235
219 // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So 236 // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So
220 // don't this on the UI/IO threads. 237 // don't this on the UI/IO threads.
221 BrowserThread::PostTask( 238 BrowserThread::PostTask(
222 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, 239 BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
223 NewRunnableFunction( 240 NewRunnableFunction(
224 &ChildProcessLauncher::Context::TerminateInternal, 241 &ChildProcessLauncher::Context::TerminateInternal,
225 #if defined(OS_POSIX) && !defined(OS_MACOSX) 242 #if defined(OS_POSIX) && !defined(OS_MACOSX)
226 zygote_, 243 zygote_,
227 #endif 244 #endif
228 process_.handle())); 245 process_.handle()));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 &ChildProcessLauncher::Context::SetProcessBackgrounded, 370 &ChildProcessLauncher::Context::SetProcessBackgrounded,
354 background)); 371 background));
355 } 372 }
356 373
357 void ChildProcessLauncher::SetTerminateChildOnShutdown( 374 void ChildProcessLauncher::SetTerminateChildOnShutdown(
358 bool terminate_on_shutdown) { 375 bool terminate_on_shutdown) {
359 if (context_) 376 if (context_)
360 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); 377 context_->set_terminate_child_on_shutdown(terminate_on_shutdown);
361 } 378 }
362 379
OLDNEW
« no previous file with comments | « no previous file | content/browser/handle_enumerator_win.h » ('j') | content/common/content_switches.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698