Chromium Code Reviews| 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 base::FieldTrial* trial = | |
| 509 base::FieldTrialList::Find("BackgroundMacRendererProcesses"); | |
|
Alexei Svitkine (slow)
2015/03/11 15:30:54
Nit: You can just use FindFullName() and then the
shrike
2015/03/11 21:38:21
Done.
| |
| 510 if (trial && trial->group_name() == "On") { | |
|
gab
2015/03/10 12:33:02
I would suggest taking this path by default in the
shrike
2015/03/10 18:00:33
OK. Will Finch flags be available soon enough afte
gab
2015/03/10 19:43:50
Yes, Finch is brought up before creating any threa
Alexei Svitkine (slow)
2015/03/11 15:30:54
Correct.
| |
| 511 MachBroker* broker = MachBroker::GetInstance(); | |
| 512 process.SetProcessBackgrounded(broker->TaskForPid(process.Pid()), | |
| 513 background); | |
| 514 } | |
| 515 #else | |
| 506 process.SetProcessBackgrounded(background); | 516 process.SetProcessBackgrounded(background); |
| 517 #endif // defined(OS_MACOSX) | |
| 507 #if defined(OS_ANDROID) | 518 #if defined(OS_ANDROID) |
| 508 SetChildProcessInForeground(process.Handle(), !background); | 519 SetChildProcessInForeground(process.Handle(), !background); |
| 509 #endif | 520 #endif |
| 510 } | 521 } |
| 511 | 522 |
| 512 // static | 523 // static |
| 513 void ChildProcessLauncher::Context::TerminateInternal( | 524 void ChildProcessLauncher::Context::TerminateInternal( |
| 514 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 525 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 515 bool zygote, | 526 bool zygote, |
| 516 #endif | 527 #endif |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 context_->SetProcessBackgrounded(background); | 606 context_->SetProcessBackgrounded(background); |
| 596 } | 607 } |
| 597 | 608 |
| 598 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 609 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 599 bool terminate_on_shutdown) { | 610 bool terminate_on_shutdown) { |
| 600 if (context_.get()) | 611 if (context_.get()) |
| 601 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 612 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 602 } | 613 } |
| 603 | 614 |
| 604 } // namespace content | 615 } // namespace content |
| OLD | NEW |