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

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

Issue 2782083003: Clean up some Mac memory code. (Closed)
Patch Set: Update comment. Created 3 years, 8 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') | no next file » | 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>
11 #include <stdint.h> 11 #include <stdint.h>
12 #include <sys/sysctl.h> 12 #include <sys/sysctl.h>
13 13
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/mac/mach_logging.h" 16 #include "base/mac/mach_logging.h"
17 #include "base/mac/scoped_mach_port.h" 17 #include "base/mac/scoped_mach_port.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/numerics/safe_conversions.h" 19 #include "base/numerics/safe_conversions.h"
20 #include "base/sys_info.h" 20 #include "base/sys_info.h"
21 21
22 #if !defined(TASK_POWER_INFO)
23 // Doesn't exist in the 10.6 or 10.7 SDKs.
24 #define TASK_POWER_INFO 21
25 struct task_power_info {
26 uint64_t total_user;
27 uint64_t total_system;
28 uint64_t task_interrupt_wakeups;
29 uint64_t task_platform_idle_wakeups;
30 uint64_t task_timer_wakeups_bin_1;
31 uint64_t task_timer_wakeups_bin_2;
32 };
33 typedef struct task_power_info task_power_info_data_t;
34 typedef struct task_power_info *task_power_info_t;
35 #define TASK_POWER_INFO_COUNT ((mach_msg_type_number_t) \
36 (sizeof (task_power_info_data_t) / sizeof (natural_t)))
37 #endif
38
39 namespace base { 22 namespace base {
40 23
41 namespace { 24 namespace {
42 25
43 bool GetTaskInfo(mach_port_t task, task_basic_info_64* task_info_data) { 26 bool GetTaskInfo(mach_port_t task, task_basic_info_64* task_info_data) {
44 if (task == MACH_PORT_NULL) 27 if (task == MACH_PORT_NULL)
45 return false; 28 return false;
46 mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT; 29 mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
47 kern_return_t kr = task_info(task, 30 kern_return_t kr = task_info(task,
48 TASK_BASIC_INFO_64, 31 TASK_BASIC_INFO_64,
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.speculative_count); 400 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.speculative_count);
418 meminfo->file_backed = 401 meminfo->file_backed =
419 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.external_page_count); 402 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.external_page_count);
420 meminfo->purgeable = 403 meminfo->purgeable =
421 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.purgeable_count); 404 saturated_cast<int>(PAGE_SIZE / 1024 * vm_info.purgeable_count);
422 405
423 return true; 406 return true;
424 } 407 }
425 408
426 } // namespace base 409 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698