| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/core/v8/custom/V8BlobCustomHelpers.h" | 32 #include "bindings/core/v8/custom/V8BlobCustomHelpers.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/Dictionary.h" | 34 #include "bindings/core/v8/Dictionary.h" |
| 35 #include "bindings/core/v8/ExceptionState.h" | 35 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 37 #include "bindings/core/v8/V8ArrayBufferView.h" |
| 36 #include "bindings/core/v8/V8Binding.h" | 38 #include "bindings/core/v8/V8Binding.h" |
| 37 #include "bindings/core/v8/V8Blob.h" | 39 #include "bindings/core/v8/V8Blob.h" |
| 38 #include "bindings/core/v8/custom/V8ArrayBufferCustom.h" | 40 #include "core/dom/ExceptionCode.h" |
| 39 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" | |
| 40 #include "wtf/DateMath.h" | 41 #include "wtf/DateMath.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 namespace V8BlobCustomHelpers { | 45 namespace V8BlobCustomHelpers { |
| 45 | 46 |
| 46 ParsedProperties::ParsedProperties(bool hasFileProperties) | 47 ParsedProperties::ParsedProperties(bool hasFileProperties) |
| 47 : m_normalizeLineEndingsToNative(false) | 48 : m_normalizeLineEndingsToNative(false) |
| 48 , m_hasFileProperties(hasFileProperties) | 49 , m_hasFileProperties(hasFileProperties) |
| 49 #if ENABLE(ASSERT) | 50 #if ENABLE(ASSERT) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 { | 111 { |
| 111 // FIXME: handle sequences based on ES6 @@iterator, see http://crbug.com/393
866 | 112 // FIXME: handle sequences based on ES6 @@iterator, see http://crbug.com/393
866 |
| 112 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(blobParts); | 113 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(blobParts); |
| 113 uint32_t length = v8::Local<v8::Array>::Cast(blobParts)->Length(); | 114 uint32_t length = v8::Local<v8::Array>::Cast(blobParts)->Length(); |
| 114 for (uint32_t i = 0; i < length; ++i) { | 115 for (uint32_t i = 0; i < length; ++i) { |
| 115 v8::Local<v8::Value> item = array->Get(i); | 116 v8::Local<v8::Value> item = array->Get(i); |
| 116 if (item.IsEmpty()) | 117 if (item.IsEmpty()) |
| 117 return false; | 118 return false; |
| 118 | 119 |
| 119 if (V8ArrayBuffer::hasInstance(item, isolate)) { | 120 if (V8ArrayBuffer::hasInstance(item, isolate)) { |
| 120 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(v8::Handle<v8::Obje
ct>::Cast(item)); | 121 DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(v8::Handle<v8::O
bject>::Cast(item)); |
| 121 ASSERT(arrayBuffer); | 122 ASSERT(arrayBuffer); |
| 122 blobData.appendArrayBuffer(arrayBuffer); | 123 blobData.appendArrayBuffer(arrayBuffer->buffer()); |
| 123 } else if (V8ArrayBufferView::hasInstance(item, isolate)) { | 124 } else if (V8ArrayBufferView::hasInstance(item, isolate)) { |
| 124 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(v8::Han
dle<v8::Object>::Cast(item)); | 125 DOMArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(v8::
Handle<v8::Object>::Cast(item)); |
| 125 ASSERT(arrayBufferView); | 126 ASSERT(arrayBufferView); |
| 126 blobData.appendArrayBufferView(arrayBufferView); | 127 blobData.appendArrayBufferView(arrayBufferView->view()); |
| 127 } else if (V8Blob::hasInstance(item, isolate)) { | 128 } else if (V8Blob::hasInstance(item, isolate)) { |
| 128 Blob* blob = V8Blob::toImpl(v8::Handle<v8::Object>::Cast(item)); | 129 Blob* blob = V8Blob::toImpl(v8::Handle<v8::Object>::Cast(item)); |
| 129 ASSERT(blob); | 130 ASSERT(blob); |
| 130 blob->appendTo(blobData); | 131 blob->appendTo(blobData); |
| 131 } else { | 132 } else { |
| 132 TOSTRING_DEFAULT(V8StringResource<>, stringValue, item, false); | 133 TOSTRING_DEFAULT(V8StringResource<>, stringValue, item, false); |
| 133 blobData.appendText(stringValue, normalizeLineEndingsToNative); | 134 blobData.appendText(stringValue, normalizeLineEndingsToNative); |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 return true; | 137 return true; |
| 137 } | 138 } |
| 138 | 139 |
| 139 } // namespace V8BlobCustomHelpers | 140 } // namespace V8BlobCustomHelpers |
| 140 | 141 |
| 141 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |