OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/sys_info.h" |
11 | 12 |
12 namespace process_util { | 13 namespace process_util { |
13 | 14 |
14 int GetCurrentProcId() { | 15 int GetCurrentProcId() { |
15 return getpid(); | 16 return getpid(); |
16 } | 17 } |
17 | 18 |
18 ProcessHandle GetCurrentProcessHandle() { | 19 ProcessHandle GetCurrentProcessHandle() { |
19 return GetCurrentProcId(); | 20 return GetCurrentProcId(); |
20 } | 21 } |
21 | 22 |
22 int GetProcId(ProcessHandle process) { | 23 int GetProcId(ProcessHandle process) { |
23 return process; | 24 return process; |
24 } | 25 } |
25 | 26 |
| 27 ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process), |
| 28 last_time_(0), |
| 29 last_system_time_(0) { |
| 30 processor_count_ = base::SysInfo::NumberOfProcessors(); |
| 31 } |
| 32 |
| 33 // static |
| 34 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) { |
| 35 return new ProcessMetrics(process); |
| 36 } |
| 37 |
| 38 ProcessMetrics::~ProcessMetrics() { } |
| 39 |
26 void EnableTerminationOnHeapCorruption() { | 40 void EnableTerminationOnHeapCorruption() { |
27 // On POSIX, there nothing to do AFAIK. | 41 // On POSIX, there nothing to do AFAIK. |
28 } | 42 } |
29 | 43 |
30 void RaiseProcessToHighPriority() { | 44 void RaiseProcessToHighPriority() { |
31 // On POSIX, we don't actually do anything here. We could try to nice() or | 45 // On POSIX, we don't actually do anything here. We could try to nice() or |
32 // setpriority() or sched_getscheduler, but these all require extra rights. | 46 // setpriority() or sched_getscheduler, but these all require extra rights. |
33 } | 47 } |
34 | 48 |
35 } // namespace process_util | 49 } // namespace process_util |
OLD | NEW |