| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 16 matching lines...) Expand all Loading... |
| 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 "bindings/core/v8/SerializedScriptValue.h" | 31 #include "bindings/core/v8/SerializedScriptValue.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/DOMDataStore.h" | 33 #include "bindings/core/v8/DOMDataStore.h" |
| 34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/core/v8/ExceptionState.h" | 35 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "bindings/core/v8/ScriptState.h" | 36 #include "bindings/core/v8/ScriptState.h" |
| 37 #include "bindings/core/v8/ScriptValueSerializer.h" | |
| 38 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 37 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 39 #include "bindings/core/v8/Transferables.h" | 38 #include "bindings/core/v8/Transferables.h" |
| 40 #include "bindings/core/v8/V8ArrayBuffer.h" | 39 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 41 #include "bindings/core/v8/V8ImageBitmap.h" | 40 #include "bindings/core/v8/V8ImageBitmap.h" |
| 42 #include "bindings/core/v8/V8MessagePort.h" | 41 #include "bindings/core/v8/V8MessagePort.h" |
| 43 #include "bindings/core/v8/V8OffscreenCanvas.h" | 42 #include "bindings/core/v8/V8OffscreenCanvas.h" |
| 44 #include "bindings/core/v8/V8SharedArrayBuffer.h" | 43 #include "bindings/core/v8/V8SharedArrayBuffer.h" |
| 45 #include "core/dom/DOMArrayBuffer.h" | 44 #include "core/dom/DOMArrayBuffer.h" |
| 46 #include "core/dom/DOMSharedArrayBuffer.h" | 45 #include "core/dom/DOMSharedArrayBuffer.h" |
| 47 #include "core/dom/ExceptionCode.h" | 46 #include "core/dom/ExceptionCode.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper)); | 197 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper)); |
| 199 } | 198 } |
| 200 } else { | 199 } else { |
| 201 v8::Local<v8::Object> wrapper = | 200 v8::Local<v8::Object> wrapper = |
| 202 DOMWrapperWorld::current(isolate).domDataStore().get(object, isolate); | 201 DOMWrapperWorld::current(isolate).domDataStore().get(object, isolate); |
| 203 if (!wrapper.IsEmpty()) | 202 if (!wrapper.IsEmpty()) |
| 204 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper)); | 203 buffers.push_back(v8::Local<v8::ArrayBuffer>::Cast(wrapper)); |
| 205 } | 204 } |
| 206 } | 205 } |
| 207 | 206 |
| 208 std::unique_ptr<ImageBitmapContentsArray> | 207 std::unique_ptr<SerializedScriptValue::ImageBitmapContentsArray> |
| 209 SerializedScriptValue::transferImageBitmapContents( | 208 SerializedScriptValue::transferImageBitmapContents( |
| 210 v8::Isolate* isolate, | 209 v8::Isolate* isolate, |
| 211 const ImageBitmapArray& imageBitmaps, | 210 const ImageBitmapArray& imageBitmaps, |
| 212 ExceptionState& exceptionState) { | 211 ExceptionState& exceptionState) { |
| 213 if (!imageBitmaps.size()) | 212 if (!imageBitmaps.size()) |
| 214 return nullptr; | 213 return nullptr; |
| 215 | 214 |
| 216 for (size_t i = 0; i < imageBitmaps.size(); ++i) { | 215 for (size_t i = 0; i < imageBitmaps.size(); ++i) { |
| 217 if (imageBitmaps[i]->isNeutered()) { | 216 if (imageBitmaps[i]->isNeutered()) { |
| 218 exceptionState.throwDOMException( | 217 exceptionState.throwDOMException( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 transferables.offscreenCanvases.push_back(offscreenCanvas); | 383 transferables.offscreenCanvases.push_back(offscreenCanvas); |
| 385 } else { | 384 } else { |
| 386 exceptionState.throwTypeError("Value at index " + String::number(i) + | 385 exceptionState.throwTypeError("Value at index " + String::number(i) + |
| 387 " does not have a transferable type."); | 386 " does not have a transferable type."); |
| 388 return false; | 387 return false; |
| 389 } | 388 } |
| 390 } | 389 } |
| 391 return true; | 390 return true; |
| 392 } | 391 } |
| 393 | 392 |
| 394 std::unique_ptr<ArrayBufferContentsArray> | 393 std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray> |
| 395 SerializedScriptValue::transferArrayBufferContents( | 394 SerializedScriptValue::transferArrayBufferContents( |
| 396 v8::Isolate* isolate, | 395 v8::Isolate* isolate, |
| 397 const ArrayBufferArray& arrayBuffers, | 396 const ArrayBufferArray& arrayBuffers, |
| 398 ExceptionState& exceptionState) { | 397 ExceptionState& exceptionState) { |
| 399 if (!arrayBuffers.size()) | 398 if (!arrayBuffers.size()) |
| 400 return nullptr; | 399 return nullptr; |
| 401 | 400 |
| 402 for (auto it = arrayBuffers.begin(); it != arrayBuffers.end(); ++it) { | 401 for (auto it = arrayBuffers.begin(); it != arrayBuffers.end(); ++it) { |
| 403 DOMArrayBufferBase* arrayBuffer = *it; | 402 DOMArrayBufferBase* arrayBuffer = *it; |
| 404 if (arrayBuffer->isNeutered()) { | 403 if (arrayBuffer->isNeutered()) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { | 461 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { |
| 463 if (m_externallyAllocatedMemory) | 462 if (m_externallyAllocatedMemory) |
| 464 return; | 463 return; |
| 465 | 464 |
| 466 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); | 465 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); |
| 467 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 466 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
| 468 m_externallyAllocatedMemory); | 467 m_externallyAllocatedMemory); |
| 469 } | 468 } |
| 470 | 469 |
| 471 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |