| 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/float_util.h" | 9 #include "base/float_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " | 210 LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " |
| 211 << "exception."; | 211 << "exception."; |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 return result; | 215 return result; |
| 216 } | 216 } |
| 217 | 217 |
| 218 v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer( | 218 v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer( |
| 219 const base::BinaryValue* value) const { | 219 const base::BinaryValue* value) const { |
| 220 WebKit::WebArrayBuffer buffer = | 220 blink::WebArrayBuffer buffer = |
| 221 WebKit::WebArrayBuffer::create(value->GetSize(), 1); | 221 blink::WebArrayBuffer::create(value->GetSize(), 1); |
| 222 memcpy(buffer.data(), value->GetBuffer(), value->GetSize()); | 222 memcpy(buffer.data(), value->GetBuffer(), value->GetSize()); |
| 223 return buffer.toV8Value(); | 223 return buffer.toV8Value(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 Value* V8ValueConverterImpl::FromV8ValueImpl( | 226 Value* V8ValueConverterImpl::FromV8ValueImpl( |
| 227 v8::Handle<v8::Value> val, | 227 v8::Handle<v8::Value> val, |
| 228 FromV8ValueState* state) const { | 228 FromV8ValueState* state) const { |
| 229 CHECK(!val.IsEmpty()); | 229 CHECK(!val.IsEmpty()); |
| 230 | 230 |
| 231 FromV8ValueState::Level state_level(state); | 231 FromV8ValueState::Level state_level(state); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 result->Append(base::Value::CreateNullValue()); | 339 result->Append(base::Value::CreateNullValue()); |
| 340 } | 340 } |
| 341 return result; | 341 return result; |
| 342 } | 342 } |
| 343 | 343 |
| 344 base::BinaryValue* V8ValueConverterImpl::FromV8Buffer( | 344 base::BinaryValue* V8ValueConverterImpl::FromV8Buffer( |
| 345 v8::Handle<v8::Value> val) const { | 345 v8::Handle<v8::Value> val) const { |
| 346 char* data = NULL; | 346 char* data = NULL; |
| 347 size_t length = 0; | 347 size_t length = 0; |
| 348 | 348 |
| 349 scoped_ptr<WebKit::WebArrayBuffer> array_buffer( | 349 scoped_ptr<blink::WebArrayBuffer> array_buffer( |
| 350 WebKit::WebArrayBuffer::createFromV8Value(val)); | 350 blink::WebArrayBuffer::createFromV8Value(val)); |
| 351 scoped_ptr<WebKit::WebArrayBufferView> view; | 351 scoped_ptr<blink::WebArrayBufferView> view; |
| 352 if (array_buffer) { | 352 if (array_buffer) { |
| 353 data = reinterpret_cast<char*>(array_buffer->data()); | 353 data = reinterpret_cast<char*>(array_buffer->data()); |
| 354 length = array_buffer->byteLength(); | 354 length = array_buffer->byteLength(); |
| 355 } else { | 355 } else { |
| 356 view.reset(WebKit::WebArrayBufferView::createFromV8Value(val)); | 356 view.reset(blink::WebArrayBufferView::createFromV8Value(val)); |
| 357 if (view) { | 357 if (view) { |
| 358 data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset(); | 358 data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset(); |
| 359 length = view->byteLength(); | 359 length = view->byteLength(); |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 | 362 |
| 363 if (data) | 363 if (data) |
| 364 return base::BinaryValue::CreateWithCopiedBuffer(data, length); | 364 return base::BinaryValue::CreateWithCopiedBuffer(data, length); |
| 365 else | 365 else |
| 366 return NULL; | 366 return NULL; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 continue; | 453 continue; |
| 454 | 454 |
| 455 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), | 455 result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), |
| 456 child.release()); | 456 child.release()); |
| 457 } | 457 } |
| 458 | 458 |
| 459 return result.release(); | 459 return result.release(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace content | 462 } // namespace content |
| OLD | NEW |