| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "bindings/core/v8/SerializedScriptValue.h" | 31 #include "bindings/core/v8/SerializedScriptValue.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/DOMDataStore.h" | 33 #include "bindings/core/v8/DOMDataStore.h" |
| 34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 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/TransferableExtractor.h" |
| 39 #include "bindings/core/v8/Transferables.h" | 40 #include "bindings/core/v8/Transferables.h" |
| 40 #include "bindings/core/v8/V8ArrayBuffer.h" | 41 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 41 #include "bindings/core/v8/V8ImageBitmap.h" | 42 #include "bindings/core/v8/V8ImageBitmap.h" |
| 42 #include "bindings/core/v8/V8MessagePort.h" | 43 #include "bindings/core/v8/V8MessagePort.h" |
| 43 #include "bindings/core/v8/V8SharedArrayBuffer.h" | 44 #include "bindings/core/v8/V8SharedArrayBuffer.h" |
| 44 #include "core/dom/DOMArrayBuffer.h" | 45 #include "core/dom/DOMArrayBuffer.h" |
| 45 #include "core/dom/DOMSharedArrayBuffer.h" | 46 #include "core/dom/DOMSharedArrayBuffer.h" |
| 46 #include "core/dom/ExceptionCode.h" | 47 #include "core/dom/ExceptionCode.h" |
| 47 #include "core/dom/MessagePort.h" | 48 #include "core/dom/MessagePort.h" |
| 48 #include "core/frame/ImageBitmap.h" | 49 #include "core/frame/ImageBitmap.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 if (value->IsArray()) { | 219 if (value->IsArray()) { |
| 219 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value); | 220 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value); |
| 220 length = array->Length(); | 221 length = array->Length(); |
| 221 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 222 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 222 if (!exceptionState.hadException()) | 223 if (!exceptionState.hadException()) |
| 223 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex + 1)); | 224 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex + 1)); |
| 224 return false; | 225 return false; |
| 225 } | 226 } |
| 226 | 227 |
| 227 v8::Local<v8::Object> transferableArray = v8::Local<v8::Object>::Cast(value)
; | 228 v8::Local<v8::Object> transferableArray = v8::Local<v8::Object>::Cast(value)
; |
| 229 Vector<OwnPtr<TransferableExtractor>> extractors; |
| 228 | 230 |
| 229 // Validate the passed array of transferables. | 231 // Validate the passed array of transferables. |
| 230 for (unsigned i = 0; i < length; ++i) { | 232 for (unsigned i = 0; i < length; ++i) { |
| 231 v8::Local<v8::Value> transferableObject; | 233 v8::Local<v8::Value> transferableObject; |
| 232 if (!transferableArray->Get(isolate->GetCurrentContext(), i).ToLocal(&tr
ansferableObject)) | 234 if (!transferableArray->Get(isolate->GetCurrentContext(), i).ToLocal(&tr
ansferableObject)) |
| 233 return false; | 235 return false; |
| 234 // Validation of non-null objects, per HTML5 spec 10.3.3. | 236 // Validation of non-null objects, per HTML5 spec 10.3.3. |
| 235 if (isUndefinedOrNull(transferableObject)) { | 237 if (isUndefinedOrNull(transferableObject)) { |
| 236 exceptionState.throwTypeError("Value at index " + String::number(i)
+ " is an untransferable " + (transferableObject->IsUndefined() ? "'undefined'"
: "'null'") + " value."); | 238 exceptionState.throwTypeError("Value at index " + String::number(i)
+ " is an untransferable " + (transferableObject->IsUndefined() ? "'undefined'"
: "'null'") + " value."); |
| 237 return false; | 239 return false; |
| 238 } | 240 } |
| 241 bool extractorDoneFlag = false; |
| 242 for (const auto& ex : TransferableExtractor::getExtractors()) { |
| 243 if (ex->extract(transferableObject, isolate, transferables, exceptio
nState, i)) { |
| 244 extractorDoneFlag = true; |
| 245 break; |
| 246 } |
| 247 } |
| 248 if (extractorDoneFlag) |
| 249 break; |
| 239 // Validation of Objects implementing an interface, per WebIDL spec 4.1.
15. | 250 // Validation of Objects implementing an interface, per WebIDL spec 4.1.
15. |
| 240 if (V8MessagePort::hasInstance(transferableObject, isolate)) { | 251 if (V8MessagePort::hasInstance(transferableObject, isolate)) { |
| 241 MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cas
t(transferableObject)); | 252 MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cas
t(transferableObject)); |
| 242 // Check for duplicate MessagePorts. | 253 // Check for duplicate MessagePorts. |
| 243 if (transferables.messagePorts.contains(port)) { | 254 if (transferables.messagePorts.contains(port)) { |
| 244 exceptionState.throwDOMException(DataCloneError, "Message port a
t index " + String::number(i) + " is a duplicate of an earlier port."); | 255 exceptionState.throwDOMException(DataCloneError, "Message port a
t index " + String::number(i) + " is a duplicate of an earlier port."); |
| 245 return false; | 256 return false; |
| 246 } | 257 } |
| 247 transferables.messagePorts.append(port); | 258 transferables.messagePorts.append(port); |
| 248 } else if (V8ArrayBuffer::hasInstance(transferableObject, isolate)) { | 259 } else if (V8ArrayBuffer::hasInstance(transferableObject, isolate)) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 292 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
| 282 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); | 293 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); |
| 283 } | 294 } |
| 284 | 295 |
| 285 bool SerializedScriptValue::containsTransferableArrayBuffer() const | 296 bool SerializedScriptValue::containsTransferableArrayBuffer() const |
| 286 { | 297 { |
| 287 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 298 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
| 288 } | 299 } |
| 289 | 300 |
| 290 } // namespace blink | 301 } // namespace blink |
| OLD | NEW |