🎨 Minor formatting/doc changes
This commit is contained in:
parent
c4e5ba6015
commit
b5879b7399
5 changed files with 31 additions and 36 deletions
|
@ -679,26 +679,20 @@ void App::OnGpuProcessCrashed(base::TerminationStatus status) {
|
||||||
|
|
||||||
void App::BrowserChildProcessLaunchedAndConnected(
|
void App::BrowserChildProcessLaunchedAndConnected(
|
||||||
const content::ChildProcessData& data) {
|
const content::ChildProcessData& data) {
|
||||||
this->ChildProcessLaunched(
|
ChildProcessLaunched(data.process_type, data.handle);
|
||||||
data.process_type,
|
|
||||||
data.handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::BrowserChildProcessHostDisconnected(
|
void App::BrowserChildProcessHostDisconnected(
|
||||||
const content::ChildProcessData& data) {
|
const content::ChildProcessData& data) {
|
||||||
this->ChildProcessDisconnected(base::GetProcId(data.handle));
|
ChildProcessDisconnected(base::GetProcId(data.handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::RenderProcessReady(
|
void App::RenderProcessReady(content::RenderProcessHost* host) {
|
||||||
content::RenderProcessHost* host) {
|
ChildProcessLaunched(content::PROCESS_TYPE_RENDERER, host->GetHandle());
|
||||||
this->ChildProcessLaunched(
|
|
||||||
content::PROCESS_TYPE_RENDERER,
|
|
||||||
host->GetHandle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::RenderProcessDisconnected(
|
void App::RenderProcessDisconnected(content::RenderProcessHost* host) {
|
||||||
content::RenderProcessHost* host) {
|
ChildProcessDisconnected(base::GetProcId(host->GetHandle()));
|
||||||
this->ChildProcessDisconnected(base::GetProcId(host->GetHandle()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::ChildProcessLaunched(
|
void App::ChildProcessLaunched(
|
||||||
|
@ -722,8 +716,7 @@ void App::ChildProcessLaunched(
|
||||||
app_metrics_[pid] = std::move(process_metric);
|
app_metrics_[pid] = std::move(process_metric);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::ChildProcessDisconnected(
|
void App::ChildProcessDisconnected(base::ProcessId pid) {
|
||||||
base::ProcessId pid) {
|
|
||||||
app_metrics_.erase(pid);
|
app_metrics_.erase(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,9 +1088,9 @@ void App::BuildPrototype(
|
||||||
.SetMethod("disableHardwareAcceleration",
|
.SetMethod("disableHardwareAcceleration",
|
||||||
&App::DisableHardwareAcceleration)
|
&App::DisableHardwareAcceleration)
|
||||||
.SetMethod("getFileIcon", &App::GetFileIcon)
|
.SetMethod("getFileIcon", &App::GetFileIcon)
|
||||||
// TODO(juturu): Deprecate getAppMemoryInfo.
|
.SetMethod("getAppMetrics", &App::GetAppMetrics)
|
||||||
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics)
|
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
|
||||||
.SetMethod("getAppMetrics", &App::GetAppMetrics);
|
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define ATOM_BROWSER_API_ATOM_API_APP_H_
|
#define ATOM_BROWSER_API_ATOM_API_APP_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/browser/api/event_emitter.h"
|
#include "atom/browser/api/event_emitter.h"
|
||||||
|
@ -46,7 +47,8 @@ struct ProcessMetric {
|
||||||
std::string type;
|
std::string type;
|
||||||
base::ProcessId pid;
|
base::ProcessId pid;
|
||||||
std::unique_ptr<base::ProcessMetrics> metrics;
|
std::unique_ptr<base::ProcessMetrics> metrics;
|
||||||
ProcessMetric(std::string type,
|
|
||||||
|
ProcessMetric(const std::string& type,
|
||||||
base::ProcessId pid,
|
base::ProcessId pid,
|
||||||
std::unique_ptr<base::ProcessMetrics> metrics) {
|
std::unique_ptr<base::ProcessMetrics> metrics) {
|
||||||
this->type = type;
|
this->type = type;
|
||||||
|
|
|
@ -413,8 +413,7 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::RenderProcessReady(
|
void AtomBrowserClient::RenderProcessReady(content::RenderProcessHost* host) {
|
||||||
content::RenderProcessHost* host) {
|
|
||||||
if (delegate_) {
|
if (delegate_) {
|
||||||
static_cast<api::App*>(delegate_)->RenderProcessReady(host);
|
static_cast<api::App*>(delegate_)->RenderProcessReady(host);
|
||||||
}
|
}
|
||||||
|
|
|
@ -762,9 +762,10 @@ Disables hardware acceleration for current app.
|
||||||
|
|
||||||
This method can only be called before app is ready.
|
This method can only be called before app is ready.
|
||||||
|
|
||||||
### `app.getAppMemoryInfo()` _Deprecate_
|
### `app.getAppMemoryInfo()` _Deprecated_
|
||||||
|
|
||||||
Returns [ProcessMetric[]](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and cpu usage statistics of all the processes associated with the app.
|
Returns [ProcessMetric[]](structures/process-metric.md): Array of `ProcessMetric` objects that correspond to memory and cpu usage statistics of all the processes associated with the app.
|
||||||
|
**Note:** This method is deprecated, use `app.getAppMetrics()` instead.
|
||||||
|
|
||||||
### `app.getAppMetrics()`
|
### `app.getAppMetrics()`
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ describe('app module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('getAppMetrics() API', function () {
|
describe('getAppMetrics() API', function () {
|
||||||
it('returns the process memory of all running electron processes', function () {
|
it('returns memory and cpu stats of all running electron processes', function () {
|
||||||
const appMetrics = app.getAppMetrics()
|
const appMetrics = app.getAppMetrics()
|
||||||
assert.ok(appMetrics.length > 0, 'App memory info object is not > 0')
|
assert.ok(appMetrics.length > 0, 'App memory info object is not > 0')
|
||||||
for (const {memory, pid, type, cpu} of appMetrics) {
|
for (const {memory, pid, type, cpu} of appMetrics) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue