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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 for (size_t i = 0; i < arrayBuffers.size(); i++) { | 131 for (size_t i = 0; i < arrayBuffers.size(); i++) { |
132 if (arrayBuffers[i]->isNeutered()) { | 132 if (arrayBuffers[i]->isNeutered()) { |
133 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " is already neutered."); | 133 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " is already neutered."); |
134 return nullptr; | 134 return nullptr; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 OwnPtr<ArrayBufferContentsArray> contents = adoptPtr(new ArrayBufferContents
Array(arrayBuffers.size())); | 138 OwnPtr<ArrayBufferContentsArray> contents = adoptPtr(new ArrayBufferContents
Array(arrayBuffers.size())); |
139 | 139 |
140 HeapHashSet<Member<DOMArrayBufferBase>> visited; | 140 HashSet<DOMArrayBufferBase*> visited; |
141 for (size_t i = 0; i < arrayBuffers.size(); i++) { | 141 for (size_t i = 0; i < arrayBuffers.size(); i++) { |
142 if (visited.contains(arrayBuffers[i].get())) | 142 if (visited.contains(arrayBuffers[i].get())) |
143 continue; | 143 continue; |
144 visited.add(arrayBuffers[i].get()); | 144 visited.add(arrayBuffers[i].get()); |
145 | 145 |
146 if (arrayBuffers[i]->isShared()) { | 146 if (arrayBuffers[i]->isShared()) { |
147 bool result = arrayBuffers[i]->shareContentsWith(contents->at(i)); | 147 bool result = arrayBuffers[i]->shareContentsWith(contents->at(i)); |
148 if (!result) { | 148 if (!result) { |
149 exceptionState.throwDOMException(DataCloneError, "SharedArrayBuf
fer at index " + String::number(i) + " could not be transferred."); | 149 exceptionState.throwDOMException(DataCloneError, "SharedArrayBuf
fer at index " + String::number(i) + " could not be transferred."); |
150 return nullptr; | 150 return nullptr; |
151 } | 151 } |
152 } else { | 152 } else { |
153 Vector<v8::Local<v8::ArrayBuffer>, 4> bufferHandles; | 153 Vector<v8::Local<v8::ArrayBuffer>, 4> bufferHandles; |
154 v8::HandleScope handleScope(isolate); | 154 v8::HandleScope handleScope(isolate); |
155 acculumateArrayBuffersForAllWorlds(isolate, static_cast<DOMArrayBuff
er*>(arrayBuffers[i].get()), bufferHandles); | 155 acculumateArrayBuffersForAllWorlds(isolate, static_pointer_cast<DOMA
rrayBuffer>(arrayBuffers[i]).get(), bufferHandles); |
156 bool isNeuterable = true; | 156 bool isNeuterable = true; |
157 for (size_t j = 0; j < bufferHandles.size(); j++) | 157 for (size_t j = 0; j < bufferHandles.size(); j++) |
158 isNeuterable &= bufferHandles[j]->IsNeuterable(); | 158 isNeuterable &= bufferHandles[j]->IsNeuterable(); |
159 | 159 |
160 DOMArrayBufferBase* toTransfer = arrayBuffers[i]; | 160 RefPtr<DOMArrayBufferBase> toTransfer = arrayBuffers[i]; |
161 if (!isNeuterable) | 161 if (!isNeuterable) |
162 toTransfer = DOMArrayBuffer::create(arrayBuffers[i]->buffer()); | 162 toTransfer = DOMArrayBuffer::create(arrayBuffers[i]->buffer()); |
163 bool result = toTransfer->transfer(contents->at(i)); | 163 bool result = toTransfer->transfer(contents->at(i)); |
164 if (!result) { | 164 if (!result) { |
165 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at
index " + String::number(i) + " could not be transferred."); | 165 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at
index " + String::number(i) + " could not be transferred."); |
166 return nullptr; | 166 return nullptr; |
167 } | 167 } |
168 | 168 |
169 if (isNeuterable) | 169 if (isNeuterable) |
170 for (size_t j = 0; j < bufferHandles.size(); j++) | 170 for (size_t j = 0; j < bufferHandles.size(); j++) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // Validation of Objects implementing an interface, per WebIDL spec 4.1.
15. | 226 // Validation of Objects implementing an interface, per WebIDL spec 4.1.
15. |
227 if (V8MessagePort::hasInstance(transferrable, isolate)) { | 227 if (V8MessagePort::hasInstance(transferrable, isolate)) { |
228 MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cas
t(transferrable)); | 228 MessagePort* port = V8MessagePort::toImpl(v8::Local<v8::Object>::Cas
t(transferrable)); |
229 // Check for duplicate MessagePorts. | 229 // Check for duplicate MessagePorts. |
230 if (ports.contains(port)) { | 230 if (ports.contains(port)) { |
231 exceptionState.throwDOMException(DataCloneError, "Message port a
t index " + String::number(i) + " is a duplicate of an earlier port."); | 231 exceptionState.throwDOMException(DataCloneError, "Message port a
t index " + String::number(i) + " is a duplicate of an earlier port."); |
232 return false; | 232 return false; |
233 } | 233 } |
234 ports.append(port); | 234 ports.append(port); |
235 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) { | 235 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) { |
236 DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(v8::Local<v8::Ob
ject>::Cast(transferrable)); | 236 RefPtr<DOMArrayBuffer> arrayBuffer = V8ArrayBuffer::toImpl(v8::Local
<v8::Object>::Cast(transferrable)); |
237 if (arrayBuffers.contains(arrayBuffer)) { | 237 if (arrayBuffers.contains(arrayBuffer)) { |
238 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at
index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer."); | 238 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at
index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer."); |
239 return false; | 239 return false; |
240 } | 240 } |
241 arrayBuffers.append(arrayBuffer); | 241 arrayBuffers.append(arrayBuffer.release()); |
242 } else if (V8SharedArrayBuffer::hasInstance(transferrable, isolate)) { | 242 } else if (V8SharedArrayBuffer::hasInstance(transferrable, isolate)) { |
243 DOMSharedArrayBuffer* sharedArrayBuffer = V8SharedArrayBuffer::toImp
l(v8::Local<v8::Object>::Cast(transferrable)); | 243 RefPtr<DOMSharedArrayBuffer> sharedArrayBuffer = V8SharedArrayBuffer
::toImpl(v8::Local<v8::Object>::Cast(transferrable)); |
244 if (arrayBuffers.contains(sharedArrayBuffer)) { | 244 if (arrayBuffers.contains(sharedArrayBuffer)) { |
245 exceptionState.throwDOMException(DataCloneError, "SharedArrayBuf
fer at index " + String::number(i) + " is a duplicate of an earlier SharedArrayB
uffer."); | 245 exceptionState.throwDOMException(DataCloneError, "SharedArrayBuf
fer at index " + String::number(i) + " is a duplicate of an earlier SharedArrayB
uffer."); |
246 return false; | 246 return false; |
247 } | 247 } |
248 arrayBuffers.append(sharedArrayBuffer); | 248 arrayBuffers.append(sharedArrayBuffer.release()); |
249 } else if (V8ImageBitmap::hasInstance(transferrable, isolate)) { | 249 } else if (V8ImageBitmap::hasInstance(transferrable, isolate)) { |
250 ImageBitmap* imageBitmap = V8ImageBitmap::toImpl(v8::Local<v8::Objec
t>::Cast(transferrable)); | 250 RawPtr<ImageBitmap> imageBitmap = V8ImageBitmap::toImpl(v8::Local<v8
::Object>::Cast(transferrable)); |
251 if (imageBitmaps.contains(imageBitmap)) { | 251 if (imageBitmaps.contains(imageBitmap)) { |
252 exceptionState.throwDOMException(DataCloneError, "ImageBitmap at
index " + String::number(i) + " is a duplicate of an earlier ImageBitmap."); | 252 exceptionState.throwDOMException(DataCloneError, "ImageBitmap at
index " + String::number(i) + " is a duplicate of an earlier ImageBitmap."); |
253 return false; | 253 return false; |
254 } | 254 } |
255 imageBitmaps.append(imageBitmap); | 255 imageBitmaps.append(imageBitmap.release()); |
256 } else { | 256 } else { |
257 exceptionState.throwTypeError("Value at index " + String::number(i)
+ " does not have a transferable type."); | 257 exceptionState.throwTypeError("Value at index " + String::number(i)
+ " does not have a transferable type."); |
258 return false; | 258 return false; |
259 } | 259 } |
260 } | 260 } |
261 return true; | 261 return true; |
262 } | 262 } |
263 | 263 |
264 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() | 264 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() |
265 { | 265 { |
(...skipping 23 matching lines...) Expand all Loading... |
289 { | 289 { |
290 m_arrayBufferContentsArray = createArrayBuffers(isolate, arrayBuffers, excep
tionState); | 290 m_arrayBufferContentsArray = createArrayBuffers(isolate, arrayBuffers, excep
tionState); |
291 } | 291 } |
292 | 292 |
293 void SerializedScriptValue::transferImageBitmaps(v8::Isolate* isolate, ImageBitm
apArray& imageBitmaps, ExceptionState& exceptionState) | 293 void SerializedScriptValue::transferImageBitmaps(v8::Isolate* isolate, ImageBitm
apArray& imageBitmaps, ExceptionState& exceptionState) |
294 { | 294 { |
295 m_imageBitmapContentsArray = createImageBitmaps(isolate, imageBitmaps, excep
tionState); | 295 m_imageBitmapContentsArray = createImageBitmaps(isolate, imageBitmaps, excep
tionState); |
296 } | 296 } |
297 | 297 |
298 } // namespace blink | 298 } // namespace blink |
OLD | NEW |