| 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" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 #endif | 249 #endif |
| 250 process_.handle())); | 250 process_.handle())); |
| 251 process_.set_handle(base::kNullProcessHandle); | 251 process_.set_handle(base::kNullProcessHandle); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void SetProcessBackgrounded(bool background) { | 254 void SetProcessBackgrounded(bool background) { |
| 255 DCHECK(!starting_); | 255 DCHECK(!starting_); |
| 256 process_.SetProcessBackgrounded(background); | 256 process_.SetProcessBackgrounded(background); |
| 257 } | 257 } |
| 258 | 258 |
| 259 // TODO(apatrick): Remove this ASAP. http://crbog.com/81449 shows that this is | |
| 260 // called before later calling null. Disable optimization to try and get more | |
| 261 // information about what happened here. | |
| 262 #if defined(OS_WIN) | |
| 263 #pragma optimize("", off) | |
| 264 #endif | |
| 265 | |
| 266 static void TerminateInternal( | 259 static void TerminateInternal( |
| 267 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 260 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 268 bool zygote, | 261 bool zygote, |
| 269 #endif | 262 #endif |
| 270 base::ProcessHandle handle) { | 263 base::ProcessHandle handle) { |
| 271 base::Process process(handle); | 264 base::Process process(handle); |
| 272 // Client has gone away, so just kill the process. Using exit code 0 | 265 // Client has gone away, so just kill the process. Using exit code 0 |
| 273 // means that UMA won't treat this as a crash. | 266 // means that UMA won't treat this as a crash. |
| 274 process.Terminate(content::RESULT_CODE_NORMAL_EXIT); | 267 process.Terminate(content::RESULT_CODE_NORMAL_EXIT); |
| 275 // On POSIX, we must additionally reap the child. | 268 // On POSIX, we must additionally reap the child. |
| 276 #if defined(OS_POSIX) | 269 #if defined(OS_POSIX) |
| 277 #if !defined(OS_MACOSX) | 270 #if !defined(OS_MACOSX) |
| 278 if (zygote) { | 271 if (zygote) { |
| 279 // If the renderer was created via a zygote, we have to proxy the reaping | 272 // If the renderer was created via a zygote, we have to proxy the reaping |
| 280 // through the zygote process. | 273 // through the zygote process. |
| 281 ZygoteHost::GetInstance()->EnsureProcessTerminated(handle); | 274 ZygoteHost::GetInstance()->EnsureProcessTerminated(handle); |
| 282 } else | 275 } else |
| 283 #endif // !OS_MACOSX | 276 #endif // !OS_MACOSX |
| 284 { | 277 { |
| 285 ProcessWatcher::EnsureProcessTerminated(handle); | 278 ProcessWatcher::EnsureProcessTerminated(handle); |
| 286 } | 279 } |
| 287 #endif // OS_POSIX | 280 #endif // OS_POSIX |
| 288 process.Close(); | 281 process.Close(); |
| 289 } | 282 } |
| 290 | 283 |
| 291 #if defined(OS_WIN) | |
| 292 #pragma optimize("", on) | |
| 293 #endif | |
| 294 | |
| 295 Client* client_; | 284 Client* client_; |
| 296 BrowserThread::ID client_thread_id_; | 285 BrowserThread::ID client_thread_id_; |
| 297 base::Process process_; | 286 base::Process process_; |
| 298 base::TerminationStatus termination_status_; | 287 base::TerminationStatus termination_status_; |
| 299 int exit_code_; | 288 int exit_code_; |
| 300 bool starting_; | 289 bool starting_; |
| 301 // Controls whether the child process should be terminated on browser | 290 // Controls whether the child process should be terminated on browser |
| 302 // shutdown. Default behavior is to terminate the child. | 291 // shutdown. Default behavior is to terminate the child. |
| 303 bool terminate_child_on_shutdown_; | 292 bool terminate_child_on_shutdown_; |
| 304 | 293 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 context_.get(), | 375 context_.get(), |
| 387 &ChildProcessLauncher::Context::SetProcessBackgrounded, | 376 &ChildProcessLauncher::Context::SetProcessBackgrounded, |
| 388 background)); | 377 background)); |
| 389 } | 378 } |
| 390 | 379 |
| 391 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 380 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 392 bool terminate_on_shutdown) { | 381 bool terminate_on_shutdown) { |
| 393 if (context_) | 382 if (context_) |
| 394 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 383 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 395 } | 384 } |
| OLD | NEW |