| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 sinkId, |
| 359 uint32_t localId, | 359 uint32_t localId, |
| 360 uint64_t nonce) { | 360 uint64_t nonceHigh, |
| 361 uint64_t nonceLow) { |
| 361 append(OffscreenCanvasTransferTag); | 362 append(OffscreenCanvasTransferTag); |
| 362 doWriteUint32(width); | 363 doWriteUint32(width); |
| 363 doWriteUint32(height); | 364 doWriteUint32(height); |
| 364 doWriteUint32(canvasId); | 365 doWriteUint32(canvasId); |
| 365 doWriteUint32(clientId); | 366 doWriteUint32(clientId); |
| 366 doWriteUint32(sinkId); | 367 doWriteUint32(sinkId); |
| 367 doWriteUint32(localId); | 368 doWriteUint32(localId); |
| 368 doWriteUint64(nonce); | 369 doWriteUint64(nonceHigh); |
| 370 doWriteUint64(nonceLow); |
| 369 } | 371 } |
| 370 | 372 |
| 371 void SerializedScriptValueWriter::writeTransferredSharedArrayBuffer( | 373 void SerializedScriptValueWriter::writeTransferredSharedArrayBuffer( |
| 372 uint32_t index) { | 374 uint32_t index) { |
| 373 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); | 375 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); |
| 374 append(SharedArrayBufferTransferTag); | 376 append(SharedArrayBufferTransferTag); |
| 375 doWriteUint32(index); | 377 doWriteUint32(index); |
| 376 } | 378 } |
| 377 | 379 |
| 378 void SerializedScriptValueWriter::writeObjectReference(uint32_t reference) { | 380 void SerializedScriptValueWriter::writeObjectReference(uint32_t reference) { |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 Status::DataCloneError, | 1299 Status::DataCloneError, |
| 1298 "An OffscreenCanvas is detached and could not be cloned.", next); | 1300 "An OffscreenCanvas is detached and could not be cloned.", next); |
| 1299 if (offscreenCanvas->renderingContext()) | 1301 if (offscreenCanvas->renderingContext()) |
| 1300 return handleError(Status::DataCloneError, | 1302 return handleError(Status::DataCloneError, |
| 1301 "An OffscreenCanvas with a context could not be cloned.", | 1303 "An OffscreenCanvas with a context could not be cloned.", |
| 1302 next); | 1304 next); |
| 1303 m_writer.writeTransferredOffscreenCanvas( | 1305 m_writer.writeTransferredOffscreenCanvas( |
| 1304 offscreenCanvas->width(), offscreenCanvas->height(), | 1306 offscreenCanvas->width(), offscreenCanvas->height(), |
| 1305 offscreenCanvas->getAssociatedCanvasId(), offscreenCanvas->clientId(), | 1307 offscreenCanvas->getAssociatedCanvasId(), offscreenCanvas->clientId(), |
| 1306 offscreenCanvas->sinkId(), offscreenCanvas->localId(), | 1308 offscreenCanvas->sinkId(), offscreenCanvas->localId(), |
| 1307 offscreenCanvas->nonce()); | 1309 offscreenCanvas->nonceHigh(), offscreenCanvas->nonceLow()); |
| 1308 return nullptr; | 1310 return nullptr; |
| 1309 } | 1311 } |
| 1310 | 1312 |
| 1311 ScriptValueSerializer::StateBase* | 1313 ScriptValueSerializer::StateBase* |
| 1312 ScriptValueSerializer::writeTransferredSharedArrayBuffer( | 1314 ScriptValueSerializer::writeTransferredSharedArrayBuffer( |
| 1313 v8::Local<v8::Value> value, | 1315 v8::Local<v8::Value> value, |
| 1314 uint32_t index, | 1316 uint32_t index, |
| 1315 StateBase* next) { | 1317 StateBase* next) { |
| 1316 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); | 1318 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); |
| 1317 DOMSharedArrayBuffer* sharedArrayBuffer = | 1319 DOMSharedArrayBuffer* sharedArrayBuffer = |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 if (!doReadUint32(&index)) | 1680 if (!doReadUint32(&index)) |
| 1679 return false; | 1681 return false; |
| 1680 if (!deserializer.tryGetTransferredImageBitmap(index, value)) | 1682 if (!deserializer.tryGetTransferredImageBitmap(index, value)) |
| 1681 return false; | 1683 return false; |
| 1682 break; | 1684 break; |
| 1683 } | 1685 } |
| 1684 case OffscreenCanvasTransferTag: { | 1686 case OffscreenCanvasTransferTag: { |
| 1685 if (!m_version) | 1687 if (!m_version) |
| 1686 return false; | 1688 return false; |
| 1687 uint32_t width, height, canvasId, clientId, sinkId, localId; | 1689 uint32_t width, height, canvasId, clientId, sinkId, localId; |
| 1688 uint64_t nonce; | 1690 uint64_t nonceHigh, nonceLow; |
| 1689 if (!doReadUint32(&width)) | 1691 if (!doReadUint32(&width)) |
| 1690 return false; | 1692 return false; |
| 1691 if (!doReadUint32(&height)) | 1693 if (!doReadUint32(&height)) |
| 1692 return false; | 1694 return false; |
| 1693 if (!doReadUint32(&canvasId)) | 1695 if (!doReadUint32(&canvasId)) |
| 1694 return false; | 1696 return false; |
| 1695 if (!doReadUint32(&clientId)) | 1697 if (!doReadUint32(&clientId)) |
| 1696 return false; | 1698 return false; |
| 1697 if (!doReadUint32(&sinkId)) | 1699 if (!doReadUint32(&sinkId)) |
| 1698 return false; | 1700 return false; |
| 1699 if (!doReadUint32(&localId)) | 1701 if (!doReadUint32(&localId)) |
| 1700 return false; | 1702 return false; |
| 1701 if (!doReadUint64(&nonce)) | 1703 if (!doReadUint64(&nonceHigh) || !doReadUint64(&nonceLow)) |
| 1702 return false; | 1704 return false; |
| 1703 if (!deserializer.tryGetTransferredOffscreenCanvas( | 1705 if (!deserializer.tryGetTransferredOffscreenCanvas( |
| 1704 width, height, canvasId, clientId, sinkId, localId, nonce, value)) | 1706 width, height, canvasId, clientId, sinkId, localId, nonceHigh, |
| 1707 nonceLow, value)) |
| 1705 return false; | 1708 return false; |
| 1706 break; | 1709 break; |
| 1707 } | 1710 } |
| 1708 case SharedArrayBufferTransferTag: { | 1711 case SharedArrayBufferTransferTag: { |
| 1709 if (!m_version) | 1712 if (!m_version) |
| 1710 return false; | 1713 return false; |
| 1711 uint32_t index; | 1714 uint32_t index; |
| 1712 if (!doReadUint32(&index)) | 1715 if (!doReadUint32(&index)) |
| 1713 return false; | 1716 return false; |
| 1714 if (!deserializer.tryGetTransferredSharedArrayBuffer(index, value)) | 1717 if (!deserializer.tryGetTransferredSharedArrayBuffer(index, value)) |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2545 return true; | 2548 return true; |
| 2546 } | 2549 } |
| 2547 | 2550 |
| 2548 bool ScriptValueDeserializer::tryGetTransferredOffscreenCanvas( | 2551 bool ScriptValueDeserializer::tryGetTransferredOffscreenCanvas( |
| 2549 uint32_t width, | 2552 uint32_t width, |
| 2550 uint32_t height, | 2553 uint32_t height, |
| 2551 uint32_t canvasId, | 2554 uint32_t canvasId, |
| 2552 uint32_t clientId, | 2555 uint32_t clientId, |
| 2553 uint32_t sinkId, | 2556 uint32_t sinkId, |
| 2554 uint32_t localId, | 2557 uint32_t localId, |
| 2555 uint64_t nonce, | 2558 uint64_t nonceHigh, |
| 2559 uint64_t nonceLow, |
| 2556 v8::Local<v8::Value>* object) { | 2560 v8::Local<v8::Value>* object) { |
| 2557 OffscreenCanvas* offscreenCanvas = OffscreenCanvas::create(width, height); | 2561 OffscreenCanvas* offscreenCanvas = OffscreenCanvas::create(width, height); |
| 2558 offscreenCanvas->setAssociatedCanvasId(canvasId); | 2562 offscreenCanvas->setAssociatedCanvasId(canvasId); |
| 2559 offscreenCanvas->setSurfaceId(clientId, sinkId, localId, nonce); | 2563 offscreenCanvas->setSurfaceId(clientId, sinkId, localId, nonceHigh, nonceLow); |
| 2560 *object = toV8(offscreenCanvas, m_reader.getScriptState()); | 2564 *object = toV8(offscreenCanvas, m_reader.getScriptState()); |
| 2561 if ((*object).IsEmpty()) | 2565 if ((*object).IsEmpty()) |
| 2562 return false; | 2566 return false; |
| 2563 return true; | 2567 return true; |
| 2564 } | 2568 } |
| 2565 | 2569 |
| 2566 bool ScriptValueDeserializer::tryGetObjectFromObjectReference( | 2570 bool ScriptValueDeserializer::tryGetObjectFromObjectReference( |
| 2567 uint32_t reference, | 2571 uint32_t reference, |
| 2568 v8::Local<v8::Value>* object) { | 2572 v8::Local<v8::Value>* object) { |
| 2569 if (reference >= m_objectPool.size()) | 2573 if (reference >= m_objectPool.size()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2635 m_openCompositeReferenceStack[m_openCompositeReferenceStack.size() - 1]; | 2639 m_openCompositeReferenceStack[m_openCompositeReferenceStack.size() - 1]; |
| 2636 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - | 2640 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - |
| 2637 1); | 2641 1); |
| 2638 if (objectReference >= m_objectPool.size()) | 2642 if (objectReference >= m_objectPool.size()) |
| 2639 return false; | 2643 return false; |
| 2640 *object = m_objectPool[objectReference]; | 2644 *object = m_objectPool[objectReference]; |
| 2641 return true; | 2645 return true; |
| 2642 } | 2646 } |
| 2643 | 2647 |
| 2644 } // namespace blink | 2648 } // namespace blink |
| OLD | NEW |