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 "config.h" | 5 #include "config.h" |
6 #include "bindings/modules/v8/SerializedScriptValueForModulesFactory.h" | 6 #include "bindings/modules/v8/SerializedScriptValueForModulesFactory.h" |
7 | 7 |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/SerializedScriptValue.h" | 9 #include "bindings/core/v8/SerializedScriptValue.h" |
10 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" | 10 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 ScriptValueSerializerForModules serializer(writer, messagePorts, arrayBuffer
s, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate)); | 56 ScriptValueSerializerForModules serializer(writer, messagePorts, arrayBuffer
s, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate)); |
57 ScriptValueSerializer::Status status = serializer.serialize(value); | 57 ScriptValueSerializer::Status status = serializer.serialize(value); |
58 errorMessage = serializer.errorMessage(); | 58 errorMessage = serializer.errorMessage(); |
59 return status; | 59 return status; |
60 } | 60 } |
61 | 61 |
62 v8::Handle<v8::Value> SerializedScriptValueForModulesFactory::deserialize(String
& data, BlobDataHandleMap& blobDataHandles, ArrayBufferContentsArray* arrayBuffe
rContentsArray, v8::Isolate* isolate, MessagePortArray* messagePorts, const WebB
lobInfoArray* blobInfo) | 62 v8::Handle<v8::Value> SerializedScriptValueForModulesFactory::deserialize(String
& data, BlobDataHandleMap& blobDataHandles, ArrayBufferContentsArray* arrayBuffe
rContentsArray, v8::Isolate* isolate, MessagePortArray* messagePorts, const WebB
lobInfoArray* blobInfo) |
63 { | 63 { |
64 if (!data.impl()) | 64 if (!data.impl()) |
65 return v8::Null(isolate); | 65 return v8::Null(isolate); |
66 COMPILE_ASSERT(sizeof(SerializedScriptValueWriter::BufferValueType) == 2, Bu
fferValueTypeIsTwoBytes); | 66 static_assert(sizeof(SerializedScriptValueWriter::BufferValueType) == 2, "Bu
fferValueType should be 2 bytes"); |
67 data.ensure16Bit(); | 67 data.ensure16Bit(); |
68 // FIXME: SerializedScriptValue shouldn't use String for its underlying | 68 // FIXME: SerializedScriptValue shouldn't use String for its underlying |
69 // storage. Instead, it should use SharedBuffer or Vector<uint8_t>. The | 69 // storage. Instead, it should use SharedBuffer or Vector<uint8_t>. The |
70 // information stored in m_data isn't even encoded in UTF-16. Instead, | 70 // information stored in m_data isn't even encoded in UTF-16. Instead, |
71 // unicode characters are encoded as UTF-8 with two code units per UChar. | 71 // unicode characters are encoded as UTF-8 with two code units per UChar. |
72 SerializedScriptValueReaderForModules reader(reinterpret_cast<const uint8_t*
>(data.impl()->characters16()), 2 * data.length(), blobInfo, blobDataHandles, Sc
riptState::current(isolate)); | 72 SerializedScriptValueReaderForModules reader(reinterpret_cast<const uint8_t*
>(data.impl()->characters16()), 2 * data.length(), blobInfo, blobDataHandles, Sc
riptState::current(isolate)); |
73 ScriptValueDeserializerForModules deserializer(reader, messagePorts, arrayBu
fferContentsArray); | 73 ScriptValueDeserializerForModules deserializer(reader, messagePorts, arrayBu
fferContentsArray); |
74 return deserializer.deserialize(); | 74 return deserializer.deserialize(); |
75 } | 75 } |
76 | 76 |
77 } // namespace blink | 77 } // namespace blink |
78 | 78 |
OLD | NEW |