OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/v8_var_converter.h" | 5 #include "content/renderer/pepper/v8_var_converter.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "content/public/renderer/renderer_ppapi_host.h" | 16 #include "content/public/renderer/renderer_ppapi_host.h" |
17 #include "content/renderer/pepper/host_array_buffer_var.h" | 17 #include "content/renderer/pepper/host_array_buffer_var.h" |
| 18 #include "content/renderer/pepper/host_globals.h" |
18 #include "content/renderer/pepper/resource_converter.h" | 19 #include "content/renderer/pepper/resource_converter.h" |
| 20 #include "content/renderer/pepper/v8object_var.h" |
19 #include "ppapi/shared_impl/array_var.h" | 21 #include "ppapi/shared_impl/array_var.h" |
20 #include "ppapi/shared_impl/dictionary_var.h" | 22 #include "ppapi/shared_impl/dictionary_var.h" |
21 #include "ppapi/shared_impl/var.h" | 23 #include "ppapi/shared_impl/var.h" |
22 #include "ppapi/shared_impl/var_tracker.h" | 24 #include "ppapi/shared_impl/var_tracker.h" |
23 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 25 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
24 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" | 26 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" |
25 | 27 |
26 using ppapi::ArrayBufferVar; | 28 using ppapi::ArrayBufferVar; |
27 using ppapi::ArrayVar; | 29 using ppapi::ArrayVar; |
28 using ppapi::DictionaryVar; | 30 using ppapi::DictionaryVar; |
29 using ppapi::ScopedPPVar; | 31 using ppapi::ScopedPPVar; |
30 using ppapi::StringVar; | 32 using ppapi::StringVar; |
| 33 using ppapi::V8ObjectVar; |
31 using std::make_pair; | 34 using std::make_pair; |
32 | 35 |
33 namespace { | 36 namespace { |
34 | 37 |
35 template <class T> | 38 template <class T> |
36 struct StackEntry { | 39 struct StackEntry { |
37 StackEntry(T v) : val(v), sentinel(false) {} | 40 StackEntry(T v) : val(v), sentinel(false) {} |
38 T val; | 41 T val; |
39 // Used to track parent nodes on the stack while traversing the graph. | 42 // Used to track parent nodes on the stack while traversing the graph. |
40 bool sentinel; | 43 bool sentinel; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 typedef base::hash_map<HashedHandle, ScopedPPVar> HandleVarMap; | 76 typedef base::hash_map<HashedHandle, ScopedPPVar> HandleVarMap; |
74 typedef base::hash_set<HashedHandle> ParentHandleSet; | 77 typedef base::hash_set<HashedHandle> ParentHandleSet; |
75 | 78 |
76 // Returns a V8 value which corresponds to a given PP_Var. If |var| is a | 79 // Returns a V8 value which corresponds to a given PP_Var. If |var| is a |
77 // reference counted PP_Var type, and it exists in |visited_ids|, the V8 value | 80 // reference counted PP_Var type, and it exists in |visited_ids|, the V8 value |
78 // associated with it in the map will be returned, otherwise a new V8 value will | 81 // associated with it in the map will be returned, otherwise a new V8 value will |
79 // be created and added to the map. |did_create| indicates whether a new v8 | 82 // be created and added to the map. |did_create| indicates whether a new v8 |
80 // value was created as a result of calling the function. | 83 // value was created as a result of calling the function. |
81 bool GetOrCreateV8Value(v8::Handle<v8::Context> context, | 84 bool GetOrCreateV8Value(v8::Handle<v8::Context> context, |
82 const PP_Var& var, | 85 const PP_Var& var, |
| 86 bool object_vars_allowed, |
83 v8::Handle<v8::Value>* result, | 87 v8::Handle<v8::Value>* result, |
84 bool* did_create, | 88 bool* did_create, |
85 VarHandleMap* visited_ids, | 89 VarHandleMap* visited_ids, |
86 ParentVarSet* parent_ids, | 90 ParentVarSet* parent_ids, |
87 ResourceConverter* resource_converter) { | 91 ResourceConverter* resource_converter) { |
88 v8::Isolate* isolate = context->GetIsolate(); | 92 v8::Isolate* isolate = context->GetIsolate(); |
89 *did_create = false; | 93 *did_create = false; |
90 | 94 |
91 if (ppapi::VarTracker::IsVarTypeRefcounted(var.type)) { | 95 if (ppapi::VarTracker::IsVarTypeRefcounted(var.type)) { |
92 if (parent_ids->count(var.value.as_id) != 0) | 96 if (parent_ids->count(var.value.as_id) != 0) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 *result = blink::WebArrayBufferConverter::toV8Value( | 147 *result = blink::WebArrayBufferConverter::toV8Value( |
144 &host_buffer->webkit_buffer(), context->Global(), isolate); | 148 &host_buffer->webkit_buffer(), context->Global(), isolate); |
145 break; | 149 break; |
146 } | 150 } |
147 case PP_VARTYPE_ARRAY: | 151 case PP_VARTYPE_ARRAY: |
148 *result = v8::Array::New(isolate); | 152 *result = v8::Array::New(isolate); |
149 break; | 153 break; |
150 case PP_VARTYPE_DICTIONARY: | 154 case PP_VARTYPE_DICTIONARY: |
151 *result = v8::Object::New(isolate); | 155 *result = v8::Object::New(isolate); |
152 break; | 156 break; |
153 case PP_VARTYPE_OBJECT: | 157 case PP_VARTYPE_OBJECT: { |
154 result->Clear(); | 158 DCHECK(object_vars_allowed); |
155 return false; | 159 scoped_refptr<V8ObjectVar> v8_object_var = V8ObjectVar::FromPPVar(var); |
| 160 if (!v8_object_var) { |
| 161 NOTREACHED(); |
| 162 result->Clear(); |
| 163 return false; |
| 164 } |
| 165 *result = v8_object_var->GetHandle(); |
| 166 break; |
| 167 } |
156 case PP_VARTYPE_RESOURCE: | 168 case PP_VARTYPE_RESOURCE: |
157 if (!resource_converter->ToV8Value(var, context, result)) { | 169 if (!resource_converter->ToV8Value(var, context, result)) { |
158 result->Clear(); | 170 result->Clear(); |
159 return false; | 171 return false; |
160 } | 172 } |
161 break; | 173 break; |
162 } | 174 } |
163 | 175 |
164 *did_create = true; | 176 *did_create = true; |
165 if (ppapi::VarTracker::IsVarTypeRefcounted(var.type)) | 177 if (ppapi::VarTracker::IsVarTypeRefcounted(var.type)) |
166 (*visited_ids)[var.value.as_id] = *result; | 178 (*visited_ids)[var.value.as_id] = *result; |
167 return true; | 179 return true; |
168 } | 180 } |
169 | 181 |
170 // For a given V8 value handle, this returns a PP_Var which corresponds to it. | 182 // For a given V8 value handle, this returns a PP_Var which corresponds to it. |
171 // If the handle already exists in |visited_handles|, the PP_Var associated with | 183 // If the handle already exists in |visited_handles|, the PP_Var associated with |
172 // it will be returned, otherwise a new V8 value will be created and added to | 184 // it will be returned, otherwise a new V8 value will be created and added to |
173 // the map. |did_create| indicates if a new PP_Var was created as a result of | 185 // the map. |did_create| indicates if a new PP_Var was created as a result of |
174 // calling the function. | 186 // calling the function. |
175 bool GetOrCreateVar(v8::Handle<v8::Value> val, | 187 bool GetOrCreateVar(v8::Handle<v8::Value> val, |
176 v8::Handle<v8::Context> context, | 188 v8::Handle<v8::Context> context, |
| 189 PP_Instance instance, |
| 190 bool object_vars_allowed, |
177 PP_Var* result, | 191 PP_Var* result, |
178 bool* did_create, | 192 bool* did_create, |
179 HandleVarMap* visited_handles, | 193 HandleVarMap* visited_handles, |
180 ParentHandleSet* parent_handles, | 194 ParentHandleSet* parent_handles, |
181 ResourceConverter* resource_converter) { | 195 ResourceConverter* resource_converter) { |
182 CHECK(!val.IsEmpty()); | 196 CHECK(!val.IsEmpty()); |
183 *did_create = false; | 197 *did_create = false; |
184 | 198 |
185 // Even though every v8 string primitive encountered will be a unique object, | 199 // Even though every v8 string primitive encountered will be a unique object, |
186 // we still add them to |visited_handles| so that the corresponding string | 200 // we still add them to |visited_handles| so that the corresponding string |
187 // PP_Var created will be properly refcounted. | 201 // PP_Var created will be properly refcounted. |
188 if (val->IsObject() || val->IsString()) { | 202 if (val->IsObject() || val->IsString()) { |
189 if (parent_handles->count(HashedHandle(val->ToObject())) != 0) | 203 if (parent_handles->count(HashedHandle(val->ToObject())) != 0) |
190 return false; | 204 return false; |
191 | 205 |
192 HandleVarMap::const_iterator it = | 206 HandleVarMap::const_iterator it = |
193 visited_handles->find(HashedHandle(val->ToObject())); | 207 visited_handles->find(HashedHandle(val->ToObject())); |
194 if (it != visited_handles->end()) { | 208 if (it != visited_handles->end()) { |
195 *result = it->second.get(); | 209 *result = it->second.get(); |
196 return true; | 210 return true; |
197 } | 211 } |
198 } | 212 } |
199 | 213 |
| 214 v8::Isolate* isolate = context->GetIsolate(); |
200 if (val->IsUndefined()) { | 215 if (val->IsUndefined()) { |
201 *result = PP_MakeUndefined(); | 216 *result = PP_MakeUndefined(); |
202 } else if (val->IsNull()) { | 217 } else if (val->IsNull()) { |
203 *result = PP_MakeNull(); | 218 *result = PP_MakeNull(); |
204 } else if (val->IsBoolean() || val->IsBooleanObject()) { | 219 } else if (val->IsBoolean() || val->IsBooleanObject()) { |
205 *result = PP_MakeBool(PP_FromBool(val->ToBoolean()->Value())); | 220 *result = PP_MakeBool(PP_FromBool(val->ToBoolean()->Value())); |
206 } else if (val->IsInt32()) { | 221 } else if (val->IsInt32()) { |
207 *result = PP_MakeInt32(val->ToInt32()->Value()); | 222 *result = PP_MakeInt32(val->ToInt32()->Value()); |
208 } else if (val->IsNumber() || val->IsNumberObject()) { | 223 } else if (val->IsNumber() || val->IsNumberObject()) { |
209 *result = PP_MakeDouble(val->ToNumber()->Value()); | 224 *result = PP_MakeDouble(val->ToNumber()->Value()); |
210 } else if (val->IsString() || val->IsStringObject()) { | 225 } else if (val->IsString() || val->IsStringObject()) { |
211 v8::String::Utf8Value utf8(val->ToString()); | 226 v8::String::Utf8Value utf8(val->ToString()); |
212 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length())); | 227 *result = StringVar::StringToPPVar(std::string(*utf8, utf8.length())); |
213 } else if (val->IsArray()) { | 228 } else if (val->IsArray()) { |
214 *result = (new ArrayVar())->GetPPVar(); | 229 *result = (new ArrayVar())->GetPPVar(); |
215 } else if (val->IsObject()) { | 230 } else if (val->IsObject()) { |
216 scoped_ptr<blink::WebArrayBuffer> web_array_buffer( | 231 scoped_ptr<blink::WebArrayBuffer> web_array_buffer( |
217 blink::WebArrayBufferConverter::createFromV8Value( | 232 blink::WebArrayBufferConverter::createFromV8Value(val, isolate)); |
218 val, context->GetIsolate())); | |
219 if (web_array_buffer.get()) { | 233 if (web_array_buffer.get()) { |
220 scoped_refptr<HostArrayBufferVar> buffer_var( | 234 scoped_refptr<HostArrayBufferVar> buffer_var( |
221 new HostArrayBufferVar(*web_array_buffer)); | 235 new HostArrayBufferVar(*web_array_buffer)); |
222 *result = buffer_var->GetPPVar(); | 236 *result = buffer_var->GetPPVar(); |
| 237 } else if (object_vars_allowed) { |
| 238 v8::Handle<v8::Object> object = val->ToObject(); |
| 239 *result = content::HostGlobals::Get()-> |
| 240 host_var_tracker()->V8ObjectVarForV8Object(instance, object); |
223 } else { | 241 } else { |
224 bool was_resource; | 242 bool was_resource; |
225 if (!resource_converter->FromV8Value( | 243 if (!resource_converter->FromV8Value( |
226 val->ToObject(), context, result, &was_resource)) | 244 val->ToObject(), context, result, &was_resource)) |
227 return false; | 245 return false; |
228 if (!was_resource) { | 246 if (!was_resource) { |
229 *result = (new DictionaryVar())->GetPPVar(); | 247 *result = (new DictionaryVar())->GetPPVar(); |
230 } | 248 } |
231 } | 249 } |
232 } else { | 250 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
245 return true; | 263 return true; |
246 } | 264 } |
247 | 265 |
248 bool CanHaveChildren(PP_Var var) { | 266 bool CanHaveChildren(PP_Var var) { |
249 return var.type == PP_VARTYPE_ARRAY || var.type == PP_VARTYPE_DICTIONARY; | 267 return var.type == PP_VARTYPE_ARRAY || var.type == PP_VARTYPE_DICTIONARY; |
250 } | 268 } |
251 | 269 |
252 } // namespace | 270 } // namespace |
253 | 271 |
254 V8VarConverter::V8VarConverter(PP_Instance instance) | 272 V8VarConverter::V8VarConverter(PP_Instance instance) |
255 : message_loop_proxy_(base::MessageLoopProxy::current()) { | 273 : instance_(instance), |
| 274 object_vars_allowed_(false), |
| 275 message_loop_proxy_(base::MessageLoopProxy::current()) { |
| 276 resource_converter_.reset(new ResourceConverterImpl( |
| 277 instance, RendererPpapiHost::GetForPPInstance(instance))); |
| 278 } |
| 279 |
| 280 V8VarConverter::V8VarConverter(PP_Instance instance, bool object_vars_allowed) |
| 281 : instance_(instance), |
| 282 object_vars_allowed_(object_vars_allowed), |
| 283 message_loop_proxy_(base::MessageLoopProxy::current()) { |
256 resource_converter_.reset(new ResourceConverterImpl( | 284 resource_converter_.reset(new ResourceConverterImpl( |
257 instance, RendererPpapiHost::GetForPPInstance(instance))); | 285 instance, RendererPpapiHost::GetForPPInstance(instance))); |
258 } | 286 } |
259 | 287 |
260 V8VarConverter::V8VarConverter(PP_Instance instance, | 288 V8VarConverter::V8VarConverter(PP_Instance instance, |
261 scoped_ptr<ResourceConverter> resource_converter) | 289 scoped_ptr<ResourceConverter> resource_converter) |
262 : message_loop_proxy_(base::MessageLoopProxy::current()), | 290 : instance_(instance), |
| 291 object_vars_allowed_(false), |
| 292 message_loop_proxy_(base::MessageLoopProxy::current()), |
263 resource_converter_(resource_converter.release()) {} | 293 resource_converter_(resource_converter.release()) {} |
264 | 294 |
265 V8VarConverter::~V8VarConverter() {} | 295 V8VarConverter::~V8VarConverter() {} |
266 | 296 |
267 // To/FromV8Value use a stack-based DFS search to traverse V8/Var graph. Each | 297 // To/FromV8Value use a stack-based DFS search to traverse V8/Var graph. Each |
268 // iteration, the top node on the stack examined. If the node has not been | 298 // iteration, the top node on the stack examined. If the node has not been |
269 // visited yet (i.e. sentinel == false) then it is added to the list of parents | 299 // visited yet (i.e. sentinel == false) then it is added to the list of parents |
270 // which contains all of the nodes on the path from the start node to the | 300 // which contains all of the nodes on the path from the start node to the |
271 // current node. Each of the current nodes children are examined. If they appear | 301 // current node. Each of the current nodes children are examined. If they appear |
272 // in the list of parents it means we have a cycle and we return NULL. | 302 // in the list of parents it means we have a cycle and we return NULL. |
(...skipping 25 matching lines...) Expand all Loading... |
298 if (CanHaveChildren(current_var)) | 328 if (CanHaveChildren(current_var)) |
299 parent_ids.erase(current_var.value.as_id); | 329 parent_ids.erase(current_var.value.as_id); |
300 continue; | 330 continue; |
301 } else { | 331 } else { |
302 stack.top().sentinel = true; | 332 stack.top().sentinel = true; |
303 } | 333 } |
304 | 334 |
305 bool did_create = false; | 335 bool did_create = false; |
306 if (!GetOrCreateV8Value(context, | 336 if (!GetOrCreateV8Value(context, |
307 current_var, | 337 current_var, |
| 338 object_vars_allowed_, |
308 ¤t_v8, | 339 ¤t_v8, |
309 &did_create, | 340 &did_create, |
310 &visited_ids, | 341 &visited_ids, |
311 &parent_ids, | 342 &parent_ids, |
312 resource_converter_.get())) { | 343 resource_converter_.get())) { |
313 return false; | 344 return false; |
314 } | 345 } |
315 | 346 |
316 if (is_root) { | 347 if (is_root) { |
317 is_root = false; | 348 is_root = false; |
318 root = current_v8; | 349 root = current_v8; |
319 } | 350 } |
320 | 351 |
321 // Add child nodes to the stack. | 352 // Add child nodes to the stack. |
322 if (current_var.type == PP_VARTYPE_ARRAY) { | 353 if (current_var.type == PP_VARTYPE_ARRAY) { |
323 parent_ids.insert(current_var.value.as_id); | 354 parent_ids.insert(current_var.value.as_id); |
324 ArrayVar* array_var = ArrayVar::FromPPVar(current_var); | 355 ArrayVar* array_var = ArrayVar::FromPPVar(current_var); |
325 if (!array_var) { | 356 if (!array_var) { |
326 NOTREACHED(); | 357 NOTREACHED(); |
327 return false; | 358 return false; |
328 } | 359 } |
329 DCHECK(current_v8->IsArray()); | 360 DCHECK(current_v8->IsArray()); |
330 v8::Handle<v8::Array> v8_array = current_v8.As<v8::Array>(); | 361 v8::Handle<v8::Array> v8_array = current_v8.As<v8::Array>(); |
331 | 362 |
332 for (size_t i = 0; i < array_var->elements().size(); ++i) { | 363 for (size_t i = 0; i < array_var->elements().size(); ++i) { |
333 const PP_Var& child_var = array_var->elements()[i].get(); | 364 const PP_Var& child_var = array_var->elements()[i].get(); |
334 v8::Handle<v8::Value> child_v8; | 365 v8::Handle<v8::Value> child_v8; |
335 if (!GetOrCreateV8Value(context, | 366 if (!GetOrCreateV8Value(context, |
336 child_var, | 367 child_var, |
| 368 object_vars_allowed_, |
337 &child_v8, | 369 &child_v8, |
338 &did_create, | 370 &did_create, |
339 &visited_ids, | 371 &visited_ids, |
340 &parent_ids, | 372 &parent_ids, |
341 resource_converter_.get())) { | 373 resource_converter_.get())) { |
342 return false; | 374 return false; |
343 } | 375 } |
344 if (did_create && CanHaveChildren(child_var)) | 376 if (did_create && CanHaveChildren(child_var)) |
345 stack.push(child_var); | 377 stack.push(child_var); |
346 v8::TryCatch try_catch; | 378 v8::TryCatch try_catch; |
(...skipping 15 matching lines...) Expand all Loading... |
362 | 394 |
363 for (DictionaryVar::KeyValueMap::const_iterator iter = | 395 for (DictionaryVar::KeyValueMap::const_iterator iter = |
364 dict_var->key_value_map().begin(); | 396 dict_var->key_value_map().begin(); |
365 iter != dict_var->key_value_map().end(); | 397 iter != dict_var->key_value_map().end(); |
366 ++iter) { | 398 ++iter) { |
367 const std::string& key = iter->first; | 399 const std::string& key = iter->first; |
368 const PP_Var& child_var = iter->second.get(); | 400 const PP_Var& child_var = iter->second.get(); |
369 v8::Handle<v8::Value> child_v8; | 401 v8::Handle<v8::Value> child_v8; |
370 if (!GetOrCreateV8Value(context, | 402 if (!GetOrCreateV8Value(context, |
371 child_var, | 403 child_var, |
| 404 object_vars_allowed_, |
372 &child_v8, | 405 &child_v8, |
373 &did_create, | 406 &did_create, |
374 &visited_ids, | 407 &visited_ids, |
375 &parent_ids, | 408 &parent_ids, |
376 resource_converter_.get())) { | 409 resource_converter_.get())) { |
377 return false; | 410 return false; |
378 } | 411 } |
379 if (did_create && CanHaveChildren(child_var)) | 412 if (did_create && CanHaveChildren(child_var)) |
380 stack.push(child_var); | 413 stack.push(child_var); |
381 v8::TryCatch try_catch; | 414 v8::TryCatch try_catch; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 if (current_v8->IsObject()) | 481 if (current_v8->IsObject()) |
449 parent_handles.erase(HashedHandle(current_v8->ToObject())); | 482 parent_handles.erase(HashedHandle(current_v8->ToObject())); |
450 continue; | 483 continue; |
451 } else { | 484 } else { |
452 stack.top().sentinel = true; | 485 stack.top().sentinel = true; |
453 } | 486 } |
454 | 487 |
455 bool did_create = false; | 488 bool did_create = false; |
456 if (!GetOrCreateVar(current_v8, | 489 if (!GetOrCreateVar(current_v8, |
457 context, | 490 context, |
| 491 instance_, |
| 492 object_vars_allowed_, |
458 ¤t_var, | 493 ¤t_var, |
459 &did_create, | 494 &did_create, |
460 &visited_handles, | 495 &visited_handles, |
461 &parent_handles, | 496 &parent_handles, |
462 resource_converter_.get())) { | 497 resource_converter_.get())) { |
463 return false; | 498 return false; |
464 } | 499 } |
465 | 500 |
466 if (is_root) { | 501 if (is_root) { |
467 is_root = false; | 502 is_root = false; |
(...skipping 17 matching lines...) Expand all Loading... |
485 v8::Handle<v8::Value> child_v8 = v8_array->Get(i); | 520 v8::Handle<v8::Value> child_v8 = v8_array->Get(i); |
486 if (try_catch.HasCaught()) | 521 if (try_catch.HasCaught()) |
487 return false; | 522 return false; |
488 | 523 |
489 if (!v8_array->HasRealIndexedProperty(i)) | 524 if (!v8_array->HasRealIndexedProperty(i)) |
490 continue; | 525 continue; |
491 | 526 |
492 PP_Var child_var; | 527 PP_Var child_var; |
493 if (!GetOrCreateVar(child_v8, | 528 if (!GetOrCreateVar(child_v8, |
494 context, | 529 context, |
| 530 instance_, |
| 531 object_vars_allowed_, |
495 &child_var, | 532 &child_var, |
496 &did_create, | 533 &did_create, |
497 &visited_handles, | 534 &visited_handles, |
498 &parent_handles, | 535 &parent_handles, |
499 resource_converter_.get())) { | 536 resource_converter_.get())) { |
500 return false; | 537 return false; |
501 } | 538 } |
502 if (did_create && child_v8->IsObject()) | 539 if (did_create && child_v8->IsObject()) |
503 stack.push(child_v8); | 540 stack.push(child_v8); |
504 | 541 |
(...skipping 29 matching lines...) Expand all Loading... |
534 v8::String::Utf8Value name_utf8(key->ToString()); | 571 v8::String::Utf8Value name_utf8(key->ToString()); |
535 | 572 |
536 v8::TryCatch try_catch; | 573 v8::TryCatch try_catch; |
537 v8::Handle<v8::Value> child_v8 = v8_object->Get(key); | 574 v8::Handle<v8::Value> child_v8 = v8_object->Get(key); |
538 if (try_catch.HasCaught()) | 575 if (try_catch.HasCaught()) |
539 return false; | 576 return false; |
540 | 577 |
541 PP_Var child_var; | 578 PP_Var child_var; |
542 if (!GetOrCreateVar(child_v8, | 579 if (!GetOrCreateVar(child_v8, |
543 context, | 580 context, |
| 581 instance_, |
| 582 object_vars_allowed_, |
544 &child_var, | 583 &child_var, |
545 &did_create, | 584 &did_create, |
546 &visited_handles, | 585 &visited_handles, |
547 &parent_handles, | 586 &parent_handles, |
548 resource_converter_.get())) { | 587 resource_converter_.get())) { |
549 return false; | 588 return false; |
550 } | 589 } |
551 if (did_create && child_v8->IsObject()) | 590 if (did_create && child_v8->IsObject()) |
552 stack.push(child_v8); | 591 stack.push(child_v8); |
553 | 592 |
554 bool success = dict_var->SetWithStringKey( | 593 bool success = dict_var->SetWithStringKey( |
555 std::string(*name_utf8, name_utf8.length()), child_var); | 594 std::string(*name_utf8, name_utf8.length()), child_var); |
556 DCHECK(success); | 595 DCHECK(success); |
557 } | 596 } |
558 } | 597 } |
559 } | 598 } |
560 *result_var = root; | 599 *result_var = root; |
561 return true; | 600 return true; |
562 } | 601 } |
563 | 602 |
564 } // namespace content | 603 } // namespace content |
OLD | NEW |