Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: base/process/process_metrics_mac.cc

Issue 2838803003: Add a field platform_private_footprint_ to ProcessMemoryTotals. (Closed)
Patch Set: Comments from mark. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/process_metrics.h ('k') | base/trace_event/process_memory_totals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 10 #include <stddef.h>
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 usage->mapped = 0; 280 usage->mapped = 0;
281 usage->image = 0; 281 usage->image = 0;
282 282
283 ws_usage->priv = task_info_data.resident_size / 1024; 283 ws_usage->priv = task_info_data.resident_size / 1024;
284 ws_usage->shareable = 0; 284 ws_usage->shareable = 0;
285 ws_usage->shared = 0; 285 ws_usage->shared = 0;
286 286
287 return true; 287 return true;
288 } 288 }
289 289
290 size_t ProcessMetrics::GetPhysicalFootprint() const { 290 ProcessMetrics::TaskVMInfo ProcessMetrics::GetTaskVMInfo() const {
291 if (mac::IsAtMostOS10_11()) 291 TaskVMInfo info;
292 return 0;
293
294 ChromeTaskVMInfo task_vm_info; 292 ChromeTaskVMInfo task_vm_info;
295 mach_msg_type_number_t count = ChromeTaskVMInfoCount; 293 mach_msg_type_number_t count = ChromeTaskVMInfoCount;
296 kern_return_t result = 294 kern_return_t result =
297 task_info(TaskForPid(process_), TASK_VM_INFO, 295 task_info(TaskForPid(process_), TASK_VM_INFO,
298 reinterpret_cast<task_info_t>(&task_vm_info), &count); 296 reinterpret_cast<task_info_t>(&task_vm_info), &count);
299 if (result != KERN_SUCCESS) 297 if (result != KERN_SUCCESS)
300 return 0; 298 return info;
301 return task_vm_info.phys_footprint; 299
300 info.internal = task_vm_info.internal;
301 info.compressed = task_vm_info.compressed;
302 if (count == ChromeTaskVMInfoCount)
303 info.phys_footprint = task_vm_info.phys_footprint;
304 return info;
302 } 305 }
303 306
304 #define TIME_VALUE_TO_TIMEVAL(a, r) do { \ 307 #define TIME_VALUE_TO_TIMEVAL(a, r) do { \
305 (r)->tv_sec = (a)->seconds; \ 308 (r)->tv_sec = (a)->seconds; \
306 (r)->tv_usec = (a)->microseconds; \ 309 (r)->tv_usec = (a)->microseconds; \
307 } while (0) 310 } while (0)
308 311
309 double ProcessMetrics::GetCPUUsage() { 312 double ProcessMetrics::GetCPUUsage() {
310 mach_port_t task = TaskForPid(process_); 313 mach_port_t task = TaskForPid(process_);
311 if (task == MACH_PORT_NULL) 314 if (task == MACH_PORT_NULL)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 task, address, size, VM_REGION_BASIC_INFO_64, 498 task, address, size, VM_REGION_BASIC_INFO_64,
496 reinterpret_cast<vm_region_info_t>(info), &info_count, &object_name); 499 reinterpret_cast<vm_region_info_t>(info), &info_count, &object_name);
497 // The kernel always returns a null object for VM_REGION_BASIC_INFO_64, but 500 // The kernel always returns a null object for VM_REGION_BASIC_INFO_64, but
498 // balance it with a deallocate in case this ever changes. See 10.9.2 501 // balance it with a deallocate in case this ever changes. See 10.9.2
499 // xnu-2422.90.20/osfmk/vm/vm_map.c vm_map_region. 502 // xnu-2422.90.20/osfmk/vm/vm_map.c vm_map_region.
500 mach_port_deallocate(task, object_name); 503 mach_port_deallocate(task, object_name);
501 return ParseOutputFromMachVMRegion(kr); 504 return ParseOutputFromMachVMRegion(kr);
502 } 505 }
503 506
504 } // namespace base 507 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics.h ('k') | base/trace_event/process_memory_totals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698