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,
PP_Var* exception)
: PepperTryCatch(instance, V8VarConverter::kAllowObjectVars),
handle_scope_(instance_->GetIsolate()),
context_(GetContext()),
exception_(exception),
exception_is_set_(false) {
// We switch to the plugin context.
v8::Handle<v8::Context> context = GetContext();
if (!context.IsEmpty())
context->Enter();
// We switch to the plugin context if it's not empty.
if (!context_.IsEmpty())
context_->Enter();
}
PepperTryCatchVar::~PepperTryCatchVar() {
v8::Handle<v8::Context> context = GetContext();
if (!context.IsEmpty())
context->Exit();
if (!context_.IsEmpty())
context_->Exit();
}
bool PepperTryCatchVar::HasException() {
......
......@@ -83,6 +83,8 @@ class PepperTryCatchVar : public PepperTryCatch {
// make one for them. Note that this class is always allocated on the stack.
v8::HandleScope handle_scope_;
v8::Handle<v8::Context> context_;
v8::TryCatch try_catch_;
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