Refactored not to expose raw pointers on ProxyList class.
[chromium-blink-merge.git] / base / process / process_metrics_ios.cc
blob135ef43c06c12a5a850c39a81fc3a19a6fa2a39a
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
3 // found in the LICENSE file.
5 #include "base/process/process_metrics.h"
7 #include <mach/task.h>
9 #include "base/logging.h"
11 namespace base {
13 namespace {
15 bool GetTaskInfo(task_basic_info_64* task_info_data) {
16 mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
17 kern_return_t kr = task_info(mach_task_self(),
18 TASK_BASIC_INFO_64,
19 reinterpret_cast<task_info_t>(task_info_data),
20 &count);
21 return kr == KERN_SUCCESS;
24 } // namespace
26 SystemMemoryInfoKB::SystemMemoryInfoKB() {
27 total = 0;
28 free = 0;
31 ProcessMetrics::ProcessMetrics(ProcessHandle process) {}
33 ProcessMetrics::~ProcessMetrics() {}
35 // static
36 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) {
37 return new ProcessMetrics(process);
40 double ProcessMetrics::GetCPUUsage() {
41 NOTIMPLEMENTED();
42 return 0;
45 size_t ProcessMetrics::GetPagefileUsage() const {
46 task_basic_info_64 task_info_data;
47 if (!GetTaskInfo(&task_info_data))
48 return 0;
49 return task_info_data.virtual_size;
52 size_t ProcessMetrics::GetWorkingSetSize() const {
53 task_basic_info_64 task_info_data;
54 if (!GetTaskInfo(&task_info_data))
55 return 0;
56 return task_info_data.resident_size;
59 size_t GetMaxFds() {
60 static const rlim_t kSystemDefaultMaxFds = 256;
61 rlim_t max_fds;
62 struct rlimit nofile;
63 if (getrlimit(RLIMIT_NOFILE, &nofile)) {
64 // Error case: Take a best guess.
65 max_fds = kSystemDefaultMaxFds;
66 } else {
67 max_fds = nofile.rlim_cur;
70 if (max_fds > INT_MAX)
71 max_fds = INT_MAX;
73 return static_cast<size_t>(max_fds);
76 void SetFdLimit(unsigned int max_descriptors) {
77 // Unimplemented.
80 size_t GetPageSize() {
81 return getpagesize();
84 // Bytes committed by the system.
85 size_t GetSystemCommitCharge() {
86 NOTIMPLEMENTED();
87 return 0;
90 // Bytes committed by the system.
91 bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) {
92 // Unimplemented. Must enable unittest for IOS when this gets implemented.
93 NOTIMPLEMENTED();
94 return false;
97 } // namespace base