| 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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <map> | 10 #include <map> |
| 8 #include <stack> | 11 #include <stack> |
| 9 #include <string> | 12 #include <string> |
| 10 | 13 |
| 11 #include "base/bind.h" | 14 #include "base/bind.h" |
| 12 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
| 13 #include "base/location.h" | 16 #include "base/location.h" |
| 14 #include "base/logging.h" | 17 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 16 #include "content/public/renderer/renderer_ppapi_host.h" | 19 #include "content/public/renderer/renderer_ppapi_host.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 &child_v8, | 373 &child_v8, |
| 371 &did_create, | 374 &did_create, |
| 372 &visited_ids, | 375 &visited_ids, |
| 373 &parent_ids, | 376 &parent_ids, |
| 374 resource_converter_.get())) { | 377 resource_converter_.get())) { |
| 375 return false; | 378 return false; |
| 376 } | 379 } |
| 377 if (did_create && CanHaveChildren(child_var)) | 380 if (did_create && CanHaveChildren(child_var)) |
| 378 stack.push(child_var); | 381 stack.push(child_var); |
| 379 v8::TryCatch try_catch(isolate); | 382 v8::TryCatch try_catch(isolate); |
| 380 v8_array->Set(static_cast<uint32>(i), child_v8); | 383 v8_array->Set(static_cast<uint32_t>(i), child_v8); |
| 381 if (try_catch.HasCaught()) { | 384 if (try_catch.HasCaught()) { |
| 382 LOG(ERROR) << "Setter for index " << i << " threw an exception."; | 385 LOG(ERROR) << "Setter for index " << i << " threw an exception."; |
| 383 return false; | 386 return false; |
| 384 } | 387 } |
| 385 } | 388 } |
| 386 } else if (current_var.type == PP_VARTYPE_DICTIONARY) { | 389 } else if (current_var.type == PP_VARTYPE_DICTIONARY) { |
| 387 parent_ids.insert(current_var.value.as_id); | 390 parent_ids.insert(current_var.value.as_id); |
| 388 DictionaryVar* dict_var = DictionaryVar::FromPPVar(current_var); | 391 DictionaryVar* dict_var = DictionaryVar::FromPPVar(current_var); |
| 389 if (!dict_var) { | 392 if (!dict_var) { |
| 390 NOTREACHED(); | 393 NOTREACHED(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 DCHECK(current_v8->IsArray()); | 512 DCHECK(current_v8->IsArray()); |
| 510 v8::Local<v8::Array> v8_array = current_v8.As<v8::Array>(); | 513 v8::Local<v8::Array> v8_array = current_v8.As<v8::Array>(); |
| 511 parent_handles.insert(HashedHandle(v8_array)); | 514 parent_handles.insert(HashedHandle(v8_array)); |
| 512 | 515 |
| 513 ArrayVar* array_var = ArrayVar::FromPPVar(current_var); | 516 ArrayVar* array_var = ArrayVar::FromPPVar(current_var); |
| 514 if (!array_var) { | 517 if (!array_var) { |
| 515 NOTREACHED(); | 518 NOTREACHED(); |
| 516 return false; | 519 return false; |
| 517 } | 520 } |
| 518 | 521 |
| 519 for (uint32 i = 0; i < v8_array->Length(); ++i) { | 522 for (uint32_t i = 0; i < v8_array->Length(); ++i) { |
| 520 v8::TryCatch try_catch(context->GetIsolate()); | 523 v8::TryCatch try_catch(context->GetIsolate()); |
| 521 v8::Local<v8::Value> child_v8 = v8_array->Get(i); | 524 v8::Local<v8::Value> child_v8 = v8_array->Get(i); |
| 522 if (try_catch.HasCaught()) | 525 if (try_catch.HasCaught()) |
| 523 return false; | 526 return false; |
| 524 | 527 |
| 525 if (!v8_array->HasRealIndexedProperty(i)) | 528 if (!v8_array->HasRealIndexedProperty(i)) |
| 526 continue; | 529 continue; |
| 527 | 530 |
| 528 PP_Var child_var; | 531 PP_Var child_var; |
| 529 if (!GetOrCreateVar(child_v8, | 532 if (!GetOrCreateVar(child_v8, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 547 v8::Local<v8::Object> v8_object = current_v8.As<v8::Object>(); | 550 v8::Local<v8::Object> v8_object = current_v8.As<v8::Object>(); |
| 548 parent_handles.insert(HashedHandle(v8_object)); | 551 parent_handles.insert(HashedHandle(v8_object)); |
| 549 | 552 |
| 550 DictionaryVar* dict_var = DictionaryVar::FromPPVar(current_var); | 553 DictionaryVar* dict_var = DictionaryVar::FromPPVar(current_var); |
| 551 if (!dict_var) { | 554 if (!dict_var) { |
| 552 NOTREACHED(); | 555 NOTREACHED(); |
| 553 return false; | 556 return false; |
| 554 } | 557 } |
| 555 | 558 |
| 556 v8::Local<v8::Array> property_names(v8_object->GetOwnPropertyNames()); | 559 v8::Local<v8::Array> property_names(v8_object->GetOwnPropertyNames()); |
| 557 for (uint32 i = 0; i < property_names->Length(); ++i) { | 560 for (uint32_t i = 0; i < property_names->Length(); ++i) { |
| 558 v8::Local<v8::Value> key(property_names->Get(i)); | 561 v8::Local<v8::Value> key(property_names->Get(i)); |
| 559 | 562 |
| 560 // Extend this test to cover more types as necessary and if sensible. | 563 // Extend this test to cover more types as necessary and if sensible. |
| 561 if (!key->IsString() && !key->IsNumber()) { | 564 if (!key->IsString() && !key->IsNumber()) { |
| 562 NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) | 565 NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) |
| 563 << "\" " | 566 << "\" " |
| 564 "is neither a string nor a number"; | 567 "is neither a string nor a number"; |
| 565 return false; | 568 return false; |
| 566 } | 569 } |
| 567 | 570 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 597 std::string(*name_utf8, name_utf8.length()), child_var); | 600 std::string(*name_utf8, name_utf8.length()), child_var); |
| 598 DCHECK(success); | 601 DCHECK(success); |
| 599 } | 602 } |
| 600 } | 603 } |
| 601 } | 604 } |
| 602 *result_var = root; | 605 *result_var = root; |
| 603 return true; | 606 return true; |
| 604 } | 607 } |
| 605 | 608 |
| 606 } // namespace content | 609 } // namespace content |
| OLD | NEW |