Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 2143033005: Transfer components of SurfaceId in OffscreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 append(ArrayBufferTransferTag); 354 append(ArrayBufferTransferTag);
355 doWriteUint32(index); 355 doWriteUint32(index);
356 } 356 }
357 357
358 void SerializedScriptValueWriter::writeTransferredImageBitmap(uint32_t index) 358 void SerializedScriptValueWriter::writeTransferredImageBitmap(uint32_t index)
359 { 359 {
360 append(ImageBitmapTransferTag); 360 append(ImageBitmapTransferTag);
361 doWriteUint32(index); 361 doWriteUint32(index);
362 } 362 }
363 363
364 void SerializedScriptValueWriter::writeTransferredOffscreenCanvas(uint32_t index , uint32_t width, uint32_t height, uint32_t id) 364 void SerializedScriptValueWriter::writeTransferredOffscreenCanvas(uint32_t index , uint32_t width, uint32_t height, uint32_t canvasId, uint32_t clientId, uint32_ t localId, uint64_t nonce)
365 { 365 {
366 append(OffscreenCanvasTransferTag); 366 append(OffscreenCanvasTransferTag);
367 doWriteUint32(index); 367 doWriteUint32(index);
368 doWriteUint32(width); 368 doWriteUint32(width);
369 doWriteUint32(height); 369 doWriteUint32(height);
370 doWriteUint32(id); 370 doWriteUint32(canvasId);
371 doWriteUint32(clientId);
372 doWriteUint32(localId);
373 doWriteUint64(nonce);
371 } 374 }
372 375
373 void SerializedScriptValueWriter::writeTransferredSharedArrayBuffer(uint32_t ind ex) 376 void SerializedScriptValueWriter::writeTransferredSharedArrayBuffer(uint32_t ind ex)
374 { 377 {
375 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); 378 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled());
376 append(SharedArrayBufferTransferTag); 379 append(SharedArrayBufferTransferTag);
377 doWriteUint32(index); 380 doWriteUint32(index);
378 } 381 }
379 382
380 void SerializedScriptValueWriter::writeObjectReference(uint32_t reference) 383 void SerializedScriptValueWriter::writeObjectReference(uint32_t reference)
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1172
1170 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredOffscre enCanvas(v8::Local<v8::Value> value, uint32_t index, StateBase* next) 1173 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredOffscre enCanvas(v8::Local<v8::Value> value, uint32_t index, StateBase* next)
1171 { 1174 {
1172 OffscreenCanvas* offscreenCanvas = V8OffscreenCanvas::toImpl(value.As<v8::Ob ject>()); 1175 OffscreenCanvas* offscreenCanvas = V8OffscreenCanvas::toImpl(value.As<v8::Ob ject>());
1173 if (!offscreenCanvas) 1176 if (!offscreenCanvas)
1174 return nullptr; 1177 return nullptr;
1175 if (offscreenCanvas->isNeutered()) 1178 if (offscreenCanvas->isNeutered())
1176 return handleError(Status::DataCloneError, "An OffscreenCanvas is detach ed and could not be cloned.", next); 1179 return handleError(Status::DataCloneError, "An OffscreenCanvas is detach ed and could not be cloned.", next);
1177 if (offscreenCanvas->renderingContext()) 1180 if (offscreenCanvas->renderingContext())
1178 return handleError(Status::DataCloneError, "An OffscreenCanvas with a co ntext could not be cloned.", next); 1181 return handleError(Status::DataCloneError, "An OffscreenCanvas with a co ntext could not be cloned.", next);
1179 m_writer.writeTransferredOffscreenCanvas(index, offscreenCanvas->width(), of fscreenCanvas->height(), offscreenCanvas->getAssociatedCanvasId()); 1182 m_writer.writeTransferredOffscreenCanvas(index, offscreenCanvas->width(), of fscreenCanvas->height(), offscreenCanvas->getAssociatedCanvasId(), offscreenCanv as->clientId(), offscreenCanvas->localId(), offscreenCanvas->nonce());
1180 return nullptr; 1183 return nullptr;
1181 } 1184 }
1182 1185
1183 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredSharedA rrayBuffer(v8::Local<v8::Value> value, uint32_t index, StateBase* next) 1186 ScriptValueSerializer::StateBase* ScriptValueSerializer::writeTransferredSharedA rrayBuffer(v8::Local<v8::Value> value, uint32_t index, StateBase* next)
1184 { 1187 {
1185 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled()); 1188 ASSERT(RuntimeEnabledFeatures::sharedArrayBufferEnabled());
1186 DOMSharedArrayBuffer* sharedArrayBuffer = V8SharedArrayBuffer::toImpl(value. As<v8::Object>()); 1189 DOMSharedArrayBuffer* sharedArrayBuffer = V8SharedArrayBuffer::toImpl(value. As<v8::Object>());
1187 if (!sharedArrayBuffer) 1190 if (!sharedArrayBuffer)
1188 return 0; 1191 return 0;
1189 m_writer.writeTransferredSharedArrayBuffer(index); 1192 m_writer.writeTransferredSharedArrayBuffer(index);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 uint32_t index; 1527 uint32_t index;
1525 if (!doReadUint32(&index)) 1528 if (!doReadUint32(&index))
1526 return false; 1529 return false;
1527 if (!deserializer.tryGetTransferredImageBitmap(index, value)) 1530 if (!deserializer.tryGetTransferredImageBitmap(index, value))
1528 return false; 1531 return false;
1529 break; 1532 break;
1530 } 1533 }
1531 case OffscreenCanvasTransferTag: { 1534 case OffscreenCanvasTransferTag: {
1532 if (!m_version) 1535 if (!m_version)
1533 return false; 1536 return false;
1534 uint32_t index, width, height, id; 1537 uint32_t index, width, height, canvasId, clientId, localId;
1538 uint64_t nonce;
1535 if (!doReadUint32(&index)) 1539 if (!doReadUint32(&index))
1536 return false; 1540 return false;
1537 if (!doReadUint32(&width)) 1541 if (!doReadUint32(&width))
1538 return false; 1542 return false;
1539 if (!doReadUint32(&height)) 1543 if (!doReadUint32(&height))
1540 return false; 1544 return false;
1541 if (!doReadUint32(&id)) 1545 if (!doReadUint32(&canvasId))
1542 return false; 1546 return false;
1543 if (!deserializer.tryGetTransferredOffscreenCanvas(index, width, height, id, value)) 1547 if (!doReadUint32(&clientId))
1548 return false;
1549 if (!doReadUint32(&localId))
1550 return false;
1551 if (!doReadUint64(&nonce))
1552 return false;
1553 if (!deserializer.tryGetTransferredOffscreenCanvas(index, width, height, canvasId, clientId, localId, nonce, value))
1544 return false; 1554 return false;
1545 break; 1555 break;
1546 } 1556 }
1547 case SharedArrayBufferTransferTag: { 1557 case SharedArrayBufferTransferTag: {
1548 if (!m_version) 1558 if (!m_version)
1549 return false; 1559 return false;
1550 uint32_t index; 1560 uint32_t index;
1551 if (!doReadUint32(&index)) 1561 if (!doReadUint32(&index))
1552 return false; 1562 return false;
1553 if (!deserializer.tryGetTransferredSharedArrayBuffer(index, value)) 1563 if (!deserializer.tryGetTransferredSharedArrayBuffer(index, value))
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 v8::Local<v8::Object> creationContext = m_reader.getScriptState()->conte xt()->Global(); 2335 v8::Local<v8::Object> creationContext = m_reader.getScriptState()->conte xt()->Global();
2326 result = toV8(buffer, creationContext, isolate); 2336 result = toV8(buffer, creationContext, isolate);
2327 if (result.IsEmpty()) 2337 if (result.IsEmpty())
2328 return false; 2338 return false;
2329 m_arrayBuffers[index] = result; 2339 m_arrayBuffers[index] = result;
2330 } 2340 }
2331 *object = result; 2341 *object = result;
2332 return true; 2342 return true;
2333 } 2343 }
2334 2344
2335 bool ScriptValueDeserializer::tryGetTransferredOffscreenCanvas(uint32_t index, u int32_t width, uint32_t height, uint32_t id, v8::Local<v8::Value>* object) 2345 bool ScriptValueDeserializer::tryGetTransferredOffscreenCanvas(uint32_t index, u int32_t width, uint32_t height, uint32_t canvasId, uint32_t clientId, uint32_t l ocalId, uint64_t nonce, v8::Local<v8::Value>* object)
2336 { 2346 {
2337 OffscreenCanvas* offscreenCanvas = OffscreenCanvas::create(width, height); 2347 OffscreenCanvas* offscreenCanvas = OffscreenCanvas::create(width, height);
2338 offscreenCanvas->setAssociatedCanvasId(id); 2348 offscreenCanvas->setAssociatedCanvasId(canvasId);
2349 offscreenCanvas->setSurfaceId(clientId, localId, nonce);
2339 *object = toV8(offscreenCanvas, m_reader.getScriptState()); 2350 *object = toV8(offscreenCanvas, m_reader.getScriptState());
2340 if ((*object).IsEmpty()) 2351 if ((*object).IsEmpty())
2341 return false; 2352 return false;
2342 return true; 2353 return true;
2343 } 2354 }
2344 2355
2345 bool ScriptValueDeserializer::tryGetObjectFromObjectReference(uint32_t reference , v8::Local<v8::Value>* object) 2356 bool ScriptValueDeserializer::tryGetObjectFromObjectReference(uint32_t reference , v8::Local<v8::Value>* object)
2346 { 2357 {
2347 if (reference >= m_objectPool.size()) 2358 if (reference >= m_objectPool.size())
2348 return false; 2359 return false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 return false; 2424 return false;
2414 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1]; 2425 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1];
2415 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1); 2426 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1);
2416 if (objectReference >= m_objectPool.size()) 2427 if (objectReference >= m_objectPool.size())
2417 return false; 2428 return false;
2418 *object = m_objectPool[objectReference]; 2429 *object = m_objectPool[objectReference];
2419 return true; 2430 return true;
2420 } 2431 }
2421 2432
2422 } // namespace blink 2433 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698