Skip to content

Commit

Permalink
feat: add utility-process-gone event to app
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Jun 30, 2020
1 parent af48762 commit bac7f6a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/api/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,26 @@ Returns:
Emitted when the renderer process unexpectedly dissapears. This is normally
because it was crashed or killed.

#### Event: 'utility-process-gone'

Returns:

* `event` Event
* `details` Object
* `reason` String - The reason the utility process is gone. Possible values:
* `clean-exit` - Process exited with an exit code of zero
* `abnormal-exit` - Process exited with a non-zero exit code
* `killed` - Process was sent a SIGTERM or otherwise killed externally
* `crashed` - Process crashed
* `oom` - Process ran out of memory
* `launch-failure` - Process never successfully launched
* `integrity-failure` - Windows code integrity checks failed
* `name` String (optional) - Name of the service hosted in the utility process.
Examples: `Audio Service`, `Content Decryption Module Service`, `Network Service`, `Video Capture`, etc.

Emitted when the utility process unexpectedly dissapears. This is normally
because it was crashed or killed.

### Event: 'accessibility-support-changed' _macOS_ _Windows_

Returns:
Expand Down
14 changes: 14 additions & 0 deletions shell/browser/api/electron_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,26 @@ void App::BrowserChildProcessCrashed(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
BrowserChildProcessCrashedOrKilled(data, info);
}

void App::BrowserChildProcessKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
ChildProcessDisconnected(base::GetProcId(data.GetProcess().Handle()));
BrowserChildProcessCrashedOrKilled(data, info);
}

void App::BrowserChildProcessCrashedOrKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) {
if (data.process_type == content::PROCESS_TYPE_UTILITY) {
v8::HandleScope handle_scope(isolate());
auto details = gin_helper::Dictionary::CreateEmpty(isolate());
details.Set("reason", info.status);
details.Set("name", data.name);
Emit("utility-process-gone", details);
}
}

void App::RenderProcessReady(content::RenderProcessHost* host) {
Expand Down
4 changes: 4 additions & 0 deletions shell/browser/api/electron_api_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class App : public ElectronBrowserClient::Delegate,
const content::ChildProcessTerminationInfo& info) override;

private:
void BrowserChildProcessCrashedOrKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info);

void SetAppPath(const base::FilePath& app_path);
void ChildProcessLaunched(int process_type, base::ProcessHandle handle);
void ChildProcessDisconnected(base::ProcessId pid);
Expand Down

0 comments on commit bac7f6a

Please sign in to comment.