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> | 10 #include <stddef.h> |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 ChromeTaskVMInfo task_vm_info; | 330 ChromeTaskVMInfo task_vm_info; |
331 mach_msg_type_number_t count = ChromeTaskVMInfoCount; | 331 mach_msg_type_number_t count = ChromeTaskVMInfoCount; |
332 kern_return_t result = | 332 kern_return_t result = |
333 task_info(TaskForPid(process_), TASK_VM_INFO, | 333 task_info(TaskForPid(process_), TASK_VM_INFO, |
334 reinterpret_cast<task_info_t>(&task_vm_info), &count); | 334 reinterpret_cast<task_info_t>(&task_vm_info), &count); |
335 if (result != KERN_SUCCESS) | 335 if (result != KERN_SUCCESS) |
336 return 0; | 336 return 0; |
337 return task_vm_info.phys_footprint; | 337 return task_vm_info.phys_footprint; |
338 } | 338 } |
339 | 339 |
340 size_t GetInternalAndCompressed() const { | |
Primiano Tucci (use gerrit)
2017/04/25 12:43:35
+ProcessMetrics::
| |
341 task_vm_info info; | |
342 mach_msg_type_number_t count = TASK_VM_INFO_COUNT; | |
343 kern_return_t result = | |
344 task_info(TaskForPid(process_), TASK_VM_INFO, | |
345 reinterpret_cast<task_info_t>(&info), &count); | |
346 if (result != KERN_SUCCESS) | |
347 return 0; | |
348 return task_vm_info.internal + task_vm_info.compressed; | |
349 } | |
350 | |
340 #define TIME_VALUE_TO_TIMEVAL(a, r) do { \ | 351 #define TIME_VALUE_TO_TIMEVAL(a, r) do { \ |
341 (r)->tv_sec = (a)->seconds; \ | 352 (r)->tv_sec = (a)->seconds; \ |
342 (r)->tv_usec = (a)->microseconds; \ | 353 (r)->tv_usec = (a)->microseconds; \ |
343 } while (0) | 354 } while (0) |
344 | 355 |
345 double ProcessMetrics::GetCPUUsage() { | 356 double ProcessMetrics::GetCPUUsage() { |
346 mach_port_t task = TaskForPid(process_); | 357 mach_port_t task = TaskForPid(process_); |
347 if (task == MACH_PORT_NULL) | 358 if (task == MACH_PORT_NULL) |
348 return 0; | 359 return 0; |
349 | 360 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.speculative_count); | 508 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.speculative_count); |
498 meminfo->file_backed = | 509 meminfo->file_backed = |
499 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.external_page_count); | 510 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.external_page_count); |
500 meminfo->purgeable = | 511 meminfo->purgeable = |
501 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.purgeable_count); | 512 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.purgeable_count); |
502 | 513 |
503 return true; | 514 return true; |
504 } | 515 } |
505 | 516 |
506 } // namespace base | 517 } // namespace base |
OLD | NEW |