2019-02-23 21:07:59 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef __mozilla_ProcInfo_h
|
|
|
|
#define __mozilla_ProcInfo_h
|
|
|
|
|
|
|
|
#include <base/process.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "mozilla/dom/ipc/IdType.h"
|
2020-05-01 06:02:13 +03:00
|
|
|
#include "mozilla/MozPromise.h"
|
2019-02-23 21:07:59 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2019-06-07 22:56:51 +03:00
|
|
|
namespace ipc {
|
|
|
|
class GeckoChildProcessHost;
|
|
|
|
}
|
|
|
|
|
2019-08-31 00:55:42 +03:00
|
|
|
// Process types. When updating this enum, please make sure to update
|
2020-05-30 17:38:30 +03:00
|
|
|
// WebIDLProcType, ChromeUtils::RequestProcInfo and ProcTypeToWebIDL to
|
|
|
|
// mirror the changes.
|
2019-02-23 21:07:59 +03:00
|
|
|
enum class ProcType {
|
2019-08-31 00:55:42 +03:00
|
|
|
// These must match the ones in ContentParent.h, and E10SUtils.jsm
|
2019-02-23 21:07:59 +03:00
|
|
|
Web,
|
2020-05-06 23:11:55 +03:00
|
|
|
WebIsolated,
|
2019-02-23 21:07:59 +03:00
|
|
|
File,
|
|
|
|
Extension,
|
2019-05-29 14:31:31 +03:00
|
|
|
PrivilegedAbout,
|
2020-05-06 23:11:55 +03:00
|
|
|
PrivilegedMozilla,
|
2019-02-23 21:07:59 +03:00
|
|
|
WebLargeAllocation,
|
2020-05-06 23:11:55 +03:00
|
|
|
WebCOOPCOEP,
|
2019-06-21 04:33:47 +03:00
|
|
|
// the rest matches GeckoProcessTypes.h
|
|
|
|
Browser, // Default is named Browser here
|
|
|
|
Plugin,
|
|
|
|
IPDLUnitTest,
|
|
|
|
GMPlugin,
|
|
|
|
GPU,
|
|
|
|
VR,
|
|
|
|
RDD,
|
2019-02-23 21:07:59 +03:00
|
|
|
Socket,
|
2019-06-21 04:33:47 +03:00
|
|
|
RemoteSandboxBroker,
|
2019-12-19 18:50:03 +03:00
|
|
|
#ifdef MOZ_ENABLE_FORKSERVER
|
|
|
|
ForkServer,
|
|
|
|
#endif
|
2020-05-30 17:38:30 +03:00
|
|
|
Preallocated,
|
2019-02-23 21:07:59 +03:00
|
|
|
// Unknown type of process
|
2019-08-31 00:55:42 +03:00
|
|
|
Unknown,
|
|
|
|
Max = Unknown,
|
2019-02-23 21:07:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ThreadInfo {
|
|
|
|
// Thread Id.
|
|
|
|
base::ProcessId tid = 0;
|
|
|
|
// Thread name, if any.
|
|
|
|
nsString name;
|
|
|
|
// User time in ns.
|
|
|
|
uint64_t cpuUser = 0;
|
|
|
|
// System time in ns.
|
|
|
|
uint64_t cpuKernel = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ProcInfo {
|
|
|
|
// Process Id
|
|
|
|
base::ProcessId pid = 0;
|
|
|
|
// Child Id as defined by Firefox when a child process is created.
|
|
|
|
dom::ContentParentId childId;
|
|
|
|
// Process type
|
|
|
|
ProcType type;
|
2020-05-06 23:11:55 +03:00
|
|
|
// Origin, if any
|
2020-07-08 23:15:59 +03:00
|
|
|
nsCString origin;
|
2019-02-23 21:07:59 +03:00
|
|
|
// Process filename (without the path name).
|
|
|
|
nsString filename;
|
|
|
|
// VMS in bytes.
|
|
|
|
uint64_t virtualMemorySize = 0;
|
|
|
|
// RSS in bytes.
|
|
|
|
int64_t residentSetSize = 0;
|
|
|
|
// User time in ns.
|
|
|
|
uint64_t cpuUser = 0;
|
|
|
|
// System time in ns.
|
|
|
|
uint64_t cpuKernel = 0;
|
|
|
|
// Threads owned by this process.
|
2020-04-30 12:38:38 +03:00
|
|
|
CopyableTArray<ThreadInfo> threads;
|
2019-02-23 21:07:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef MozPromise<ProcInfo, nsresult, true> ProcInfoPromise;
|
|
|
|
|
2019-02-28 09:30:05 +03:00
|
|
|
/*
|
|
|
|
* GetProcInfo() uses a background thread to perform system calls.
|
|
|
|
*
|
|
|
|
* Depending on the platform, this call can be quite expensive and the
|
|
|
|
* promise may return after several ms.
|
|
|
|
*/
|
2019-06-21 04:33:47 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
|
2020-05-06 23:11:55 +03:00
|
|
|
const ProcType& processType,
|
2020-07-08 23:15:59 +03:00
|
|
|
const nsACString& origin,
|
2019-06-21 04:33:47 +03:00
|
|
|
mach_port_t aChildTask = MACH_PORT_NULL);
|
|
|
|
#else
|
|
|
|
RefPtr<ProcInfoPromise> GetProcInfo(base::ProcessId pid, int32_t childId,
|
2020-05-06 23:11:55 +03:00
|
|
|
const ProcType& processType,
|
2020-07-08 23:15:59 +03:00
|
|
|
const nsACString& origin);
|
2019-06-21 04:33:47 +03:00
|
|
|
#endif
|
2019-02-23 21:07:59 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // ProcInfo_h
|