| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/process/process.h" | 5 #include "base/process/process.h" |
| 6 | 6 |
| 7 #include <sys/resource.h> | 7 #include <sys/resource.h> |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 Process Process::Current() { | 34 Process Process::Current() { |
| 35 Process process; | 35 Process process; |
| 36 process.process_ = GetCurrentProcessHandle(); | 36 process.process_ = GetCurrentProcessHandle(); |
| 37 return process.Pass(); | 37 return process.Pass(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 Process Process::Open(ProcessId pid) { |
| 42 if (pid == GetCurrentProcId()) |
| 43 return Current(); |
| 44 |
| 45 // On POSIX process handles are the same as PIDs. |
| 46 return Process(pid); |
| 47 } |
| 48 |
| 49 // static |
| 41 Process Process::OpenWithExtraPriviles(ProcessId pid) { | 50 Process Process::OpenWithExtraPriviles(ProcessId pid) { |
| 42 if (pid == GetCurrentProcId()) | 51 // On POSIX there are no privileges to set. |
| 43 return Current(); | 52 return Open(pid); |
| 44 | |
| 45 // On POSIX process handles are the same as PIDs, and there are no privileges | |
| 46 // to set. | |
| 47 return Process(pid); | |
| 48 } | 53 } |
| 49 | 54 |
| 50 // static | 55 // static |
| 51 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { | 56 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { |
| 52 DCHECK_NE(handle, GetCurrentProcessHandle()); | 57 DCHECK_NE(handle, GetCurrentProcessHandle()); |
| 53 return Process(handle); | 58 return Process(handle); |
| 54 } | 59 } |
| 55 | 60 |
| 56 #if !defined(OS_LINUX) | 61 #if !defined(OS_LINUX) |
| 57 // static | 62 // static |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return false; | 131 return false; |
| 127 } | 132 } |
| 128 #endif // !defined(OS_LINUX) | 133 #endif // !defined(OS_LINUX) |
| 129 | 134 |
| 130 int Process::GetPriority() const { | 135 int Process::GetPriority() const { |
| 131 DCHECK(IsValid()); | 136 DCHECK(IsValid()); |
| 132 return getpriority(PRIO_PROCESS, process_); | 137 return getpriority(PRIO_PROCESS, process_); |
| 133 } | 138 } |
| 134 | 139 |
| 135 } // namspace base | 140 } // namspace base |
| OLD | NEW |