Bug 1649121: part 26) Move `CollectTopMostChildContentsCompletelyInRange`. r=masayuki
[gecko.git] / widget / ProcInfo.h
blob0076603adfe42d34a29e9dd6dcac860424aa18a9
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"
12 #include "mozilla/MozPromise.h"
14 namespace mozilla {
16 namespace ipc {
17 class GeckoChildProcessHost;
20 // Process types. When updating this enum, please make sure to update
21 // WebIDLProcType, ChromeUtils::RequestProcInfo and ProcTypeToWebIDL to
22 // mirror the changes.
23 enum class ProcType {
24 // These must match the ones in ContentParent.h, and E10SUtils.jsm
25 Web,
26 WebIsolated,
27 File,
28 Extension,
29 PrivilegedAbout,
30 PrivilegedMozilla,
31 WebLargeAllocation,
32 WebCOOPCOEP,
33 // the rest matches GeckoProcessTypes.h
34 Browser, // Default is named Browser here
35 Plugin,
36 IPDLUnitTest,
37 GMPlugin,
38 GPU,
39 VR,
40 RDD,
41 Socket,
42 RemoteSandboxBroker,
43 #ifdef MOZ_ENABLE_FORKSERVER
44 ForkServer,
45 #endif
46 Preallocated,
47 // Unknown type of process
48 Unknown,
49 Max = Unknown,
52 struct ThreadInfo {
53 // Thread Id.
54 base::ProcessId tid = 0;
55 // Thread name, if any.
56 nsString name;
57 // User time in ns.
58 uint64_t cpuUser = 0;
59 // System time in ns.
60 uint64_t cpuKernel = 0;
63 struct ProcInfo {
64 // Process Id
65 base::ProcessId pid = 0;
66 // Child Id as defined by Firefox when a child process is created.
67 dom::ContentParentId childId;
68 // Process type
69 ProcType type;
70 // Origin, if any
71 nsCString origin;
72 // Process filename (without the path name).
73 nsString filename;
74 // VMS in bytes.
75 uint64_t virtualMemorySize = 0;
76 // RSS in bytes.
77 int64_t residentSetSize = 0;
78 // User time in ns.
79 uint64_t cpuUser = 0;
80 // System time in ns.
81 uint64_t cpuKernel = 0;
82 // Threads owned by this process.
83 CopyableTArray<ThreadInfo> threads;
86 typedef MozPromise<ProcInfo, nsresult, true> ProcInfoPromise;
89 * GetProcInfo() uses a background thread to perform system calls.
91 * Depending on the platform, this call can be quite expensive and the
92 * promise may return after several ms.
94 #ifdef XP_MACOSX
95 RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
96 const ProcType& processType,
97 const nsACString& origin,
98 mach_port_t aChildTask = MACH_PORT_NULL);
99 #else
100 RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
101 const ProcType& processType,
102 const nsACString& origin);
103 #endif
105 } // namespace mozilla
106 #endif // ProcInfo_h