| 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 "base/gtest_prod_util.h" |
| 8 #include "bindings/core/v8/SerializationTag.h" | 9 #include "bindings/core/v8/SerializationTag.h" |
| 9 #include "bindings/core/v8/SerializedScriptValue.h" | 10 #include "bindings/core/v8/SerializedScriptValue.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
| 11 #include "core/CoreExport.h" | 12 #include "core/CoreExport.h" |
| 12 #include "wtf/HashMap.h" | 13 #include "wtf/HashMap.h" |
| 13 #include "wtf/Noncopyable.h" | 14 #include "wtf/Noncopyable.h" |
| 14 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
| 15 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
| 16 #include "wtf/typed_arrays/ArrayBufferContents.h" | 17 #include "wtf/typed_arrays/ArrayBufferContents.h" |
| 17 #include <v8.h> | 18 #include <v8.h> |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 template<class T> | 534 template<class T> |
| 534 bool doReadUintHelper(T* value) | 535 bool doReadUintHelper(T* value) |
| 535 { | 536 { |
| 536 *value = 0; | 537 *value = 0; |
| 537 uint8_t currentByte; | 538 uint8_t currentByte; |
| 538 int shift = 0; | 539 int shift = 0; |
| 539 do { | 540 do { |
| 540 if (m_position >= m_length) | 541 if (m_position >= m_length) |
| 541 return false; | 542 return false; |
| 542 currentByte = m_buffer[m_position++]; | 543 currentByte = m_buffer[m_position++]; |
| 543 *value |= ((currentByte & SerializedScriptValue::varIntMask) << shif
t); | 544 *value |= (static_cast<T>(currentByte & SerializedScriptValue::varIn
tMask) << shift); |
| 544 shift += SerializedScriptValue::varIntShift; | 545 shift += SerializedScriptValue::varIntShift; |
| 545 } while (currentByte & (1 << SerializedScriptValue::varIntShift)); | 546 } while (currentByte & (1 << SerializedScriptValue::varIntShift)); |
| 546 return true; | 547 return true; |
| 547 } | 548 } |
| 548 | 549 |
| 549 bool doReadUint64(uint64_t* value); | 550 bool doReadUint64(uint64_t* value); |
| 550 bool doReadNumber(double* number); | 551 bool doReadNumber(double* number); |
| 551 PassRefPtr<BlobDataHandle> getOrCreateBlobDataHandle(const String& uuid, con
st String& type, long long size = -1); | 552 PassRefPtr<BlobDataHandle> getOrCreateBlobDataHandle(const String& uuid, con
st String& type, long long size = -1); |
| 552 | 553 |
| 553 RefPtr<ScriptState> m_scriptState; | 554 RefPtr<ScriptState> m_scriptState; |
| 554 const uint8_t* m_buffer; | 555 const uint8_t* m_buffer; |
| 555 const unsigned m_length; | 556 const unsigned m_length; |
| 556 unsigned m_position; | 557 unsigned m_position; |
| 557 uint32_t m_version; | 558 uint32_t m_version; |
| 558 const WebBlobInfoArray* m_blobInfo; | 559 const WebBlobInfoArray* m_blobInfo; |
| 559 const BlobDataHandleMap& m_blobDataHandles; | 560 const BlobDataHandleMap& m_blobDataHandles; |
| 561 |
| 562 FRIEND_TEST_ALL_PREFIXES(ScriptValueSerializerTest, Uint64Decode); |
| 560 }; | 563 }; |
| 561 | 564 |
| 562 class CORE_EXPORT ScriptValueDeserializer { | 565 class CORE_EXPORT ScriptValueDeserializer { |
| 563 STACK_ALLOCATED(); | 566 STACK_ALLOCATED(); |
| 564 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializer); | 567 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializer); |
| 565 public: | 568 public: |
| 566 ScriptValueDeserializer(SerializedScriptValueReader& reader, MessagePortArra
y* messagePorts, ArrayBufferContentsArray* arrayBufferContents, ImageBitmapConte
ntsArray* imageBitmapContents) | 569 ScriptValueDeserializer(SerializedScriptValueReader& reader, MessagePortArra
y* messagePorts, ArrayBufferContentsArray* arrayBufferContents, ImageBitmapConte
ntsArray* imageBitmapContents) |
| 567 : m_reader(reader) | 570 : m_reader(reader) |
| 568 , m_transferredMessagePorts(messagePorts) | 571 , m_transferredMessagePorts(messagePorts) |
| 569 , m_arrayBufferContents(arrayBufferContents) | 572 , m_arrayBufferContents(arrayBufferContents) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 ArrayBufferContentsArray* m_arrayBufferContents; | 625 ArrayBufferContentsArray* m_arrayBufferContents; |
| 623 ImageBitmapContentsArray* m_imageBitmapContents; | 626 ImageBitmapContentsArray* m_imageBitmapContents; |
| 624 Vector<v8::Local<v8::Value>> m_arrayBuffers; | 627 Vector<v8::Local<v8::Value>> m_arrayBuffers; |
| 625 Vector<v8::Local<v8::Value>> m_imageBitmaps; | 628 Vector<v8::Local<v8::Value>> m_imageBitmaps; |
| 626 uint32_t m_version; | 629 uint32_t m_version; |
| 627 }; | 630 }; |
| 628 | 631 |
| 629 } // namespace blink | 632 } // namespace blink |
| 630 | 633 |
| 631 #endif // ScriptValueSerializer_h | 634 #endif // ScriptValueSerializer_h |
| OLD | NEW |