2019-06-14 19:39:55 +00:00
|
|
|
// Copyright (c) 2019 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_PROCESS_METRIC_H_
|
|
|
|
#define SHELL_BROWSER_API_PROCESS_METRIC_H_
|
2019-06-14 19:39:55 +00:00
|
|
|
|
|
|
|
#include <memory>
|
2020-07-07 18:00:45 +00:00
|
|
|
#include <string>
|
2019-06-14 19:39:55 +00:00
|
|
|
|
|
|
|
#include "base/process/process.h"
|
|
|
|
#include "base/process/process_handle.h"
|
|
|
|
#include "base/process/process_metrics.h"
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2019-06-14 19:39:55 +00:00
|
|
|
|
2019-07-23 20:41:59 +00:00
|
|
|
#if !defined(OS_LINUX)
|
|
|
|
struct ProcessMemoryInfo {
|
|
|
|
size_t working_set_size = 0;
|
|
|
|
size_t peak_working_set_size = 0;
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
size_t private_bytes = 0;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-06-14 19:39:55 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
enum class ProcessIntegrityLevel {
|
2020-10-27 17:51:45 +00:00
|
|
|
kUnknown,
|
|
|
|
kUntrusted,
|
|
|
|
kLow,
|
|
|
|
kMedium,
|
|
|
|
kHigh,
|
2019-06-14 19:39:55 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct ProcessMetric {
|
|
|
|
int type;
|
|
|
|
base::Process process;
|
|
|
|
std::unique_ptr<base::ProcessMetrics> metrics;
|
2020-10-19 11:55:47 +00:00
|
|
|
std::string service_name;
|
2020-07-07 18:00:45 +00:00
|
|
|
std::string name;
|
2019-06-14 19:39:55 +00:00
|
|
|
|
|
|
|
ProcessMetric(int type,
|
|
|
|
base::ProcessHandle handle,
|
2020-07-07 18:00:45 +00:00
|
|
|
std::unique_ptr<base::ProcessMetrics> metrics,
|
2020-10-19 11:55:47 +00:00
|
|
|
const std::string& service_name = std::string(),
|
2020-07-07 18:00:45 +00:00
|
|
|
const std::string& name = std::string());
|
2019-06-14 19:39:55 +00:00
|
|
|
~ProcessMetric();
|
|
|
|
|
2019-07-23 20:41:59 +00:00
|
|
|
#if !defined(OS_LINUX)
|
|
|
|
ProcessMemoryInfo GetMemoryInfo() const;
|
|
|
|
#endif
|
|
|
|
|
2019-06-14 19:39:55 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
ProcessIntegrityLevel GetIntegrityLevel() const;
|
|
|
|
static bool IsSandboxed(ProcessIntegrityLevel integrity_level);
|
2020-08-12 18:33:58 +00:00
|
|
|
#elif defined(OS_MAC)
|
2019-06-14 19:39:55 +00:00
|
|
|
bool IsSandboxed() const;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2019-06-14 19:39:55 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_API_PROCESS_METRIC_H_
|