| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/process/process.h" | 17 #include "base/process/process.h" |
| 17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/common/content_descriptors.h" | 22 #include "content/public/common/content_descriptors.h" |
| 22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/result_codes.h" | 24 #include "content/public/common/result_codes.h" |
| 24 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 25 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 497 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 497 zygote_, | 498 zygote_, |
| 498 #endif | 499 #endif |
| 499 base::Passed(&process_))); | 500 base::Passed(&process_))); |
| 500 } | 501 } |
| 501 | 502 |
| 502 // static | 503 // static |
| 503 void ChildProcessLauncher::Context::SetProcessBackgroundedInternal( | 504 void ChildProcessLauncher::Context::SetProcessBackgroundedInternal( |
| 504 base::Process process, | 505 base::Process process, |
| 505 bool background) { | 506 bool background) { |
| 507 #if defined(OS_MACOSX) |
| 508 const std::string trial_group_name = |
| 509 base::FieldTrialList::FindFullName("BackgroundMacRendererProcesses"); |
| 510 // Activate backgrounding when the user is part of the field trial, or |
| 511 // there's no trial (i.e. a perf bot) |
| 512 if (trial_group_name != "Off") { |
| 513 MachBroker* broker = MachBroker::GetInstance(); |
| 514 process.SetProcessBackgrounded(broker->TaskForPid(process.Pid()), |
| 515 background); |
| 516 } |
| 517 #else |
| 506 process.SetProcessBackgrounded(background); | 518 process.SetProcessBackgrounded(background); |
| 519 #endif // defined(OS_MACOSX) |
| 507 #if defined(OS_ANDROID) | 520 #if defined(OS_ANDROID) |
| 508 SetChildProcessInForeground(process.Handle(), !background); | 521 SetChildProcessInForeground(process.Handle(), !background); |
| 509 #endif | 522 #endif |
| 510 } | 523 } |
| 511 | 524 |
| 512 // static | 525 // static |
| 513 void ChildProcessLauncher::Context::TerminateInternal( | 526 void ChildProcessLauncher::Context::TerminateInternal( |
| 514 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 527 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 515 bool zygote, | 528 bool zygote, |
| 516 #endif | 529 #endif |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 context_->SetProcessBackgrounded(background); | 608 context_->SetProcessBackgrounded(background); |
| 596 } | 609 } |
| 597 | 610 |
| 598 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 611 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 599 bool terminate_on_shutdown) { | 612 bool terminate_on_shutdown) { |
| 600 if (context_.get()) | 613 if (context_.get()) |
| 601 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 614 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 602 } | 615 } |
| 603 | 616 |
| 604 } // namespace content | 617 } // namespace content |
| OLD | NEW |