| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <mach/task.h> | 8 #include <mach/task.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 bool GetTaskInfo(task_basic_info_64* task_info_data) { | 18 bool GetTaskInfo(task_basic_info_64* task_info_data) { |
| 18 mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT; | 19 mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT; |
| 19 kern_return_t kr = task_info(mach_task_self(), | 20 kern_return_t kr = task_info(mach_task_self(), |
| 20 TASK_BASIC_INFO_64, | 21 TASK_BASIC_INFO_64, |
| 21 reinterpret_cast<task_info_t>(task_info_data), | 22 reinterpret_cast<task_info_t>(task_info_data), |
| 22 &count); | 23 &count); |
| 23 return kr == KERN_SUCCESS; | 24 return kr == KERN_SUCCESS; |
| 24 } | 25 } |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 SystemMemoryInfoKB::SystemMemoryInfoKB() { | 29 SystemMemoryInfoKB::SystemMemoryInfoKB() : total(0), free(0) {} |
| 29 total = 0; | |
| 30 free = 0; | |
| 31 } | |
| 32 | 30 |
| 33 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = | 31 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = |
| 34 default; | 32 default; |
| 35 | 33 |
| 36 ProcessMetrics::ProcessMetrics(ProcessHandle process) {} | 34 ProcessMetrics::ProcessMetrics(ProcessHandle process) {} |
| 37 | 35 |
| 38 ProcessMetrics::~ProcessMetrics() {} | 36 ProcessMetrics::~ProcessMetrics() {} |
| 39 | 37 |
| 40 // static | 38 // static |
| 41 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) { | 39 std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics( |
| 42 return new ProcessMetrics(process); | 40 ProcessHandle process) { |
| 41 return WrapUnique(new ProcessMetrics(process)); |
| 43 } | 42 } |
| 44 | 43 |
| 45 double ProcessMetrics::GetCPUUsage() { | 44 double ProcessMetrics::GetCPUUsage() { |
| 46 NOTIMPLEMENTED(); | 45 NOTIMPLEMENTED(); |
| 47 return 0; | 46 return 0; |
| 48 } | 47 } |
| 49 | 48 |
| 50 size_t ProcessMetrics::GetPagefileUsage() const { | 49 size_t ProcessMetrics::GetPagefileUsage() const { |
| 51 task_basic_info_64 task_info_data; | 50 task_basic_info_64 task_info_data; |
| 52 if (!GetTaskInfo(&task_info_data)) | 51 if (!GetTaskInfo(&task_info_data)) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 92 } |
| 94 | 93 |
| 95 // Bytes committed by the system. | 94 // Bytes committed by the system. |
| 96 bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { | 95 bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { |
| 97 // Unimplemented. Must enable unittest for IOS when this gets implemented. | 96 // Unimplemented. Must enable unittest for IOS when this gets implemented. |
| 98 NOTIMPLEMENTED(); | 97 NOTIMPLEMENTED(); |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| 101 | 100 |
| 102 } // namespace base | 101 } // namespace base |
| OLD | NEW |