| 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 <sys/sysctl.h> | 8 #include <sys/sysctl.h> |
| 9 #include <sys/user.h> | 9 #include <sys/user.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return 0; | 51 return 0; |
| 52 | 52 |
| 53 return info.ki_rssize * getpagesize(); | 53 return info.ki_rssize * getpagesize(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 size_t ProcessMetrics::GetPeakWorkingSetSize() const { | 56 size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
| 57 return 0; | 57 return 0; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, | 60 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| 61 size_t* shared_bytes) { | 61 size_t* shared_bytes) const { |
| 62 WorkingSetKBytes ws_usage; | 62 WorkingSetKBytes ws_usage; |
| 63 if (!GetWorkingSetKBytes(&ws_usage)) | 63 if (!GetWorkingSetKBytes(&ws_usage)) |
| 64 return false; | 64 return false; |
| 65 | 65 |
| 66 if (private_bytes) | 66 if (private_bytes) |
| 67 *private_bytes = ws_usage.priv << 10; | 67 *private_bytes = ws_usage.priv << 10; |
| 68 | 68 |
| 69 if (shared_bytes) | 69 if (shared_bytes) |
| 70 *shared_bytes = ws_usage.shared * 1024; | 70 *shared_bytes = ws_usage.shared * 1024; |
| 71 | 71 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 NULL, 0) < 0) { | 116 NULL, 0) < 0) { |
| 117 return 0; | 117 return 0; |
| 118 } | 118 } |
| 119 | 119 |
| 120 pagesize = getpagesize(); | 120 pagesize = getpagesize(); |
| 121 | 121 |
| 122 return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize); | 122 return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace base | 125 } // namespace base |
| OLD | NEW |