Chromium Code Reviews| Index: base/process/process_metrics_ios.cc | 
| diff --git a/base/process/process_metrics_ios.cc b/base/process/process_metrics_ios.cc | 
| index e6b01192b5965c4a8151e655e5a9833e57676867..c2fe360910537aed93aa1d61039436f0a0505422 100644 | 
| --- a/base/process/process_metrics_ios.cc | 
| +++ b/base/process/process_metrics_ios.cc | 
| @@ -9,6 +9,7 @@ | 
| #include <stddef.h> | 
| #include "base/logging.h" | 
| +#include "base/mac/scoped_mach_port.h" | 
| #include "base/memory/ptr_util.h" | 
| namespace base { | 
| @@ -26,11 +27,6 @@ bool GetTaskInfo(task_basic_info_64* task_info_data) { | 
| } // namespace | 
| -SystemMemoryInfoKB::SystemMemoryInfoKB() : total(0), free(0) {} | 
| 
 
brucedawson
2017/03/11 01:42:08
Don't these need to be =defaulted in?
 
 | 
| - | 
| -SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = | 
| - default; | 
| - | 
| ProcessMetrics::ProcessMetrics(ProcessHandle process) {} | 
| ProcessMetrics::~ProcessMetrics() {} | 
| @@ -91,11 +87,38 @@ size_t GetSystemCommitCharge() { | 
| return 0; | 
| } | 
| -// Bytes committed by the system. | 
| bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { | 
| - // Unimplemented. Must enable unittest for IOS when this gets implemented. | 
| - NOTIMPLEMENTED(); | 
| - return false; | 
| + struct host_basic_info hostinfo; | 
| + mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; | 
| + base::mac::ScopedMachSendRight host(mach_host_self()); | 
| + int result = host_info(host.get(), HOST_BASIC_INFO, | 
| + reinterpret_cast<host_info_t>(&hostinfo), &count); | 
| + if (result != KERN_SUCCESS) | 
| + return false; | 
| + | 
| + DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); | 
| + meminfo->total = static_cast<int>(hostinfo.max_mem / 1024); | 
| + | 
| + vm_statistics64_data_t vm_info; | 
| + count = HOST_VM_INFO64_COUNT; | 
| + | 
| + if (host_statistics64(host.get(), HOST_VM_INFO64, | 
| + reinterpret_cast<host_info64_t>(&vm_info), | 
| + &count) != KERN_SUCCESS) { | 
| + return false; | 
| + } | 
| + DCHECK_EQ(HOST_VM_INFO64_COUNT, count); | 
| + | 
| + meminfo->free = static_cast<int>( | 
| 
 
danakj
2017/03/13 16:01:20
same thing as the _mac file here re casting and in
 
danakj
2017/03/13 16:01:20
So I'm not sure what you did to relieve my worry h
 
Michael K. (Yandex Team)
2017/03/14 03:49:09
Done.
 
Michael K. (Yandex Team)
2017/03/14 03:49:09
Done.
 
 | 
| + (vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE / 1024); | 
| + meminfo->speculative = | 
| + static_cast<int>(vm_info.speculative_count * PAGE_SIZE / 1024); | 
| + meminfo->file_backed = | 
| + static_cast<int>(vm_info.external_page_count * PAGE_SIZE / 1024); | 
| + meminfo->purgeable = | 
| + static_cast<int>(vm_info.purgeable_count * PAGE_SIZE / 1024); | 
| + | 
| + return true; | 
| } | 
| } // namespace base |