Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp

Issue 1862033002: Make OffscreenCanvas Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update layout test results Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
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/TransferableArrayBuffer.h" 39 #include "bindings/core/v8/TransferableArrayBuffer.h"
40 #include "bindings/core/v8/TransferableExtractor.h"
40 #include "bindings/core/v8/TransferableImageBitmap.h" 41 #include "bindings/core/v8/TransferableImageBitmap.h"
41 #include "bindings/core/v8/V8ArrayBuffer.h" 42 #include "bindings/core/v8/V8ArrayBuffer.h"
42 #include "bindings/core/v8/V8ImageBitmap.h" 43 #include "bindings/core/v8/V8ImageBitmap.h"
43 #include "bindings/core/v8/V8MessagePort.h" 44 #include "bindings/core/v8/V8MessagePort.h"
44 #include "bindings/core/v8/V8SharedArrayBuffer.h" 45 #include "bindings/core/v8/V8SharedArrayBuffer.h"
45 #include "core/dom/ExceptionCode.h" 46 #include "core/dom/ExceptionCode.h"
46 #include "platform/SharedBuffer.h" 47 #include "platform/SharedBuffer.h"
47 #include "platform/blob/BlobData.h" 48 #include "platform/blob/BlobData.h"
48 #include "platform/heap/Handle.h" 49 #include "platform/heap/Handle.h"
49 #include "wtf/Assertions.h" 50 #include "wtf/Assertions.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (value->IsArray()) { 209 if (value->IsArray()) {
209 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value); 210 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
210 length = array->Length(); 211 length = array->Length();
211 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { 212 } else if (!toV8Sequence(value, length, isolate, exceptionState)) {
212 if (!exceptionState.hadException()) 213 if (!exceptionState.hadException())
213 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(argumentIndex + 1)); 214 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(argumentIndex + 1));
214 return false; 215 return false;
215 } 216 }
216 217
217 v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value); 218 v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value);
219 Vector<OwnPtr<TransferableExtractor>> extractors;
218 220
219 // Validate the passed array of transferrables. 221 // Validate the passed array of transferrables.
220 for (unsigned i = 0; i < length; ++i) { 222 for (unsigned i = 0; i < length; ++i) {
221 v8::Local<v8::Value> transferrable; 223 v8::Local<v8::Value> transferrable;
222 if (!transferrables->Get(isolate->GetCurrentContext(), i).ToLocal(&trans ferrable)) 224 if (!transferrables->Get(isolate->GetCurrentContext(), i).ToLocal(&trans ferrable))
223 return false; 225 return false;
224 // Validation of non-null objects, per HTML5 spec 10.3.3. 226 // Validation of non-null objects, per HTML5 spec 10.3.3.
225 if (isUndefinedOrNull(transferrable)) { 227 if (isUndefinedOrNull(transferrable)) {
226 exceptionState.throwTypeError("Value at index " + String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'n ull'") + " value."); 228 exceptionState.throwTypeError("Value at index " + String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'n ull'") + " value.");
227 return false; 229 return false;
228 } 230 }
231 bool extractorDoneFlag = false;
232 for (const auto& ex : TransferableExtractor::getExtractors()) {
233 if (ex->extract(transferrable, isolate, transferables, exceptionStat e, i)) {
234 extractorDoneFlag = true;
235 break;
236 }
237 }
238 if (extractorDoneFlag)
239 break;
229 // Validation of Objects implementing an interface, per WebIDL spec 4.1. 15. 240 // Validation of Objects implementing an interface, per WebIDL spec 4.1. 15.
230 if (V8MessagePort::hasInstance(transferrable, isolate)) { 241 if (V8MessagePort::hasInstance(transferrable, isolate)) {
231 MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cas t(transferrable)); 242 MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cas t(transferrable));
232 // Check for duplicate MessagePorts. 243 // Check for duplicate MessagePorts.
233 if (ports.contains(port)) { 244 if (ports.contains(port)) {
234 exceptionState.throwDOMException(DataCloneError, "Message port a t index " + String::number(i) + " is a duplicate of an earlier port."); 245 exceptionState.throwDOMException(DataCloneError, "Message port a t index " + String::number(i) + " is a duplicate of an earlier port.");
235 return false; 246 return false;
236 } 247 }
237 ports.append(port); 248 ports.append(port);
238 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) { 249 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 { 306 {
296 m_arrayBufferContentsArray = createArrayBuffers(isolate, transferableArrayBu ffers, exceptionState); 307 m_arrayBufferContentsArray = createArrayBuffers(isolate, transferableArrayBu ffers, exceptionState);
297 } 308 }
298 309
299 void SerializedScriptValue::transferImageBitmaps(v8::Isolate* isolate, Transfera bleImageBitmap* transferableImageBitmaps, ExceptionState& exceptionState) 310 void SerializedScriptValue::transferImageBitmaps(v8::Isolate* isolate, Transfera bleImageBitmap* transferableImageBitmaps, ExceptionState& exceptionState)
300 { 311 {
301 m_imageBitmapContentsArray = createImageBitmaps(isolate, transferableImageBi tmaps, exceptionState); 312 m_imageBitmapContentsArray = createImageBitmaps(isolate, transferableImageBi tmaps, exceptionState);
302 } 313 }
303 314
304 } // namespace blink 315 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698