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

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

Issue 635593004: PPAPI: Make V8VarConverter longer-lived (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugin_object.h" 5 #include "content/renderer/pepper/plugin_object.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 gin::ConvertFromV8(isolate, v8_object, &plugin_object)) { 64 gin::ConvertFromV8(isolate, v8_object, &plugin_object)) {
65 return plugin_object; 65 return plugin_object;
66 } 66 }
67 return NULL; 67 return NULL;
68 } 68 }
69 69
70 // static 70 // static
71 PP_Var PluginObject::Create(PepperPluginInstanceImpl* instance, 71 PP_Var PluginObject::Create(PepperPluginInstanceImpl* instance,
72 const PPP_Class_Deprecated* ppp_class, 72 const PPP_Class_Deprecated* ppp_class,
73 void* ppp_class_data) { 73 void* ppp_class_data) {
74 PepperTryCatchVar try_catch(instance, NULL); 74 V8VarConverter var_converter(instance->pp_instance(),
75 V8VarConverter::kAllowObjectVars);
76 PepperTryCatchVar try_catch(instance, &var_converter, NULL);
75 gin::Handle<PluginObject> object = 77 gin::Handle<PluginObject> object =
76 gin::CreateHandle(instance->GetIsolate(), 78 gin::CreateHandle(instance->GetIsolate(),
77 new PluginObject(instance, ppp_class, ppp_class_data)); 79 new PluginObject(instance, ppp_class, ppp_class_data));
78 ScopedPPVar result = try_catch.FromV8(object.ToV8()); 80 ScopedPPVar result = try_catch.FromV8(object.ToV8());
79 DCHECK(!try_catch.HasException()); 81 DCHECK(!try_catch.HasException());
80 return result.Release(); 82 return result.Release();
81 } 83 }
82 84
83 v8::Local<v8::Value> PluginObject::GetNamedProperty( 85 v8::Local<v8::Value> PluginObject::GetNamedProperty(
84 v8::Isolate* isolate, 86 v8::Isolate* isolate,
85 const std::string& identifier) { 87 const std::string& identifier) {
86 ScopedPPVar identifier_var(ScopedPPVar::PassRef(), 88 ScopedPPVar identifier_var(ScopedPPVar::PassRef(),
87 StringVar::StringToPPVar(identifier)); 89 StringVar::StringToPPVar(identifier));
88 return GetPropertyOrMethod(instance_->GetIsolate(), identifier_var.get()); 90 return GetPropertyOrMethod(instance_->GetIsolate(), identifier_var.get());
89 } 91 }
90 92
91 std::vector<std::string> PluginObject::EnumerateNamedProperties( 93 std::vector<std::string> PluginObject::EnumerateNamedProperties(
92 v8::Isolate* isolate) { 94 v8::Isolate* isolate) {
93 std::vector<std::string> result; 95 std::vector<std::string> result;
94 if (!instance_) 96 if (!instance_)
95 return result; 97 return result;
96 98
97 PepperTryCatchV8 try_catch(instance_, V8VarConverter::kAllowObjectVars, 99 V8VarConverter var_converter(instance_->pp_instance(),
98 isolate); 100 V8VarConverter::kAllowObjectVars);
101 PepperTryCatchV8 try_catch(instance_, &var_converter, isolate);
99 102
100 PP_Var* name_vars; 103 PP_Var* name_vars;
101 uint32_t count = 0; 104 uint32_t count = 0;
102 ppp_class_->GetAllPropertyNames(ppp_class_data_, &count, &name_vars, 105 ppp_class_->GetAllPropertyNames(ppp_class_data_, &count, &name_vars,
103 try_catch.exception()); 106 try_catch.exception());
104 ScopedPPVarArray scoped_name_vars( 107 ScopedPPVarArray scoped_name_vars(
105 ScopedPPVarArray::PassPPBMemoryAllocatedArray(), name_vars, count); 108 ScopedPPVarArray::PassPPBMemoryAllocatedArray(), name_vars, count);
106 109
107 if (try_catch.ThrowException()) 110 if (try_catch.ThrowException())
108 return result; 111 return result;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 v8::Isolate* isolate) { 143 v8::Isolate* isolate) {
141 return Wrappable<PluginObject>::GetObjectTemplateBuilder(isolate) 144 return Wrappable<PluginObject>::GetObjectTemplateBuilder(isolate)
142 .AddNamedPropertyInterceptor(); 145 .AddNamedPropertyInterceptor();
143 } 146 }
144 147
145 v8::Local<v8::Value> PluginObject::GetPropertyOrMethod(v8::Isolate* isolate, 148 v8::Local<v8::Value> PluginObject::GetPropertyOrMethod(v8::Isolate* isolate,
146 PP_Var identifier_var) { 149 PP_Var identifier_var) {
147 if (!instance_) 150 if (!instance_)
148 return v8::Local<v8::Value>(); 151 return v8::Local<v8::Value>();
149 152
150 PepperTryCatchV8 try_catch(instance_, V8VarConverter::kAllowObjectVars, 153 V8VarConverter var_converter(instance_->pp_instance(),
151 isolate); 154 V8VarConverter::kAllowObjectVars);
155 PepperTryCatchV8 try_catch(instance_, &var_converter, isolate);
152 bool has_property = 156 bool has_property =
153 ppp_class_->HasProperty(ppp_class_data_, identifier_var, 157 ppp_class_->HasProperty(ppp_class_data_, identifier_var,
154 try_catch.exception()); 158 try_catch.exception());
155 if (try_catch.ThrowException()) 159 if (try_catch.ThrowException())
156 return v8::Local<v8::Value>(); 160 return v8::Local<v8::Value>();
157 161
158 if (has_property) { 162 if (has_property) {
159 ScopedPPVar result_var(ScopedPPVar::PassRef(), 163 ScopedPPVar result_var(ScopedPPVar::PassRef(),
160 ppp_class_->GetProperty(ppp_class_data_, identifier_var, 164 ppp_class_->GetProperty(ppp_class_data_, identifier_var,
161 try_catch.exception())); 165 try_catch.exception()));
(...skipping 23 matching lines...) Expand all
185 } 189 }
186 190
187 return v8::Local<v8::Value>(); 191 return v8::Local<v8::Value>();
188 } 192 }
189 193
190 void PluginObject::Call(const std::string& identifier, 194 void PluginObject::Call(const std::string& identifier,
191 gin::Arguments* args) { 195 gin::Arguments* args) {
192 if (!instance_) 196 if (!instance_)
193 return; 197 return;
194 198
195 PepperTryCatchV8 try_catch(instance_, V8VarConverter::kAllowObjectVars, 199 V8VarConverter var_converter(instance_->pp_instance(),
196 args->isolate()); 200 V8VarConverter::kAllowObjectVars);
201 PepperTryCatchV8 try_catch(instance_, &var_converter, args->isolate());
197 ScopedPPVar identifier_var(ScopedPPVar::PassRef(), 202 ScopedPPVar identifier_var(ScopedPPVar::PassRef(),
198 StringVar::StringToPPVar(identifier)); 203 StringVar::StringToPPVar(identifier));
199 ScopedPPVarArray argument_vars(args->Length()); 204 ScopedPPVarArray argument_vars(args->Length());
200 205
201 for (uint32_t i = 0; i < argument_vars.size(); ++i) { 206 for (uint32_t i = 0; i < argument_vars.size(); ++i) {
202 v8::Handle<v8::Value> arg; 207 v8::Handle<v8::Value> arg;
203 if (!args->GetNext(&arg)) { 208 if (!args->GetNext(&arg)) {
204 NOTREACHED(); 209 NOTREACHED();
205 } 210 }
206 211
(...skipping 16 matching lines...) Expand all
223 return; 228 return;
224 229
225 v8::Handle<v8::Value> result = try_catch.ToV8(result_var.get()); 230 v8::Handle<v8::Value> result = try_catch.ToV8(result_var.get());
226 if (try_catch.ThrowException()) 231 if (try_catch.ThrowException())
227 return; 232 return;
228 233
229 args->Return(result); 234 args->Return(result);
230 } 235 }
231 236
232 } // namespace content 237 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698