feat: add name to app.getAppMetrics() output (#24359)

This commit is contained in:
Milan Burda 2020-07-07 20:00:45 +02:00 committed by GitHub
parent 25a36a43c1
commit 7fd96cd188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 6 deletions

View file

@ -790,7 +790,8 @@ void App::OnGpuProcessCrashed(base::TerminationStatus status) {
void App::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) {
ChildProcessLaunched(data.process_type, data.GetProcess().Handle());
ChildProcessLaunched(data.process_type, data.GetProcess().Handle(),
base::UTF16ToUTF8(data.name));
}
void App::BrowserChildProcessHostDisconnected(
@ -830,7 +831,9 @@ void App::RenderProcessDisconnected(base::ProcessId host_pid) {
ChildProcessDisconnected(host_pid);
}
void App::ChildProcessLaunched(int process_type, base::ProcessHandle handle) {
void App::ChildProcessLaunched(int process_type,
base::ProcessHandle handle,
const std::string& name) {
auto pid = base::GetProcId(handle);
#if defined(OS_MACOSX)
@ -840,7 +843,7 @@ void App::ChildProcessLaunched(int process_type, base::ProcessHandle handle) {
auto metrics = base::ProcessMetrics::CreateProcessMetrics(handle);
#endif
app_metrics_[pid] = std::make_unique<electron::ProcessMetric>(
process_type, handle, std::move(metrics));
process_type, handle, std::move(metrics), name);
}
void App::ChildProcessDisconnected(base::ProcessId pid) {
@ -1281,6 +1284,10 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
pid_dict.Set("creationTime",
process_metric.second->process.CreationTime().ToJsTime());
if (!process_metric.second->name.empty()) {
pid_dict.Set("name", process_metric.second->name);
}
#if !defined(OS_LINUX)
auto memory_info = process_metric.second->GetMemoryInfo();