1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/process.h"
6 #include "base/logging.h"
7 #include "base/process_util.h"
8 #include "base/scoped_ptr.h"
12 void Process::Close() {
15 ::CloseHandle(process_
);
19 void Process::Terminate(int result_code
) {
22 ::TerminateProcess(process_
, result_code
);
25 bool Process::IsProcessBackgrounded() const {
27 return false; // Failure case.
28 DWORD priority
= GetPriority();
30 return false; // Failure case.
31 return priority
== BELOW_NORMAL_PRIORITY_CLASS
;
34 bool Process::SetProcessBackgrounded(bool value
) {
37 DWORD priority
= value
? BELOW_NORMAL_PRIORITY_CLASS
: NORMAL_PRIORITY_CLASS
;
38 return (SetPriorityClass(process_
, priority
) != 0);
41 ProcessId
Process::pid() const {
45 return GetProcId(process_
);
48 bool Process::is_current() const {
49 return process_
== GetCurrentProcess();
53 Process
Process::Current() {
54 return Process(GetCurrentProcess());
57 int Process::GetPriority() const {
59 return GetPriorityClass(process_
);