Commit 85d12eb7 authored by raymes's avatar raymes Committed by Commit bot

Hold a handle to the v8 context in PepperTryCatchVar.

It is safer to hold a handle to v8 context in PepperTryCatchVar than to try
retrieving it again on destruction from the frame (through the plugin instance) which has
a chance of being torn down.

BUG=411445

Review URL: https://codereview.chromium.org/562763005

Cr-Commit-Position: refs/heads/master@{#294288}
parent 4db543f3
...@@ -119,18 +119,17 @@ PepperTryCatchVar::PepperTryCatchVar(PepperPluginInstanceImpl* instance, ...@@ -119,18 +119,17 @@ PepperTryCatchVar::PepperTryCatchVar(PepperPluginInstanceImpl* instance,
PP_Var* exception) PP_Var* exception)
: PepperTryCatch(instance, V8VarConverter::kAllowObjectVars), : PepperTryCatch(instance, V8VarConverter::kAllowObjectVars),
handle_scope_(instance_->GetIsolate()), handle_scope_(instance_->GetIsolate()),
context_(GetContext()),
exception_(exception), exception_(exception),
exception_is_set_(false) { exception_is_set_(false) {
// We switch to the plugin context. // We switch to the plugin context if it's not empty.
v8::Handle<v8::Context> context = GetContext(); if (!context_.IsEmpty())
if (!context.IsEmpty()) context_->Enter();
context->Enter();
} }
PepperTryCatchVar::~PepperTryCatchVar() { PepperTryCatchVar::~PepperTryCatchVar() {
v8::Handle<v8::Context> context = GetContext(); if (!context_.IsEmpty())
if (!context.IsEmpty()) context_->Exit();
context->Exit();
} }
bool PepperTryCatchVar::HasException() { bool PepperTryCatchVar::HasException() {
......
...@@ -83,6 +83,8 @@ class PepperTryCatchVar : public PepperTryCatch { ...@@ -83,6 +83,8 @@ class PepperTryCatchVar : public PepperTryCatch {
// make one for them. Note that this class is always allocated on the stack. // make one for them. Note that this class is always allocated on the stack.
v8::HandleScope handle_scope_; v8::HandleScope handle_scope_;
v8::Handle<v8::Context> context_;
v8::TryCatch try_catch_; v8::TryCatch try_catch_;
PP_Var* exception_; PP_Var* exception_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment