Add null guards

This commit is contained in:
Kevin Sawicki 2016-12-08 13:03:39 -08:00
parent 08b203fed1
commit cdf33ff3dc

View file

@ -15,16 +15,15 @@ node::Environment* AtomIsolatedWorld::env_ = nullptr;
AtomIsolatedWorld::AtomIsolatedWorld(NodeBindings* node_bindings) :
v8::Extension("AtomIsolatedWorld", "native function SetupNode();") {
node_bindings_ = node_bindings;
env_ = nullptr;
}
AtomIsolatedWorld::~AtomIsolatedWorld() {
node_bindings_ = nullptr;
env_ = nullptr;
}
node::Environment* AtomIsolatedWorld::CreateEnvironment(
content::RenderFrame* frame) {
env_ = nullptr;
blink::WebScriptSource source("SetupNode()");
frame->GetWebFrame()->executeScriptInIsolatedWorld(
1,
@ -46,6 +45,7 @@ v8::Local<v8::FunctionTemplate> AtomIsolatedWorld::GetNativeFunctionTemplate(
// static
void AtomIsolatedWorld::SetupNode(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (node_bindings_ != nullptr)
env_ = node_bindings_->CreateEnvironment(
args.GetIsolate()->GetCurrentContext());
}