| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "bindings/core/v8/ExceptionState.h" | 35 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "bindings/core/v8/ScriptState.h" | 36 #include "bindings/core/v8/ScriptState.h" |
| 37 #include "bindings/core/v8/ScriptValueSerializer.h" | 37 #include "bindings/core/v8/ScriptValueSerializer.h" |
| 38 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 38 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 39 #include "bindings/core/v8/Transferables.h" | 39 #include "bindings/core/v8/Transferables.h" |
| 40 #include "bindings/core/v8/V8ArrayBuffer.h" | 40 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 41 #include "bindings/core/v8/V8ImageBitmap.h" | 41 #include "bindings/core/v8/V8ImageBitmap.h" |
| 42 #include "bindings/core/v8/V8MessagePort.h" | 42 #include "bindings/core/v8/V8MessagePort.h" |
| 43 #include "bindings/core/v8/V8OffscreenCanvas.h" | 43 #include "bindings/core/v8/V8OffscreenCanvas.h" |
| 44 #include "bindings/core/v8/V8SharedArrayBuffer.h" | 44 #include "bindings/core/v8/V8SharedArrayBuffer.h" |
| 45 #include "bindings/core/v8/serialization/V8ScriptValueDeserializer.h" |
| 46 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h" |
| 45 #include "core/dom/DOMArrayBuffer.h" | 47 #include "core/dom/DOMArrayBuffer.h" |
| 46 #include "core/dom/DOMSharedArrayBuffer.h" | 48 #include "core/dom/DOMSharedArrayBuffer.h" |
| 47 #include "core/dom/ExceptionCode.h" | 49 #include "core/dom/ExceptionCode.h" |
| 48 #include "core/dom/MessagePort.h" | 50 #include "core/dom/MessagePort.h" |
| 49 #include "core/frame/ImageBitmap.h" | 51 #include "core/frame/ImageBitmap.h" |
| 50 #include "platform/SharedBuffer.h" | 52 #include "platform/SharedBuffer.h" |
| 51 #include "platform/blob/BlobData.h" | 53 #include "platform/blob/BlobData.h" |
| 52 #include "platform/heap/Handle.h" | 54 #include "platform/heap/Handle.h" |
| 53 #include "wtf/Assertions.h" | 55 #include "wtf/Assertions.h" |
| 54 #include "wtf/ByteOrder.h" | 56 #include "wtf/ByteOrder.h" |
| 55 #include "wtf/PtrUtil.h" | 57 #include "wtf/PtrUtil.h" |
| 56 #include "wtf/Vector.h" | 58 #include "wtf/Vector.h" |
| 57 #include "wtf/text/StringBuffer.h" | 59 #include "wtf/text/StringBuffer.h" |
| 58 #include "wtf/text/StringHash.h" | 60 #include "wtf/text/StringHash.h" |
| 59 #include <memory> | 61 #include <memory> |
| 60 | 62 |
| 61 namespace blink { | 63 namespace blink { |
| 62 | 64 |
| 63 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) | 65 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) |
| 64 { | 66 { |
| 67 // TODO(jbroman): Move the V8-based structured clone invocation into |
| 68 // SerializedScriptValueFactory. |
| 69 if (RuntimeEnabledFeatures::v8BasedStructuredCloneEnabled()) { |
| 70 V8ScriptValueSerializer serializer(ScriptState::current(isolate)); |
| 71 return serializer.serialize(value, transferables, exception); |
| 72 } |
| 65 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); | 73 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); |
| 66 } | 74 } |
| 67 | 75 |
| 68 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) | 76 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) |
| 69 { | 77 { |
| 70 return create(ScriptValueSerializer::serializeWTFString(str)); | 78 return create(ScriptValueSerializer::serializeWTFString(str)); |
| 71 } | 79 } |
| 72 | 80 |
| 73 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serializeAndSwallowExce
ptions(v8::Isolate* isolate, v8::Local<v8::Value> value) | 81 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serializeAndSwallowExce
ptions(v8::Isolate* isolate, v8::Local<v8::Value> value) |
| 74 { | 82 { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 m_arrayBufferContentsArray = std::move(contents); | 271 m_arrayBufferContentsArray = std::move(contents); |
| 264 } | 272 } |
| 265 | 273 |
| 266 v8::Local<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messag
ePorts) | 274 v8::Local<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messag
ePorts) |
| 267 { | 275 { |
| 268 return deserialize(v8::Isolate::GetCurrent(), messagePorts, 0); | 276 return deserialize(v8::Isolate::GetCurrent(), messagePorts, 0); |
| 269 } | 277 } |
| 270 | 278 |
| 271 v8::Local<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, Me
ssagePortArray* messagePorts, const WebBlobInfoArray* blobInfo) | 279 v8::Local<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, Me
ssagePortArray* messagePorts, const WebBlobInfoArray* blobInfo) |
| 272 { | 280 { |
| 281 // TODO(jbroman): Move the V8-based structured clone invocation into |
| 282 // SerializedScriptValueFactory. |
| 283 if (RuntimeEnabledFeatures::v8BasedStructuredCloneEnabled()) { |
| 284 V8ScriptValueDeserializer deserializer(ScriptState::current(isolate), th
is); |
| 285 return deserializer.deserialize(); |
| 286 } |
| 273 return SerializedScriptValueFactory::instance().deserialize(this, isolate, m
essagePorts, blobInfo); | 287 return SerializedScriptValueFactory::instance().deserialize(this, isolate, m
essagePorts, blobInfo); |
| 274 } | 288 } |
| 275 | 289 |
| 276 bool SerializedScriptValue::extractTransferables(v8::Isolate* isolate, v8::Local
<v8::Value> value, int argumentIndex, Transferables& transferables, ExceptionSta
te& exceptionState) | 290 bool SerializedScriptValue::extractTransferables(v8::Isolate* isolate, v8::Local
<v8::Value> value, int argumentIndex, Transferables& transferables, ExceptionSta
te& exceptionState) |
| 277 { | 291 { |
| 278 if (value.IsEmpty() || value->IsUndefined()) | 292 if (value.IsEmpty() || value->IsUndefined()) |
| 279 return true; | 293 return true; |
| 280 | 294 |
| 281 uint32_t length = 0; | 295 uint32_t length = 0; |
| 282 if (value->IsArray()) { | 296 if (value->IsArray()) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 366 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
| 353 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); | 367 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); |
| 354 } | 368 } |
| 355 | 369 |
| 356 bool SerializedScriptValue::containsTransferableArrayBuffer() const | 370 bool SerializedScriptValue::containsTransferableArrayBuffer() const |
| 357 { | 371 { |
| 358 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 372 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
| 359 } | 373 } |
| 360 | 374 |
| 361 } // namespace blink | 375 } // namespace blink |
| OLD | NEW |