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 <sys/sysctl.h> | 10 #include <sys/sysctl.h> |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (info.share_mode == SM_COW && info.ref_count == 1) | 159 if (info.share_mode == SM_COW && info.ref_count == 1) |
160 info.share_mode = SM_PRIVATE; | 160 info.share_mode = SM_PRIVATE; |
161 | 161 |
162 switch (info.share_mode) { | 162 switch (info.share_mode) { |
163 case SM_PRIVATE: | 163 case SM_PRIVATE: |
164 private_pages_count += info.private_pages_resident; | 164 private_pages_count += info.private_pages_resident; |
165 private_pages_count += info.shared_pages_resident; | 165 private_pages_count += info.shared_pages_resident; |
166 break; | 166 break; |
167 case SM_COW: | 167 case SM_COW: |
168 private_pages_count += info.private_pages_resident; | 168 private_pages_count += info.private_pages_resident; |
169 // Fall through | 169 FALLTHROUGH_INTENDED; |
170 case SM_SHARED: | 170 case SM_SHARED: |
171 if (seen_objects.count(info.obj_id) == 0) { | 171 if (seen_objects.count(info.obj_id) == 0) { |
172 // Only count the first reference to this region. | 172 // Only count the first reference to this region. |
173 seen_objects.insert(info.obj_id); | 173 seen_objects.insert(info.obj_id); |
174 shared_pages_count += info.shared_pages_resident; | 174 shared_pages_count += info.shared_pages_resident; |
175 } | 175 } |
176 break; | 176 break; |
177 default: | 177 default: |
178 break; | 178 break; |
179 } | 179 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 kr = host_page_size(host, &page_size); | 316 kr = host_page_size(host, &page_size); |
317 if (kr) { | 317 if (kr) { |
318 DLOG(ERROR) << "Failed to fetch host page size."; | 318 DLOG(ERROR) << "Failed to fetch host page size."; |
319 return 0; | 319 return 0; |
320 } | 320 } |
321 | 321 |
322 return (data.active_count * page_size) / 1024; | 322 return (data.active_count * page_size) / 1024; |
323 } | 323 } |
324 | 324 |
325 } // namespace base | 325 } // namespace base |
OLD | NEW |