Revert of Use scoped_ptr for NavigationEntries. (patchset #4 id:60001 of https:/...
[chromium-blink-merge.git] / base / process / process_metrics_ios.cc
blob07f2c8de1d46ff41ed88214b0ac624f94f5eb0d9
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 ProcessMetrics::ProcessMetrics(ProcessHandle process) {}
28 ProcessMetrics::~ProcessMetrics() {}
30 // static
31 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) {
32 return new ProcessMetrics(process);
35 double ProcessMetrics::GetCPUUsage() {
36 NOTIMPLEMENTED();
37 return 0;
40 size_t ProcessMetrics::GetPagefileUsage() const {
41 task_basic_info_64 task_info_data;
42 if (!GetTaskInfo(&task_info_data))
43 return 0;
44 return task_info_data.virtual_size;
47 size_t ProcessMetrics::GetWorkingSetSize() const {
48 task_basic_info_64 task_info_data;
49 if (!GetTaskInfo(&task_info_data))
50 return 0;
51 return task_info_data.resident_size;
54 size_t GetMaxFds() {
55 static const rlim_t kSystemDefaultMaxFds = 256;
56 rlim_t max_fds;
57 struct rlimit nofile;
58 if (getrlimit(RLIMIT_NOFILE, &nofile)) {
59 // Error case: Take a best guess.
60 max_fds = kSystemDefaultMaxFds;
61 } else {
62 max_fds = nofile.rlim_cur;
65 if (max_fds > INT_MAX)
66 max_fds = INT_MAX;
68 return static_cast<size_t>(max_fds);
71 void SetFdLimit(unsigned int max_descriptors) {
72 // Unimplemented.
75 size_t GetPageSize() {
76 return getpagesize();
79 // Bytes committed by the system.
80 size_t GetSystemCommitCharge() {
81 NOTIMPLEMENTED();
82 return 0;
85 } // namespace base