| OLD | NEW |
| 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 Loading... |
| 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 assume that a handle scope and context has been setup by the user of |
| 75 // this class. This is typically true because this class is used when calling |
| 76 // into the plugin from JavaScript. We want to use whatever v8 context the |
| 77 // caller is in. |
| 75 } | 78 } |
| 76 | 79 |
| 77 PepperTryCatchV8::~PepperTryCatchV8() { | 80 PepperTryCatchV8::~PepperTryCatchV8() { |
| 78 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(exception_); | 81 ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(exception_); |
| 79 } | 82 } |
| 80 | 83 |
| 81 bool PepperTryCatchV8::HasException() { | 84 bool PepperTryCatchV8::HasException() { |
| 82 return GetContext().IsEmpty() || exception_.type != PP_VARTYPE_UNDEFINED; | 85 return GetContext().IsEmpty() || exception_.type != PP_VARTYPE_UNDEFINED; |
| 83 } | 86 } |
| 84 | 87 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (exception_is_set_) { | 162 if (exception_is_set_) { |
| 160 NOTREACHED(); | 163 NOTREACHED(); |
| 161 return; | 164 return; |
| 162 } | 165 } |
| 163 if (exception_) | 166 if (exception_) |
| 164 *exception_ = ppapi::StringVar::StringToPPVar(message, strlen(message)); | 167 *exception_ = ppapi::StringVar::StringToPPVar(message, strlen(message)); |
| 165 exception_is_set_ = true; | 168 exception_is_set_ = true; |
| 166 } | 169 } |
| 167 | 170 |
| 168 } // namespace content | 171 } // namespace content |
| OLD | NEW |