Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed May 19, 2016
1 parent 4c1e26a commit 558e993
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions atom/renderer/atom_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,19 @@ void AtomRendererClient::DidCreateScriptContext(
}
}

void AtomRendererClient::OnReleaseContext(node::Environment* env) {
mate::EmitEvent(env->isolate(), env->process_object(), "exit");
}

void AtomRendererClient::WillReleaseScriptContext(
v8::Handle<v8::Context> context) {
node::Environment* env = node::Environment::GetCurrent(context);
mate::EmitEvent(env->isolate(), env->process_object(), "exit");
if (WebContentsPreferences::run_node()) {
node::Environment* env = node::Environment::GetCurrent(context);
if (env)
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&AtomRendererClient::OnReleaseContext,
base::Unretained(this), env));
}
}

bool AtomRendererClient::AllowPopup() {
Expand Down
6 changes: 6 additions & 0 deletions atom/renderer/atom_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ namespace extensions {
class Dispatcher;
}

namespace node {
class Environment;
}

namespace atom {

class AtomBindings;
Expand Down Expand Up @@ -80,6 +84,8 @@ class AtomRendererClient : public content::ContentRendererClient,
const GURL& first_party_for_cookies,
GURL* new_url) override;

void OnReleaseContext(node::Environment* env);

scoped_ptr<NodeBindings> node_bindings_;
scoped_ptr<AtomBindings> atom_bindings_;

Expand Down

1 comment on commit 558e993

@bbondy
Copy link
Member

@bbondy bbondy commented on 558e993 May 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.