| 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 #ifndef ScriptValueSerializer_h | 5 #ifndef ScriptValueSerializer_h |
| 6 #define ScriptValueSerializer_h | 6 #define ScriptValueSerializer_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/SerializationTag.h" | 8 #include "bindings/core/v8/SerializationTag.h" |
| 9 #include "bindings/core/v8/SerializedScriptValue.h" | 9 #include "bindings/core/v8/SerializedScriptValue.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void writeFileListIndex(const Vector<int>& blobIndices); | 136 void writeFileListIndex(const Vector<int>& blobIndices); |
| 137 void writeArrayBuffer(const DOMArrayBuffer&); | 137 void writeArrayBuffer(const DOMArrayBuffer&); |
| 138 void writeArrayBufferView(const DOMArrayBufferView&); | 138 void writeArrayBufferView(const DOMArrayBufferView&); |
| 139 void doWriteImageData(uint32_t width, uint32_t height, const uint8_t* pixelD
ata, uint32_t pixelDataLength); | 139 void doWriteImageData(uint32_t width, uint32_t height, const uint8_t* pixelD
ata, uint32_t pixelDataLength); |
| 140 void writeImageData(uint32_t width, uint32_t height, const uint8_t* pixelDat
a, uint32_t pixelDataLength); | 140 void writeImageData(uint32_t width, uint32_t height, const uint8_t* pixelDat
a, uint32_t pixelDataLength); |
| 141 void writeImageBitmap(uint32_t width, uint32_t height, const uint8_t* pixelD
ata, uint32_t pixelDataLength); | 141 void writeImageBitmap(uint32_t width, uint32_t height, const uint8_t* pixelD
ata, uint32_t pixelDataLength); |
| 142 void writeRegExp(v8::Local<v8::String> pattern, v8::RegExp::Flags); | 142 void writeRegExp(v8::Local<v8::String> pattern, v8::RegExp::Flags); |
| 143 void writeTransferredMessagePort(uint32_t index); | 143 void writeTransferredMessagePort(uint32_t index); |
| 144 void writeTransferredArrayBuffer(uint32_t index); | 144 void writeTransferredArrayBuffer(uint32_t index); |
| 145 void writeTransferredImageBitmap(uint32_t index); | 145 void writeTransferredImageBitmap(uint32_t index); |
| 146 void writeTransferredOffscreenCanvas(uint32_t index, uint32_t width, uint32_
t height, uint32_t id); |
| 146 void writeTransferredSharedArrayBuffer(uint32_t index); | 147 void writeTransferredSharedArrayBuffer(uint32_t index); |
| 147 void writeObjectReference(uint32_t reference); | 148 void writeObjectReference(uint32_t reference); |
| 148 void writeObject(uint32_t numProperties); | 149 void writeObject(uint32_t numProperties); |
| 149 void writeSparseArray(uint32_t numProperties, uint32_t length); | 150 void writeSparseArray(uint32_t numProperties, uint32_t length); |
| 150 void writeDenseArray(uint32_t numProperties, uint32_t length); | 151 void writeDenseArray(uint32_t numProperties, uint32_t length); |
| 151 String takeWireString(); | 152 String takeWireString(); |
| 152 void writeReferenceCount(uint32_t numberOfReferences); | 153 void writeReferenceCount(uint32_t numberOfReferences); |
| 153 void writeGenerateFreshObject(); | 154 void writeGenerateFreshObject(); |
| 154 void writeGenerateFreshSparseArray(uint32_t length); | 155 void writeGenerateFreshSparseArray(uint32_t length); |
| 155 void writeGenerateFreshDenseArray(uint32_t length); | 156 void writeGenerateFreshDenseArray(uint32_t length); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 StateBase* writeCompositorProxy(v8::Local<v8::Value>, StateBase* next); | 403 StateBase* writeCompositorProxy(v8::Local<v8::Value>, StateBase* next); |
| 403 StateBase* writeFile(v8::Local<v8::Value>, StateBase* next); | 404 StateBase* writeFile(v8::Local<v8::Value>, StateBase* next); |
| 404 StateBase* writeFileList(v8::Local<v8::Value>, StateBase* next); | 405 StateBase* writeFileList(v8::Local<v8::Value>, StateBase* next); |
| 405 void writeImageData(v8::Local<v8::Value>); | 406 void writeImageData(v8::Local<v8::Value>); |
| 406 StateBase* writeImageBitmap(v8::Local<v8::Value>, StateBase* next); | 407 StateBase* writeImageBitmap(v8::Local<v8::Value>, StateBase* next); |
| 407 void writeRegExp(v8::Local<v8::Value>); | 408 void writeRegExp(v8::Local<v8::Value>); |
| 408 StateBase* writeAndGreyArrayBufferView(v8::Local<v8::Object>, StateBase* nex
t); | 409 StateBase* writeAndGreyArrayBufferView(v8::Local<v8::Object>, StateBase* nex
t); |
| 409 StateBase* writeArrayBuffer(v8::Local<v8::Value>, StateBase* next); | 410 StateBase* writeArrayBuffer(v8::Local<v8::Value>, StateBase* next); |
| 410 StateBase* writeTransferredArrayBuffer(v8::Local<v8::Value>, uint32_t index,
StateBase* next); | 411 StateBase* writeTransferredArrayBuffer(v8::Local<v8::Value>, uint32_t index,
StateBase* next); |
| 411 StateBase* writeTransferredImageBitmap(v8::Local<v8::Value>, uint32_t index,
StateBase* next); | 412 StateBase* writeTransferredImageBitmap(v8::Local<v8::Value>, uint32_t index,
StateBase* next); |
| 413 StateBase* writeTransferredOffscreenCanvas(v8::Local<v8::Value>, uint32_t in
dex, StateBase* next); |
| 412 StateBase* writeTransferredSharedArrayBuffer(v8::Local<v8::Value>, uint32_t
index, StateBase* next); | 414 StateBase* writeTransferredSharedArrayBuffer(v8::Local<v8::Value>, uint32_t
index, StateBase* next); |
| 413 static bool shouldSerializeDensely(uint32_t length, uint32_t propertyCount); | 415 static bool shouldSerializeDensely(uint32_t length, uint32_t propertyCount); |
| 414 | 416 |
| 415 StateBase* startArrayState(v8::Local<v8::Array>, StateBase* next); | 417 StateBase* startArrayState(v8::Local<v8::Array>, StateBase* next); |
| 416 StateBase* startObjectState(v8::Local<v8::Object>, StateBase* next); | 418 StateBase* startObjectState(v8::Local<v8::Object>, StateBase* next); |
| 417 StateBase* startMapState(v8::Local<v8::Map>, StateBase* next); | 419 StateBase* startMapState(v8::Local<v8::Map>, StateBase* next); |
| 418 StateBase* startSetState(v8::Local<v8::Set>, StateBase* next); | 420 StateBase* startSetState(v8::Local<v8::Set>, StateBase* next); |
| 419 | 421 |
| 420 bool appendBlobInfo(const String& uuid, const String& type, unsigned long lo
ng size, int* index); | 422 bool appendBlobInfo(const String& uuid, const String& type, unsigned long lo
ng size, int* index); |
| 421 bool appendFileInfo(const File*, int* index); | 423 bool appendFileInfo(const File*, int* index); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 438 SerializedScriptValueWriter& m_writer; | 440 SerializedScriptValueWriter& m_writer; |
| 439 v8::TryCatch& m_tryCatch; | 441 v8::TryCatch& m_tryCatch; |
| 440 int m_depth; | 442 int m_depth; |
| 441 Status m_status; | 443 Status m_status; |
| 442 String m_errorMessage; | 444 String m_errorMessage; |
| 443 typedef V8ObjectMap<v8::Object, uint32_t> ObjectPool; | 445 typedef V8ObjectMap<v8::Object, uint32_t> ObjectPool; |
| 444 ObjectPool m_objectPool; | 446 ObjectPool m_objectPool; |
| 445 ObjectPool m_transferredMessagePorts; | 447 ObjectPool m_transferredMessagePorts; |
| 446 ObjectPool m_transferredArrayBuffers; | 448 ObjectPool m_transferredArrayBuffers; |
| 447 ObjectPool m_transferredImageBitmaps; | 449 ObjectPool m_transferredImageBitmaps; |
| 450 ObjectPool m_transferredOffscreenCanvas; |
| 448 uint32_t m_nextObjectReference; | 451 uint32_t m_nextObjectReference; |
| 449 WebBlobInfoArray* m_blobInfo; | 452 WebBlobInfoArray* m_blobInfo; |
| 450 BlobDataHandleMap& m_blobDataHandles; | 453 BlobDataHandleMap& m_blobDataHandles; |
| 451 }; | 454 }; |
| 452 | 455 |
| 453 // Interface used by SerializedScriptValueReader to create objects of composite
types. | 456 // Interface used by SerializedScriptValueReader to create objects of composite
types. |
| 454 class CORE_EXPORT ScriptValueCompositeCreator { | 457 class CORE_EXPORT ScriptValueCompositeCreator { |
| 455 STACK_ALLOCATED(); | 458 STACK_ALLOCATED(); |
| 456 WTF_MAKE_NONCOPYABLE(ScriptValueCompositeCreator); | 459 WTF_MAKE_NONCOPYABLE(ScriptValueCompositeCreator); |
| 457 public: | 460 public: |
| 458 ScriptValueCompositeCreator() { } | 461 ScriptValueCompositeCreator() { } |
| 459 virtual ~ScriptValueCompositeCreator() { } | 462 virtual ~ScriptValueCompositeCreator() { } |
| 460 | 463 |
| 461 virtual bool consumeTopOfStack(v8::Local<v8::Value>*) = 0; | 464 virtual bool consumeTopOfStack(v8::Local<v8::Value>*) = 0; |
| 462 virtual uint32_t objectReferenceCount() = 0; | 465 virtual uint32_t objectReferenceCount() = 0; |
| 463 virtual void pushObjectReference(const v8::Local<v8::Value>&) = 0; | 466 virtual void pushObjectReference(const v8::Local<v8::Value>&) = 0; |
| 464 virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Local<v
8::Value>*) = 0; | 467 virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Local<v
8::Value>*) = 0; |
| 465 virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Local<v8::Valu
e>*) = 0; | 468 virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Local<v8::Valu
e>*) = 0; |
| 466 virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Local<v8::Valu
e>*) = 0; | 469 virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Local<v8::Valu
e>*) = 0; |
| 467 virtual bool tryGetTransferredImageBitmap(uint32_t index, v8::Local<v8::Valu
e>*) = 0; | 470 virtual bool tryGetTransferredImageBitmap(uint32_t index, v8::Local<v8::Valu
e>*) = 0; |
| 471 virtual bool tryGetTransferredOffscreenCanvas(uint32_t index, uint32_t width
, uint32_t height, uint32_t id, v8::Local<v8::Value>*) = 0; |
| 468 virtual bool tryGetTransferredSharedArrayBuffer(uint32_t index, v8::Local<v8
::Value>*) = 0; | 472 virtual bool tryGetTransferredSharedArrayBuffer(uint32_t index, v8::Local<v8
::Value>*) = 0; |
| 469 virtual bool newSparseArray(uint32_t length) = 0; | 473 virtual bool newSparseArray(uint32_t length) = 0; |
| 470 virtual bool newDenseArray(uint32_t length) = 0; | 474 virtual bool newDenseArray(uint32_t length) = 0; |
| 471 virtual bool newMap() = 0; | 475 virtual bool newMap() = 0; |
| 472 virtual bool newSet() = 0; | 476 virtual bool newSet() = 0; |
| 473 virtual bool newObject() = 0; | 477 virtual bool newObject() = 0; |
| 474 virtual bool completeObject(uint32_t numProperties, v8::Local<v8::Value>*) =
0; | 478 virtual bool completeObject(uint32_t numProperties, v8::Local<v8::Value>*) =
0; |
| 475 virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8
::Local<v8::Value>*) = 0; | 479 virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8
::Local<v8::Value>*) = 0; |
| 476 virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8:
:Local<v8::Value>*) = 0; | 480 virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8:
:Local<v8::Value>*) = 0; |
| 477 virtual bool completeMap(uint32_t length, v8::Local<v8::Value>*) = 0; | 481 virtual bool completeMap(uint32_t length, v8::Local<v8::Value>*) = 0; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 bool newObject() override; | 610 bool newObject() override; |
| 607 bool completeObject(uint32_t numProperties, v8::Local<v8::Value>*) override; | 611 bool completeObject(uint32_t numProperties, v8::Local<v8::Value>*) override; |
| 608 bool completeSparseArray(uint32_t numProperties, uint32_t length, v8::Local<
v8::Value>*) override; | 612 bool completeSparseArray(uint32_t numProperties, uint32_t length, v8::Local<
v8::Value>*) override; |
| 609 bool completeDenseArray(uint32_t numProperties, uint32_t length, v8::Local<v
8::Value>*) override; | 613 bool completeDenseArray(uint32_t numProperties, uint32_t length, v8::Local<v
8::Value>*) override; |
| 610 bool completeMap(uint32_t length, v8::Local<v8::Value>*) override; | 614 bool completeMap(uint32_t length, v8::Local<v8::Value>*) override; |
| 611 bool completeSet(uint32_t length, v8::Local<v8::Value>*) override; | 615 bool completeSet(uint32_t length, v8::Local<v8::Value>*) override; |
| 612 void pushObjectReference(const v8::Local<v8::Value>&) override; | 616 void pushObjectReference(const v8::Local<v8::Value>&) override; |
| 613 bool tryGetTransferredMessagePort(uint32_t index, v8::Local<v8::Value>*) ove
rride; | 617 bool tryGetTransferredMessagePort(uint32_t index, v8::Local<v8::Value>*) ove
rride; |
| 614 bool tryGetTransferredArrayBuffer(uint32_t index, v8::Local<v8::Value>*) ove
rride; | 618 bool tryGetTransferredArrayBuffer(uint32_t index, v8::Local<v8::Value>*) ove
rride; |
| 615 bool tryGetTransferredImageBitmap(uint32_t index, v8::Local<v8::Value>*) ove
rride; | 619 bool tryGetTransferredImageBitmap(uint32_t index, v8::Local<v8::Value>*) ove
rride; |
| 620 bool tryGetTransferredOffscreenCanvas(uint32_t index, uint32_t width, uint32
_t height, uint32_t id, v8::Local<v8::Value>*) override; |
| 616 bool tryGetTransferredSharedArrayBuffer(uint32_t index, v8::Local<v8::Value>
*) override; | 621 bool tryGetTransferredSharedArrayBuffer(uint32_t index, v8::Local<v8::Value>
*) override; |
| 617 bool tryGetObjectFromObjectReference(uint32_t reference, v8::Local<v8::Value
>*) override; | 622 bool tryGetObjectFromObjectReference(uint32_t reference, v8::Local<v8::Value
>*) override; |
| 618 uint32_t objectReferenceCount() override; | 623 uint32_t objectReferenceCount() override; |
| 619 | 624 |
| 620 protected: | 625 protected: |
| 621 SerializedScriptValueReader& reader() { return m_reader; } | 626 SerializedScriptValueReader& reader() { return m_reader; } |
| 622 virtual bool read(v8::Local<v8::Value>*); | 627 virtual bool read(v8::Local<v8::Value>*); |
| 623 | 628 |
| 624 private: | 629 private: |
| 625 bool initializeObject(v8::Local<v8::Object>, uint32_t numProperties, v8::Loc
al<v8::Value>*); | 630 bool initializeObject(v8::Local<v8::Object>, uint32_t numProperties, v8::Loc
al<v8::Value>*); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 644 ArrayBufferContentsArray* m_arrayBufferContents; | 649 ArrayBufferContentsArray* m_arrayBufferContents; |
| 645 ImageBitmapContentsArray* m_imageBitmapContents; | 650 ImageBitmapContentsArray* m_imageBitmapContents; |
| 646 Vector<v8::Local<v8::Value>> m_arrayBuffers; | 651 Vector<v8::Local<v8::Value>> m_arrayBuffers; |
| 647 Vector<v8::Local<v8::Value>> m_imageBitmaps; | 652 Vector<v8::Local<v8::Value>> m_imageBitmaps; |
| 648 uint32_t m_version; | 653 uint32_t m_version; |
| 649 }; | 654 }; |
| 650 | 655 |
| 651 } // namespace blink | 656 } // namespace blink |
| 652 | 657 |
| 653 #endif // ScriptValueSerializer_h | 658 #endif // ScriptValueSerializer_h |
| OLD | NEW |