| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "bindings/core/v8/ScriptValueSerializer.h" | 5 #include "bindings/core/v8/ScriptValueSerializer.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Transferables.h" | 7 #include "bindings/core/v8/Transferables.h" |
| 8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 9 #include "bindings/core/v8/V8ArrayBufferView.h" | 9 #include "bindings/core/v8/V8ArrayBufferView.h" |
| 10 #include "bindings/core/v8/V8Blob.h" | 10 #include "bindings/core/v8/V8Blob.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 void SerializedScriptValueWriter::writeTransferredImageBitmap(uint32_t index) { | 348 void SerializedScriptValueWriter::writeTransferredImageBitmap(uint32_t index) { |
| 349 append(ImageBitmapTransferTag); | 349 append(ImageBitmapTransferTag); |
| 350 doWriteUint32(index); | 350 doWriteUint32(index); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void SerializedScriptValueWriter::writeTransferredOffscreenCanvas( | 353 void SerializedScriptValueWriter::writeTransferredOffscreenCanvas( |
| 354 uint32_t width, | 354 uint32_t width, |
| 355 uint32_t height, | 355 uint32_t height, |
| 356 uint32_t canvasId, | 356 uint32_t canvasId, |
| 357 uint32_t clientId, | 357 uint32_t clientId, |
| 358 uint32_t sinkId, |
| 358 uint32_t localId, | 359 uint32_t localId, |
| 359 uint64_t nonce) { | 360 uint64_t nonce) { |
| 360 append(OffscreenCanvasTransferTag); | 361 append(OffscreenCanvasTransferTag); |
| 361 doWriteUint32(width); | 362 doWriteUint32(width); |
| 362 doWriteUint32(height); | 363 doWriteUint32(height); |
| 363 doWriteUint32(canvasId); | 364 doWriteUint32(canvasId); |
| 364 doWriteUint32(clientId); | 365 doWriteUint32(clientId); |
| 366 doWriteUint32(sinkId); |
| 365 doWriteUint32(localId); | 367 doWriteUint32(localId); |
| 366 doWriteUint64(nonce); | 368 doWriteUint64(nonce); |
| 367 } | 369 } |
| 368 | 370 |
| 369 void SerializedScriptValueWriter::writeTransferredSharedArrayBuffer( | 371 void SerializedScriptValueWriter::writeTransferredSharedArrayBuffer( |
| 370 uint32_t index) { | 372 uint32_t index) { |
| 371 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); | 373 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); |
| 372 append(SharedArrayBufferTransferTag); | 374 append(SharedArrayBufferTransferTag); |
| 373 doWriteUint32(index); | 375 doWriteUint32(index); |
| 374 } | 376 } |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 return handleError( | 1296 return handleError( |
| 1295 Status::DataCloneError, | 1297 Status::DataCloneError, |
| 1296 "An OffscreenCanvas is detached and could not be cloned.", next); | 1298 "An OffscreenCanvas is detached and could not be cloned.", next); |
| 1297 if (offscreenCanvas->renderingContext()) | 1299 if (offscreenCanvas->renderingContext()) |
| 1298 return handleError(Status::DataCloneError, | 1300 return handleError(Status::DataCloneError, |
| 1299 "An OffscreenCanvas with a context could not be cloned.", | 1301 "An OffscreenCanvas with a context could not be cloned.", |
| 1300 next); | 1302 next); |
| 1301 m_writer.writeTransferredOffscreenCanvas( | 1303 m_writer.writeTransferredOffscreenCanvas( |
| 1302 offscreenCanvas->width(), offscreenCanvas->height(), | 1304 offscreenCanvas->width(), offscreenCanvas->height(), |
| 1303 offscreenCanvas->getAssociatedCanvasId(), offscreenCanvas->clientId(), | 1305 offscreenCanvas->getAssociatedCanvasId(), offscreenCanvas->clientId(), |
| 1304 offscreenCanvas->localId(), offscreenCanvas->nonce()); | 1306 offscreenCanvas->sinkId(), offscreenCanvas->localId(), |
| 1307 offscreenCanvas->nonce()); |
| 1305 return nullptr; | 1308 return nullptr; |
| 1306 } | 1309 } |
| 1307 | 1310 |
| 1308 ScriptValueSerializer::StateBase* | 1311 ScriptValueSerializer::StateBase* |
| 1309 ScriptValueSerializer::writeTransferredSharedArrayBuffer( | 1312 ScriptValueSerializer::writeTransferredSharedArrayBuffer( |
| 1310 v8::Local<v8::Value> value, | 1313 v8::Local<v8::Value> value, |
| 1311 uint32_t index, | 1314 uint32_t index, |
| 1312 StateBase* next) { | 1315 StateBase* next) { |
| 1313 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); | 1316 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); |
| 1314 DOMSharedArrayBuffer* sharedArrayBuffer = | 1317 DOMSharedArrayBuffer* sharedArrayBuffer = |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 uint32_t index; | 1677 uint32_t index; |
| 1675 if (!doReadUint32(&index)) | 1678 if (!doReadUint32(&index)) |
| 1676 return false; | 1679 return false; |
| 1677 if (!deserializer.tryGetTransferredImageBitmap(index, value)) | 1680 if (!deserializer.tryGetTransferredImageBitmap(index, value)) |
| 1678 return false; | 1681 return false; |
| 1679 break; | 1682 break; |
| 1680 } | 1683 } |
| 1681 case OffscreenCanvasTransferTag: { | 1684 case OffscreenCanvasTransferTag: { |
| 1682 if (!m_version) | 1685 if (!m_version) |
| 1683 return false; | 1686 return false; |
| 1684 uint32_t width, height, canvasId, clientId, localId; | 1687 uint32_t width, height, canvasId, clientId, sinkId, localId; |
| 1685 uint64_t nonce; | 1688 uint64_t nonce; |
| 1686 if (!doReadUint32(&width)) | 1689 if (!doReadUint32(&width)) |
| 1687 return false; | 1690 return false; |
| 1688 if (!doReadUint32(&height)) | 1691 if (!doReadUint32(&height)) |
| 1689 return false; | 1692 return false; |
| 1690 if (!doReadUint32(&canvasId)) | 1693 if (!doReadUint32(&canvasId)) |
| 1691 return false; | 1694 return false; |
| 1692 if (!doReadUint32(&clientId)) | 1695 if (!doReadUint32(&clientId)) |
| 1693 return false; | 1696 return false; |
| 1697 if (!doReadUint32(&sinkId)) |
| 1698 return false; |
| 1694 if (!doReadUint32(&localId)) | 1699 if (!doReadUint32(&localId)) |
| 1695 return false; | 1700 return false; |
| 1696 if (!doReadUint64(&nonce)) | 1701 if (!doReadUint64(&nonce)) |
| 1697 return false; | 1702 return false; |
| 1698 if (!deserializer.tryGetTransferredOffscreenCanvas( | 1703 if (!deserializer.tryGetTransferredOffscreenCanvas( |
| 1699 width, height, canvasId, clientId, localId, nonce, value)) | 1704 width, height, canvasId, clientId, sinkId, localId, nonce, value)) |
| 1700 return false; | 1705 return false; |
| 1701 break; | 1706 break; |
| 1702 } | 1707 } |
| 1703 case SharedArrayBufferTransferTag: { | 1708 case SharedArrayBufferTransferTag: { |
| 1704 if (!m_version) | 1709 if (!m_version) |
| 1705 return false; | 1710 return false; |
| 1706 uint32_t index; | 1711 uint32_t index; |
| 1707 if (!doReadUint32(&index)) | 1712 if (!doReadUint32(&index)) |
| 1708 return false; | 1713 return false; |
| 1709 if (!deserializer.tryGetTransferredSharedArrayBuffer(index, value)) | 1714 if (!deserializer.tryGetTransferredSharedArrayBuffer(index, value)) |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 } | 2543 } |
| 2539 *object = result; | 2544 *object = result; |
| 2540 return true; | 2545 return true; |
| 2541 } | 2546 } |
| 2542 | 2547 |
| 2543 bool ScriptValueDeserializer::tryGetTransferredOffscreenCanvas( | 2548 bool ScriptValueDeserializer::tryGetTransferredOffscreenCanvas( |
| 2544 uint32_t width, | 2549 uint32_t width, |
| 2545 uint32_t height, | 2550 uint32_t height, |
| 2546 uint32_t canvasId, | 2551 uint32_t canvasId, |
| 2547 uint32_t clientId, | 2552 uint32_t clientId, |
| 2553 uint32_t sinkId, |
| 2548 uint32_t localId, | 2554 uint32_t localId, |
| 2549 uint64_t nonce, | 2555 uint64_t nonce, |
| 2550 v8::Local<v8::Value>* object) { | 2556 v8::Local<v8::Value>* object) { |
| 2551 OffscreenCanvas* offscreenCanvas = OffscreenCanvas::create(width, height); | 2557 OffscreenCanvas* offscreenCanvas = OffscreenCanvas::create(width, height); |
| 2552 offscreenCanvas->setAssociatedCanvasId(canvasId); | 2558 offscreenCanvas->setAssociatedCanvasId(canvasId); |
| 2553 offscreenCanvas->setSurfaceId(clientId, localId, nonce); | 2559 offscreenCanvas->setSurfaceId(clientId, sinkId, localId, nonce); |
| 2554 *object = toV8(offscreenCanvas, m_reader.getScriptState()); | 2560 *object = toV8(offscreenCanvas, m_reader.getScriptState()); |
| 2555 if ((*object).IsEmpty()) | 2561 if ((*object).IsEmpty()) |
| 2556 return false; | 2562 return false; |
| 2557 return true; | 2563 return true; |
| 2558 } | 2564 } |
| 2559 | 2565 |
| 2560 bool ScriptValueDeserializer::tryGetObjectFromObjectReference( | 2566 bool ScriptValueDeserializer::tryGetObjectFromObjectReference( |
| 2561 uint32_t reference, | 2567 uint32_t reference, |
| 2562 v8::Local<v8::Value>* object) { | 2568 v8::Local<v8::Value>* object) { |
| 2563 if (reference >= m_objectPool.size()) | 2569 if (reference >= m_objectPool.size()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 m_openCompositeReferenceStack[m_openCompositeReferenceStack.size() - 1]; | 2635 m_openCompositeReferenceStack[m_openCompositeReferenceStack.size() - 1]; |
| 2630 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - | 2636 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - |
| 2631 1); | 2637 1); |
| 2632 if (objectReference >= m_objectPool.size()) | 2638 if (objectReference >= m_objectPool.size()) |
| 2633 return false; | 2639 return false; |
| 2634 *object = m_objectPool[objectReference]; | 2640 *object = m_objectPool[objectReference]; |
| 2635 return true; | 2641 return true; |
| 2636 } | 2642 } |
| 2637 | 2643 |
| 2638 } // namespace blink | 2644 } // namespace blink |
| OLD | NEW |