refactor: simplify child process tracking for app.getAppMetrics() (#26657)

This commit is contained in:
Milan Burda 2020-12-01 02:47:46 +01:00 committed by GitHub
parent 61f339d3aa
commit 4e3e3d414d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 27 deletions

View file

@ -5,9 +5,9 @@
#ifndef SHELL_BROWSER_API_ELECTRON_API_APP_H_
#define SHELL_BROWSER_API_ELECTRON_API_APP_H_
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
@ -74,7 +74,7 @@ class App : public ElectronBrowserClient::Delegate,
base::FilePath GetAppPath() const;
void RenderProcessReady(content::RenderProcessHost* host);
void RenderProcessDisconnected(base::ProcessId host_pid);
void RenderProcessExited(content::RenderProcessHost* host);
App();
@ -167,10 +167,11 @@ class App : public ElectronBrowserClient::Delegate,
void SetAppPath(const base::FilePath& app_path);
void ChildProcessLaunched(int process_type,
int pid,
base::ProcessHandle handle,
const std::string& service_name = std::string(),
const std::string& name = std::string());
void ChildProcessDisconnected(base::ProcessId pid);
void ChildProcessDisconnected(int pid);
void SetAppLogsPath(gin_helper::ErrorThrower thrower,
base::Optional<base::FilePath> custom_path);
@ -250,8 +251,7 @@ class App : public ElectronBrowserClient::Delegate,
base::FilePath app_path_;
using ProcessMetricMap =
std::unordered_map<base::ProcessId,
std::unique_ptr<electron::ProcessMetric>>;
std::map<int, std::unique_ptr<electron::ProcessMetric>>;
ProcessMetricMap app_metrics_;
bool disable_hw_acceleration_ = false;