| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/v8_value_converter_impl.h" | 5 #include "content/renderer/v8_value_converter_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 LOG(ERROR) << "Unexpected value type: " << value->GetType(); | 125 LOG(ERROR) << "Unexpected value type: " << value->GetType(); |
| 126 return v8::Null(); | 126 return v8::Null(); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array( | 130 v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array( |
| 131 const ListValue* val) const { | 131 const ListValue* val) const { |
| 132 v8::Handle<v8::Array> result(v8::Array::New(val->GetSize())); | 132 v8::Handle<v8::Array> result(v8::Array::New(val->GetSize())); |
| 133 | 133 |
| 134 for (size_t i = 0; i < val->GetSize(); ++i) { | 134 for (size_t i = 0; i < val->GetSize(); ++i) { |
| 135 Value* child = NULL; | 135 const Value* child = NULL; |
| 136 CHECK(val->Get(i, &child)); | 136 CHECK(val->Get(i, &child)); |
| 137 | 137 |
| 138 v8::Handle<v8::Value> child_v8 = ToV8ValueImpl(child); | 138 v8::Handle<v8::Value> child_v8 = ToV8ValueImpl(child); |
| 139 CHECK(!child_v8.IsEmpty()); | 139 CHECK(!child_v8.IsEmpty()); |
| 140 | 140 |
| 141 v8::TryCatch try_catch; | 141 v8::TryCatch try_catch; |
| 142 result->Set(static_cast<uint32>(i), child_v8); | 142 result->Set(static_cast<uint32>(i), child_v8); |
| 143 if (try_catch.HasCaught()) | 143 if (try_catch.HasCaught()) |
| 144 LOG(ERROR) << "Setter for index " << i << " threw an exception."; | 144 LOG(ERROR) << "Setter for index " << i << " threw an exception."; |
| 145 } | 145 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // We can avoid all bugs related to this by stripping null. | 350 // We can avoid all bugs related to this by stripping null. |
| 351 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) | 351 if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) |
| 352 continue; | 352 continue; |
| 353 | 353 |
| 354 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 354 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
| 355 child.release()); | 355 child.release()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 return result.release(); | 358 return result.release(); |
| 359 } | 359 } |
| OLD | NEW |