• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/process/process_metrics.h"
6 
7 #include <lib/fdio/limits.h>
8 #include <lib/zx/process.h>
9 
10 #include "base/fuchsia/fuchsia_logging.h"
11 #include "base/memory/ptr_util.h"
12 
13 namespace base {
14 
GetMaxFds()15 size_t GetMaxFds() {
16   return FDIO_MAX_FD;
17 }
18 
GetHandleLimit()19 size_t GetHandleLimit() {
20   // Duplicated from the internal Magenta kernel constant kMaxHandleCount
21   // (zircon/kernel/object/handle.cc).
22   return 256 * 1024u;
23 }
24 
GetSystemCommitCharge()25 size_t GetSystemCommitCharge() {
26   // TODO(https://crbug.com/926581): Fuchsia does not support this.
27   return 0;
28 }
29 
ProcessMetrics(ProcessHandle process)30 ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process) {}
31 
32 // static
CreateProcessMetrics(ProcessHandle process)33 std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics(
34     ProcessHandle process) {
35   return base::WrapUnique(new ProcessMetrics(process));
36 }
37 
GetCumulativeCPUUsage()38 TimeDelta ProcessMetrics::GetCumulativeCPUUsage() {
39   zx_info_task_runtime_t stats;
40 
41   zx_status_t status = zx::unowned_process(process_)->get_info(
42       ZX_INFO_TASK_RUNTIME, &stats, sizeof(stats), nullptr, nullptr);
43   ZX_CHECK(status == ZX_OK, status);
44 
45   return TimeDelta::FromZxDuration(stats.cpu_time);
46 }
47 
GetSystemMemoryInfo(SystemMemoryInfoKB * meminfo)48 bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) {
49   // TODO(https://crbug.com/926581).
50   return false;
51 }
52 
53 }  // namespace base
54