| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <sys/param.h> | 9 #include <sys/param.h> |
| 10 #include <sys/sysctl.h> | 10 #include <sys/sysctl.h> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return -1; | 57 return -1; |
| 58 | 58 |
| 59 return info.p_vm_rssize * getpagesize(); | 59 return info.p_vm_rssize * getpagesize(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 size_t ProcessMetrics::GetPeakWorkingSetSize() const { | 62 size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
| 63 return 0; | 63 return 0; |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, | 66 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| 67 size_t* shared_bytes) { | 67 size_t* shared_bytes) const { |
| 68 WorkingSetKBytes ws_usage; | 68 WorkingSetKBytes ws_usage; |
| 69 | 69 |
| 70 if (!GetWorkingSetKBytes(&ws_usage)) | 70 if (!GetWorkingSetKBytes(&ws_usage)) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 if (private_bytes) | 73 if (private_bytes) |
| 74 *private_bytes = ws_usage.priv << 10; | 74 *private_bytes = ws_usage.priv << 10; |
| 75 | 75 |
| 76 if (shared_bytes) | 76 if (shared_bytes) |
| 77 *shared_bytes = ws_usage.shared * 1024; | 77 *shared_bytes = ws_usage.shared * 1024; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 mem_total = vmtotal.t_vm; | 157 mem_total = vmtotal.t_vm; |
| 158 mem_free = vmtotal.t_free; | 158 mem_free = vmtotal.t_free; |
| 159 mem_inactive = vmtotal.t_vm - vmtotal.t_avm; | 159 mem_inactive = vmtotal.t_vm - vmtotal.t_avm; |
| 160 | 160 |
| 161 pagesize = getpagesize(); | 161 pagesize = getpagesize(); |
| 162 | 162 |
| 163 return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize); | 163 return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace base | 166 } // namespace base |
| OLD | NEW |