Add bookmark apps to taskbar automatically.
[chromium-blink-merge.git] / base / process / process_metrics_ios.cc
blob9ae838d39a0b4ec341c36a52a32accd7a78c7ec1
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 namespace base {
11 namespace {
13 bool GetTaskInfo(task_basic_info_64* task_info_data) {
14 mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
15 kern_return_t kr = task_info(mach_task_self(),
16 TASK_BASIC_INFO_64,
17 reinterpret_cast<task_info_t>(task_info_data),
18 &count);
19 return kr == KERN_SUCCESS;
22 } // namespace
24 ProcessMetrics::ProcessMetrics(ProcessHandle process) {}
26 ProcessMetrics::~ProcessMetrics() {}
28 // static
29 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) {
30 return new ProcessMetrics(process);
33 size_t ProcessMetrics::GetPagefileUsage() const {
34 task_basic_info_64 task_info_data;
35 if (!GetTaskInfo(&task_info_data))
36 return 0;
37 return task_info_data.virtual_size;
40 size_t ProcessMetrics::GetWorkingSetSize() const {
41 task_basic_info_64 task_info_data;
42 if (!GetTaskInfo(&task_info_data))
43 return 0;
44 return task_info_data.resident_size;
47 size_t GetMaxFds() {
48 static const rlim_t kSystemDefaultMaxFds = 256;
49 rlim_t max_fds;
50 struct rlimit nofile;
51 if (getrlimit(RLIMIT_NOFILE, &nofile)) {
52 // Error case: Take a best guess.
53 max_fds = kSystemDefaultMaxFds;
54 } else {
55 max_fds = nofile.rlim_cur;
58 if (max_fds > INT_MAX)
59 max_fds = INT_MAX;
61 return static_cast<size_t>(max_fds);
64 void SetFdLimit(unsigned int max_descriptors) {
65 // Unimplemented.
68 size_t GetPageSize() {
69 return getpagesize();
72 } // namespace base