Bug 1613552 [wpt PR 21618] - Fix timeout vs. task-queue race conditions in promise...
[gecko.git] / widget / ProcInfo.h
blobdb51781855ca0525f49c649152a3a4e2db63ec11
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 #ifdef MOZ_ENABLE_FORKSERVER
39 ForkServer,
40 #endif
41 // Unknown type of process
42 Unknown,
43 Max = Unknown,
46 struct ThreadInfo {
47 // Thread Id.
48 base::ProcessId tid = 0;
49 // Thread name, if any.
50 nsString name;
51 // User time in ns.
52 uint64_t cpuUser = 0;
53 // System time in ns.
54 uint64_t cpuKernel = 0;
57 struct ProcInfo {
58 // Process Id
59 base::ProcessId pid = 0;
60 // Child Id as defined by Firefox when a child process is created.
61 dom::ContentParentId childId;
62 // Process type
63 ProcType type;
64 // Process filename (without the path name).
65 nsString filename;
66 // VMS in bytes.
67 uint64_t virtualMemorySize = 0;
68 // RSS in bytes.
69 int64_t residentSetSize = 0;
70 // User time in ns.
71 uint64_t cpuUser = 0;
72 // System time in ns.
73 uint64_t cpuKernel = 0;
74 // Threads owned by this process.
75 nsTArray<ThreadInfo> threads;
78 typedef MozPromise<ProcInfo, nsresult, true> ProcInfoPromise;
81 * GetProcInfo() uses a background thread to perform system calls.
83 * Depending on the platform, this call can be quite expensive and the
84 * promise may return after several ms.
86 #ifdef XP_MACOSX
87 RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
88 const ProcType& type,
89 mach_port_t aChildTask = MACH_PORT_NULL);
90 #else
91 RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
92 const ProcType& type);
93 #endif
95 } // namespace mozilla
96 #endif // ProcInfo_h