🎨 Minor formatting/doc changes

This commit is contained in:
Kevin Sawicki 2017-05-26 07:51:17 -07:00
parent c4e5ba6015
commit b5879b7399
5 changed files with 31 additions and 36 deletions

View file

@ -510,10 +510,10 @@ App::App(v8::Isolate* isolate) {
content::BrowserChildProcessObserver::Add(this);
base::ProcessId pid = base::GetCurrentProcId();
std::unique_ptr<atom::ProcessMetric> process_metric(
new atom::ProcessMetric(
"Browser",
pid,
base::ProcessMetrics::CreateCurrentProcessMetrics()));
new atom::ProcessMetric(
"Browser",
pid,
base::ProcessMetrics::CreateCurrentProcessMetrics()));
app_metrics_[pid] = std::move(process_metric);
Init(isolate);
}
@ -679,26 +679,20 @@ void App::OnGpuProcessCrashed(base::TerminationStatus status) {
void App::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) {
this->ChildProcessLaunched(
data.process_type,
data.handle);
ChildProcessLaunched(data.process_type, data.handle);
}
void App::BrowserChildProcessHostDisconnected(
const content::ChildProcessData& data) {
this->ChildProcessDisconnected(base::GetProcId(data.handle));
ChildProcessDisconnected(base::GetProcId(data.handle));
}
void App::RenderProcessReady(
content::RenderProcessHost* host) {
this->ChildProcessLaunched(
content::PROCESS_TYPE_RENDERER,
host->GetHandle());
void App::RenderProcessReady(content::RenderProcessHost* host) {
ChildProcessLaunched(content::PROCESS_TYPE_RENDERER, host->GetHandle());
}
void App::RenderProcessDisconnected(
content::RenderProcessHost* host) {
this->ChildProcessDisconnected(base::GetProcId(host->GetHandle()));
void App::RenderProcessDisconnected(content::RenderProcessHost* host) {
ChildProcessDisconnected(base::GetProcId(host->GetHandle()));
}
void App::ChildProcessLaunched(
@ -707,23 +701,22 @@ void App::ChildProcessLaunched(
auto pid = base::GetProcId(handle);
#if defined(OS_MACOSX)
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(
handle, content::BrowserChildProcessHost::GetPortProvider()));
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(
handle, content::BrowserChildProcessHost::GetPortProvider()));
#else
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(handle));
std::unique_ptr<base::ProcessMetrics> metrics(
base::ProcessMetrics::CreateProcessMetrics(handle));
#endif
std::unique_ptr<atom::ProcessMetric> process_metric(
new atom::ProcessMetric(
content::GetProcessTypeNameInEnglish(process_type),
pid,
std::move(metrics)));
new atom::ProcessMetric(
content::GetProcessTypeNameInEnglish(process_type),
pid,
std::move(metrics)));
app_metrics_[pid] = std::move(process_metric);
}
void App::ChildProcessDisconnected(
base::ProcessId pid) {
void App::ChildProcessDisconnected(base::ProcessId pid) {
app_metrics_.erase(pid);
}
@ -1095,9 +1088,9 @@ void App::BuildPrototype(
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration)
.SetMethod("getFileIcon", &App::GetFileIcon)
// TODO(juturu): Deprecate getAppMemoryInfo.
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics)
.SetMethod("getAppMetrics", &App::GetAppMetrics);
.SetMethod("getAppMetrics", &App::GetAppMetrics)
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
.SetMethod("getAppMemoryInfo", &App::GetAppMetrics);
}
} // namespace api

View file

@ -6,6 +6,7 @@
#define ATOM_BROWSER_API_ATOM_API_APP_H_
#include <string>
#include <utility>
#include <vector>
#include "atom/browser/api/event_emitter.h"
@ -46,7 +47,8 @@ struct ProcessMetric {
std::string type;
base::ProcessId pid;
std::unique_ptr<base::ProcessMetrics> metrics;
ProcessMetric(std::string type,
ProcessMetric(const std::string& type,
base::ProcessId pid,
std::unique_ptr<base::ProcessMetrics> metrics) {
this->type = type;

View file

@ -413,8 +413,7 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
}
}
void AtomBrowserClient::RenderProcessReady(
content::RenderProcessHost* host) {
void AtomBrowserClient::RenderProcessReady(content::RenderProcessHost* host) {
if (delegate_) {
static_cast<api::App*>(delegate_)->RenderProcessReady(host);
}

View file

@ -127,7 +127,7 @@ Returns:
Emitted when the application is activated. Various actions can trigger
this event, such as launching the application for the first time, attempting
to re-launch the application when it's already running, or clicking on the
to re-launch the application when it's already running, or clicking on the
application's dock or taskbar icon.
### Event: 'continue-activity' _macOS_
@ -762,9 +762,10 @@ Disables hardware acceleration for current app.
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.
**Note:** This method is deprecated, use `app.getAppMetrics()` instead.
### `app.getAppMetrics()`

View file

@ -535,7 +535,7 @@ describe('app module', 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()
assert.ok(appMetrics.length > 0, 'App memory info object is not > 0')
for (const {memory, pid, type, cpu} of appMetrics) {