| Index: base/process/process_posix.cc
|
| diff --git a/base/process/process_posix.cc b/base/process/process_posix.cc
|
| index 3d8b31d0352e6c027a2d132255654ff3d8692e13..3c714d7cb2431a864ff35745a1675bd9663c29f1 100644
|
| --- a/base/process/process_posix.cc
|
| +++ b/base/process/process_posix.cc
|
| @@ -13,6 +13,100 @@
|
|
|
| namespace base {
|
|
|
| +ProcessObject::ProcessObject(ProcessHandle handle) : process_(handle) {
|
| + CHECK_NE(handle, GetCurrentProcessHandle());
|
| +}
|
| +
|
| +ProcessObject::ProcessObject(RValue other)
|
| + : process_(other.object->process_) {
|
| + other.object->Close();
|
| +}
|
| +
|
| +ProcessObject& ProcessObject::operator=(RValue other) {
|
| + if (this != other.object) {
|
| + process_ = other.object->process_;
|
| + other.object->Close();
|
| + }
|
| + return *this;
|
| +}
|
| +
|
| +// static
|
| +ProcessObject ProcessObject::Current() {
|
| + ProcessObject process;
|
| + process.process_ = GetCurrentProcessHandle();
|
| + return process.Pass();
|
| +}
|
| +
|
| +#if !defined(OS_LINUX)
|
| +// static
|
| +bool ProcessObject::CanBackgroundProcesses() {
|
| + return false;
|
| +}
|
| +#endif // !defined(OS_LINUX)
|
| +
|
| +bool ProcessObject::IsValid() const {
|
| + return process_ != kNullProcessHandle;
|
| +}
|
| +
|
| +ProcessHandle ProcessObject::Handle() const {
|
| + return process_;
|
| +}
|
| +
|
| +ProcessObject ProcessObject::Duplicate() const {
|
| + if (is_current())
|
| + return Current();
|
| +
|
| + return ProcessObject(process_);
|
| +}
|
| +
|
| +ProcessId ProcessObject::pid() const {
|
| + DCHECK(IsValid());
|
| + return GetProcId(process_);
|
| +}
|
| +
|
| +bool ProcessObject::is_current() const {
|
| + return process_ == GetCurrentProcessHandle();
|
| +}
|
| +
|
| +void ProcessObject::Close() {
|
| + process_ = kNullProcessHandle;
|
| + // if the process wasn't terminated (so we waited) or the state
|
| + // wasn't already collected w/ a wait from process_utils, we're gonna
|
| + // end up w/ a zombie when it does finally exit.
|
| +}
|
| +
|
| +void ProcessObject::Terminate(int result_code) {
|
| + // result_code isn't supportable.
|
| + DCHECK(IsValid());
|
| + // We don't wait here. It's the responsibility of other code to reap the
|
| + // child.
|
| + KillProcess(process_, result_code, false);
|
| +}
|
| +
|
| +#if !defined(OS_LINUX)
|
| +bool ProcessObject::IsProcessBackgrounded() const {
|
| + // See SetProcessBackgrounded().
|
| + DCHECK(IsValid());
|
| + return false;
|
| +}
|
| +
|
| +bool ProcessObject::SetProcessBackgrounded(bool value) {
|
| + // POSIX only allows lowering the priority of a process, so if we
|
| + // were to lower it we wouldn't be able to raise it back to its initial
|
| + // priority.
|
| + DCHECK(IsValid());
|
| + return false;
|
| +}
|
| +#endif // !defined(OS_LINUX)
|
| +
|
| +int ProcessObject::GetPriority() const {
|
| + DCHECK(IsValid());
|
| + return getpriority(PRIO_PROCESS, process_);
|
| +}
|
| +
|
| +// -----------------------------------------------------------------------------
|
| +// TODO(rvargas) crbug.com/417532: Remove Process::*
|
| +
|
| // static
|
| Process Process::Current() {
|
| return Process(GetCurrentProcessHandle());
|
|
|