Bug 1579327 [wpt PR 18888] - Make canShare() and files support tests tentative, a...
[gecko.git] / widget / ProcInfo.h
blob8e719a8ba27b78036f10192d66065f6a6867e5b4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef __mozilla_ProcInfo_h
7 #define __mozilla_ProcInfo_h
9 #include <base/process.h>
10 #include <stdint.h>
11 #include "mozilla/dom/ipc/IdType.h"
13 namespace mozilla {
15 namespace ipc {
16 class GeckoChildProcessHost;
19 // Process types. When updating this enum, please make sure to update
20 // WebIDLProcType and ProcTypeToWebIDL to mirror the changes.
21 enum class ProcType {
22 // These must match the ones in ContentParent.h, and E10SUtils.jsm
23 Web,
24 File,
25 Extension,
26 PrivilegedAbout,
27 WebLargeAllocation,
28 // the rest matches GeckoProcessTypes.h
29 Browser, // Default is named Browser here
30 Plugin,
31 IPDLUnitTest,
32 GMPlugin,
33 GPU,
34 VR,
35 RDD,
36 Socket,
37 RemoteSandboxBroker,
38 // Unknown type of process
39 Unknown,
40 Max = Unknown,
43 struct ThreadInfo {
44 // Thread Id.
45 base::ProcessId tid = 0;
46 // Thread name, if any.
47 nsString name;
48 // User time in ns.
49 uint64_t cpuUser = 0;
50 // System time in ns.
51 uint64_t cpuKernel = 0;
54 struct ProcInfo {
55 // Process Id
56 base::ProcessId pid = 0;
57 // Child Id as defined by Firefox when a child process is created.
58 dom::ContentParentId childId;
59 // Process type
60 ProcType type;
61 // Process filename (without the path name).
62 nsString filename;
63 // VMS in bytes.
64 uint64_t virtualMemorySize = 0;
65 // RSS in bytes.
66 int64_t residentSetSize = 0;
67 // User time in ns.
68 uint64_t cpuUser = 0;
69 // System time in ns.
70 uint64_t cpuKernel = 0;
71 // Threads owned by this process.
72 nsTArray<ThreadInfo> threads;
75 typedef MozPromise<ProcInfo, nsresult, true> ProcInfoPromise;
78 * GetProcInfo() uses a background thread to perform system calls.
80 * Depending on the platform, this call can be quite expensive and the
81 * promise may return after several ms.
83 #ifdef XP_MACOSX
84 RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
85 const ProcType& type,
86 mach_port_t aChildTask = MACH_PORT_NULL);
87 #else
88 RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
89 const ProcType& type);
90 #endif
92 } // namespace mozilla
93 #endif // ProcInfo_h