| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, | 238 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 239 NewRunnableFunction( | 239 NewRunnableFunction( |
| 240 &ChildProcessLauncher::Context::TerminateInternal, | 240 &ChildProcessLauncher::Context::TerminateInternal, |
| 241 #if defined(OS_LINUX) | 241 #if defined(OS_LINUX) |
| 242 zygote_, | 242 zygote_, |
| 243 #endif | 243 #endif |
| 244 process_.handle())); | 244 process_.handle())); |
| 245 process_.set_handle(base::kNullProcessHandle); | 245 process_.set_handle(base::kNullProcessHandle); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void SetProcessBackgrounded(bool background) { |
| 249 DCHECK(!starting_); |
| 250 process_.SetProcessBackgrounded(background); |
| 251 } |
| 252 |
| 248 static void TerminateInternal( | 253 static void TerminateInternal( |
| 249 #if defined(OS_LINUX) | 254 #if defined(OS_LINUX) |
| 250 bool zygote, | 255 bool zygote, |
| 251 #endif | 256 #endif |
| 252 base::ProcessHandle handle) { | 257 base::ProcessHandle handle) { |
| 253 base::Process process(handle); | 258 base::Process process(handle); |
| 254 // Client has gone away, so just kill the process. Using exit code 0 | 259 // Client has gone away, so just kill the process. Using exit code 0 |
| 255 // means that UMA won't treat this as a crash. | 260 // means that UMA won't treat this as a crash. |
| 256 process.Terminate(ResultCodes::NORMAL_EXIT); | 261 process.Terminate(ResultCodes::NORMAL_EXIT); |
| 257 // On POSIX, we must additionally reap the child. | 262 // On POSIX, we must additionally reap the child. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // it'll reap the process. However, if GetTerminationStatus didn't | 341 // it'll reap the process. However, if GetTerminationStatus didn't |
| 337 // reap the child (because it was still running), we'll need to | 342 // reap the child (because it was still running), we'll need to |
| 338 // Terminate via ProcessWatcher. So we can't close the handle here. | 343 // Terminate via ProcessWatcher. So we can't close the handle here. |
| 339 if (status != base::TERMINATION_STATUS_STILL_RUNNING) | 344 if (status != base::TERMINATION_STATUS_STILL_RUNNING) |
| 340 context_->process_.Close(); | 345 context_->process_.Close(); |
| 341 | 346 |
| 342 return status; | 347 return status; |
| 343 } | 348 } |
| 344 | 349 |
| 345 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { | 350 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |
| 346 DCHECK(!context_->starting_); | 351 BrowserThread::PostTask( |
| 347 context_->process_.SetProcessBackgrounded(background); | 352 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 353 NewRunnableMethod( |
| 354 context_.get(), |
| 355 &ChildProcessLauncher::Context::SetProcessBackgrounded, |
| 356 background)); |
| 348 } | 357 } |
| OLD | NEW |