summaryrefslogtreecommitdiffstats
path: root/toolkit/components/processtools
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/processtools')
-rw-r--r--toolkit/components/processtools/ProcInfo.h12
-rw-r--r--toolkit/components/processtools/ProcInfo.mm45
-rw-r--r--toolkit/components/processtools/moz.build2
3 files changed, 30 insertions, 29 deletions
diff --git a/toolkit/components/processtools/ProcInfo.h b/toolkit/components/processtools/ProcInfo.h
index d7e557b42e..7fd2d7aae8 100644
--- a/toolkit/components/processtools/ProcInfo.h
+++ b/toolkit/components/processtools/ProcInfo.h
@@ -171,10 +171,10 @@ struct ProcInfoRequest {
ProcInfoRequest(base::ProcessId aPid, ProcType aProcessType,
const nsACString& aOrigin, nsTArray<WindowInfo>&& aWindowInfo,
nsTArray<UtilityInfo>&& aUtilityInfo, uint32_t aChildId = 0
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
,
mach_port_t aChildTask = 0
-#endif // XP_MACOSX
+#endif // XP_DARWIN
)
: pid(aPid),
processType(aProcessType),
@@ -182,10 +182,10 @@ struct ProcInfoRequest {
windowInfo(std::move(aWindowInfo)),
utilityInfo(std::move(aUtilityInfo)),
childId(aChildId)
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
,
childTask(aChildTask)
-#endif // XP_MACOSX
+#endif // XP_DARWIN
{
}
const base::ProcessId pid;
@@ -195,9 +195,9 @@ struct ProcInfoRequest {
const nsTArray<UtilityInfo> utilityInfo;
// If the process is a child, its child id, otherwise `0`.
const int32_t childId;
-#ifdef XP_MACOSX
+#ifdef XP_DARWIN
const mach_port_t childTask;
-#endif // XP_MACOSX
+#endif // XP_DARWIN
};
/**
diff --git a/toolkit/components/processtools/ProcInfo.mm b/toolkit/components/processtools/ProcInfo.mm
index 6c98ce81f5..68edeef81b 100644
--- a/toolkit/components/processtools/ProcInfo.mm
+++ b/toolkit/components/processtools/ProcInfo.mm
@@ -14,7 +14,6 @@
#include <cstring>
#include <unistd.h>
-#include <libproc.h>
#include <sys/sysctl.h>
#include <mach/mach.h>
#include <mach/mach_time.h>
@@ -30,18 +29,19 @@ static void GetTimeBase(mach_timebase_info_data_t* timebase) {
namespace mozilla {
nsresult GetCpuTimeSinceProcessStartInMs(uint64_t* aResult) {
- struct proc_taskinfo pti;
- if ((unsigned long)proc_pidinfo(getpid(), PROC_PIDTASKINFO, 0, &pti,
- PROC_PIDTASKINFO_SIZE) <
- PROC_PIDTASKINFO_SIZE) {
+ task_power_info_data_t task_power_info;
+ mach_msg_type_number_t count = TASK_POWER_INFO_COUNT;
+ kern_return_t kr = task_info(mach_task_self(), TASK_POWER_INFO,
+ (task_info_t)&task_power_info, &count);
+ if (kr != KERN_SUCCESS) {
return NS_ERROR_FAILURE;
}
mach_timebase_info_data_t timebase;
GetTimeBase(&timebase);
- *aResult = (pti.pti_total_user + pti.pti_total_system) * timebase.numer /
- timebase.denom / PR_NSEC_PER_MSEC;
+ *aResult = (task_power_info.total_user + task_power_info.total_system) *
+ timebase.numer / timebase.denom / PR_NSEC_PER_MSEC;
return NS_OK;
}
@@ -82,18 +82,6 @@ ProcInfoPromise::ResolveOrRejectValue GetProcInfoSync(
info.windows = std::move(request.windowInfo);
info.utilityActors = std::move(request.utilityInfo);
- struct proc_taskinfo pti;
- if ((unsigned long)proc_pidinfo(request.pid, PROC_PIDTASKINFO, 0, &pti,
- PROC_PIDTASKINFO_SIZE) <
- PROC_PIDTASKINFO_SIZE) {
- // Can't read data for this process.
- // Probably either a sandboxing issue or a race condition, e.g.
- // the process has been just been killed. Regardless, skip process.
- continue;
- }
- info.cpuTime = (pti.pti_total_user + pti.pti_total_system) *
- timebase.numer / timebase.denom;
-
mach_port_t selectedTask;
// If we did not get a task from a child process, we use mach_task_self()
if (request.childTask == MACH_PORT_NULL) {
@@ -102,12 +90,25 @@ ProcInfoPromise::ResolveOrRejectValue GetProcInfoSync(
selectedTask = request.childTask;
}
+ task_power_info_data_t task_power_info;
+ mach_msg_type_number_t count = TASK_POWER_INFO_COUNT;
+ kern_return_t kr = task_info(selectedTask, TASK_POWER_INFO,
+ (task_info_t)&task_power_info, &count);
+ if (kr != KERN_SUCCESS) {
+ // Can't read data for this process.
+ // Probably either a sandboxing issue or a race condition, e.g.
+ // the process has been just been killed. Regardless, skip process.
+ continue;
+ }
+ info.cpuTime = (task_power_info.total_user + task_power_info.total_system) *
+ timebase.numer / timebase.denom;
+
// The phys_footprint value (introduced in 10.11) of the TASK_VM_INFO data
// matches the value in the 'Memory' column of the Activity Monitor.
task_vm_info_data_t task_vm_info;
- mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
- kern_return_t kr = task_info(selectedTask, TASK_VM_INFO,
- (task_info_t)&task_vm_info, &count);
+ count = TASK_VM_INFO_COUNT;
+ kr = task_info(selectedTask, TASK_VM_INFO, (task_info_t)&task_vm_info,
+ &count);
info.memory = kr == KERN_SUCCESS ? task_vm_info.phys_footprint : 0;
// Now getting threads info
diff --git a/toolkit/components/processtools/moz.build b/toolkit/components/processtools/moz.build
index d45fe87237..ee9d07cd6d 100644
--- a/toolkit/components/processtools/moz.build
+++ b/toolkit/components/processtools/moz.build
@@ -47,7 +47,7 @@ if toolkit == "gtk" or toolkit == "android":
UNIFIED_SOURCES += ["ProcInfo_linux.cpp"]
elif toolkit == "windows":
UNIFIED_SOURCES += ["ProcInfo_win.cpp"]
-elif toolkit == "cocoa":
+elif toolkit in ("cocoa", "uikit"):
UNIFIED_SOURCES += ["ProcInfo.mm"]
include("/ipc/chromium/chromium-config.mozbuild")