| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (HasException()) | 112 if (HasException()) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 exception_ = ppapi::StringVar::StringToPPVar(message); | 115 exception_ = ppapi::StringVar::StringToPPVar(message); |
| 116 } | 116 } |
| 117 | 117 |
| 118 PepperTryCatchVar::PepperTryCatchVar(PepperPluginInstanceImpl* instance, | 118 PepperTryCatchVar::PepperTryCatchVar(PepperPluginInstanceImpl* instance, |
| 119 PP_Var* exception) | 119 PP_Var* exception) |
| 120 : PepperTryCatch(instance, V8VarConverter::kAllowObjectVars), | 120 : PepperTryCatch(instance, V8VarConverter::kAllowObjectVars), |
| 121 handle_scope_(instance_->GetIsolate()), | 121 handle_scope_(instance_->GetIsolate()), |
| 122 context_(GetContext()), |
| 122 exception_(exception), | 123 exception_(exception), |
| 123 exception_is_set_(false) { | 124 exception_is_set_(false) { |
| 124 // We switch to the plugin context. | 125 // We switch to the plugin context if it's not empty. |
| 125 v8::Handle<v8::Context> context = GetContext(); | 126 if (!context_.IsEmpty()) |
| 126 if (!context.IsEmpty()) | 127 context_->Enter(); |
| 127 context->Enter(); | |
| 128 } | 128 } |
| 129 | 129 |
| 130 PepperTryCatchVar::~PepperTryCatchVar() { | 130 PepperTryCatchVar::~PepperTryCatchVar() { |
| 131 v8::Handle<v8::Context> context = GetContext(); | 131 if (!context_.IsEmpty()) |
| 132 if (!context.IsEmpty()) | 132 context_->Exit(); |
| 133 context->Exit(); | |
| 134 } | 133 } |
| 135 | 134 |
| 136 bool PepperTryCatchVar::HasException() { | 135 bool PepperTryCatchVar::HasException() { |
| 137 if (exception_is_set_) | 136 if (exception_is_set_) |
| 138 return true; | 137 return true; |
| 139 | 138 |
| 140 std::string exception_message; | 139 std::string exception_message; |
| 141 if (GetContext().IsEmpty()) { | 140 if (GetContext().IsEmpty()) { |
| 142 exception_message = "The v8 context has been destroyed."; | 141 exception_message = "The v8 context has been destroyed."; |
| 143 } else if (try_catch_.HasCaught()) { | 142 } else if (try_catch_.HasCaught()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 157 void PepperTryCatchVar::SetException(const char* message) { | 156 void PepperTryCatchVar::SetException(const char* message) { |
| 158 if (exception_is_set_) | 157 if (exception_is_set_) |
| 159 return; | 158 return; |
| 160 | 159 |
| 161 if (exception_) | 160 if (exception_) |
| 162 *exception_ = ppapi::StringVar::StringToPPVar(message, strlen(message)); | 161 *exception_ = ppapi::StringVar::StringToPPVar(message, strlen(message)); |
| 163 exception_is_set_ = true; | 162 exception_is_set_ = true; |
| 164 } | 163 } |
| 165 | 164 |
| 166 } // namespace content | 165 } // namespace content |
| OLD | NEW |