OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_metrics.h" | 5 #include "base/process/process_metrics.h" |
6 | 6 |
7 #include <mach/mach.h> | 7 #include <mach/mach.h> |
8 #include <mach/mach_vm.h> | 8 #include <mach/mach_vm.h> |
9 #include <mach/shared_region.h> | 9 #include <mach/shared_region.h> |
| 10 #include <stddef.h> |
| 11 #include <stdint.h> |
10 #include <sys/sysctl.h> | 12 #include <sys/sysctl.h> |
11 | 13 |
12 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
13 #include "base/logging.h" | 15 #include "base/logging.h" |
14 #include "base/mac/mach_logging.h" | 16 #include "base/mac/mach_logging.h" |
15 #include "base/mac/scoped_mach_port.h" | 17 #include "base/mac/scoped_mach_port.h" |
16 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
17 | 19 |
18 #if !defined(TASK_POWER_INFO) | 20 #if !defined(TASK_POWER_INFO) |
19 // Doesn't exist in the 10.6 or 10.7 SDKs. | 21 // Doesn't exist in the 10.6 or 10.7 SDKs. |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 TIME_VALUE_TO_TIMEVAL(&thread_info_data.system_time, &system_timeval); | 279 TIME_VALUE_TO_TIMEVAL(&thread_info_data.system_time, &system_timeval); |
278 timeradd(&user_timeval, &system_timeval, &task_timeval); | 280 timeradd(&user_timeval, &system_timeval, &task_timeval); |
279 | 281 |
280 // ... task info contains terminated time. | 282 // ... task info contains terminated time. |
281 TIME_VALUE_TO_TIMEVAL(&task_info_data.user_time, &user_timeval); | 283 TIME_VALUE_TO_TIMEVAL(&task_info_data.user_time, &user_timeval); |
282 TIME_VALUE_TO_TIMEVAL(&task_info_data.system_time, &system_timeval); | 284 TIME_VALUE_TO_TIMEVAL(&task_info_data.system_time, &system_timeval); |
283 timeradd(&user_timeval, &task_timeval, &task_timeval); | 285 timeradd(&user_timeval, &task_timeval, &task_timeval); |
284 timeradd(&system_timeval, &task_timeval, &task_timeval); | 286 timeradd(&system_timeval, &task_timeval, &task_timeval); |
285 | 287 |
286 TimeTicks time = TimeTicks::Now(); | 288 TimeTicks time = TimeTicks::Now(); |
287 int64 task_time = TimeValToMicroseconds(task_timeval); | 289 int64_t task_time = TimeValToMicroseconds(task_timeval); |
288 | 290 |
289 if (last_system_time_ == 0) { | 291 if (last_system_time_ == 0) { |
290 // First call, just set the last values. | 292 // First call, just set the last values. |
291 last_cpu_time_ = time; | 293 last_cpu_time_ = time; |
292 last_system_time_ = task_time; | 294 last_system_time_ = task_time; |
293 return 0; | 295 return 0; |
294 } | 296 } |
295 | 297 |
296 int64 system_time_delta = task_time - last_system_time_; | 298 int64_t system_time_delta = task_time - last_system_time_; |
297 int64 time_delta = (time - last_cpu_time_).InMicroseconds(); | 299 int64_t time_delta = (time - last_cpu_time_).InMicroseconds(); |
298 DCHECK_NE(0U, time_delta); | 300 DCHECK_NE(0U, time_delta); |
299 if (time_delta == 0) | 301 if (time_delta == 0) |
300 return 0; | 302 return 0; |
301 | 303 |
302 last_cpu_time_ = time; | 304 last_cpu_time_ = time; |
303 last_system_time_ = task_time; | 305 last_system_time_ = task_time; |
304 | 306 |
305 return static_cast<double>(system_time_delta * 100.0) / time_delta; | 307 return static_cast<double>(system_time_delta * 100.0) / time_delta; |
306 } | 308 } |
307 | 309 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 return false; | 387 return false; |
386 } | 388 } |
387 | 389 |
388 meminfo->free = static_cast<int>( | 390 meminfo->free = static_cast<int>( |
389 (vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE / 1024); | 391 (vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE / 1024); |
390 | 392 |
391 return true; | 393 return true; |
392 } | 394 } |
393 | 395 |
394 } // namespace base | 396 } // namespace base |
OLD | NEW |