Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/renderer/pepper/pepper_try_catch.cc

Issue 555583003: Always use the caller's context in PepperTryCatchV8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_try_catch.h" 5 #include "content/renderer/pepper/pepper_try_catch.h"
6 6
7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
8 #include "gin/converter.h" 8 #include "gin/converter.h"
9 #include "ppapi/shared_impl/ppapi_globals.h" 9 #include "ppapi/shared_impl/ppapi_globals.h"
10 #include "ppapi/shared_impl/var_tracker.h" 10 #include "ppapi/shared_impl/var_tracker.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 PepperTryCatchV8::PepperTryCatchV8( 64 PepperTryCatchV8::PepperTryCatchV8(
65 PepperPluginInstanceImpl* instance, 65 PepperPluginInstanceImpl* instance,
66 V8VarConverter::AllowObjectVars convert_objects, 66 V8VarConverter::AllowObjectVars convert_objects,
67 v8::Isolate* isolate) 67 v8::Isolate* isolate)
68 : PepperTryCatch(instance, convert_objects), 68 : PepperTryCatch(instance, convert_objects),
69 exception_(PP_MakeUndefined()) { 69 exception_(PP_MakeUndefined()) {
70 // Typically when using PepperTryCatchV8 we are passed an isolate. We verify 70 // Typically when using PepperTryCatchV8 we are passed an isolate. We verify
71 // that this isolate is the same as the plugin isolate. 71 // that this isolate is the same as the plugin isolate.
72 DCHECK(isolate == instance_->GetIsolate()); 72 DCHECK(isolate == instance_->GetIsolate());
73 // We assume we are already in the plugin context for PepperTryCatchV8. 73
74 DCHECK(GetContext() == isolate->GetCurrentContext()); 74 // We switch to the plugin context. We may be in a different context if we
75 // called into the plugin from a frame that differs from the plugin's frame.
dmichael (off chromium) 2014/09/09 21:38:06 d'oh... I don't think this is the right thing to
76 v8::Handle<v8::Context> context = GetContext();
77 if (!context.IsEmpty())
78 context->Enter();
75 } 79 }
76 80
77 PepperTryCatchV8::~PepperTryCatchV8() { 81 PepperTryCatchV8::~PepperTryCatchV8() {
82 v8::Handle<v8::Context> context = GetContext();
83 if (!context.IsEmpty())
84 context->Exit();
85
78 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(exception_); 86 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(exception_);
79 } 87 }
80 88
81 bool PepperTryCatchV8::HasException() { 89 bool PepperTryCatchV8::HasException() {
82 return GetContext().IsEmpty() || exception_.type != PP_VARTYPE_UNDEFINED; 90 return GetContext().IsEmpty() || exception_.type != PP_VARTYPE_UNDEFINED;
83 } 91 }
84 92
85 bool PepperTryCatchV8::ThrowException() { 93 bool PepperTryCatchV8::ThrowException() {
86 if (!HasException()) 94 if (!HasException())
87 return false; 95 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (exception_is_set_) { 167 if (exception_is_set_) {
160 NOTREACHED(); 168 NOTREACHED();
161 return; 169 return;
162 } 170 }
163 if (exception_) 171 if (exception_)
164 *exception_ = ppapi::StringVar::StringToPPVar(message, strlen(message)); 172 *exception_ = ppapi::StringVar::StringToPPVar(message, strlen(message));
165 exception_is_set_ = true; 173 exception_is_set_ = true;
166 } 174 }
167 175
168 } // namespace content 176 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698