| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value); | 179 v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value); |
| 180 | 180 |
| 181 // Validate the passed array of transferrables. | 181 // Validate the passed array of transferrables. |
| 182 for (unsigned i = 0; i < length; ++i) { | 182 for (unsigned i = 0; i < length; ++i) { |
| 183 v8::Local<v8::Value> transferrable = transferrables->Get(i); | 183 v8::Local<v8::Value> transferrable = transferrables->Get(i); |
| 184 // Validation of non-null objects, per HTML5 spec 10.3.3. | 184 // Validation of non-null objects, per HTML5 spec 10.3.3. |
| 185 if (isUndefinedOrNull(transferrable)) { | 185 if (isUndefinedOrNull(transferrable)) { |
| 186 exceptionState.throwDOMException(DataCloneError, "Value at index " +
String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ?
"'undefined'" : "'null'") + " value."); | 186 exceptionState.throwTypeError("Value at index " + String::number(i)
+ " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'n
ull'") + " value."); |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| 189 // Validation of Objects implementing an interface, per WebIDL spec 4.1.
15. | 189 // Validation of Objects implementing an interface, per WebIDL spec 4.1.
15. |
| 190 if (V8MessagePort::hasInstance(transferrable, isolate)) { | 190 if (V8MessagePort::hasInstance(transferrable, isolate)) { |
| 191 RefPtrWillBeRawPtr<MessagePort> port = V8MessagePort::toImpl(v8::Han
dle<v8::Object>::Cast(transferrable)); | 191 RefPtrWillBeRawPtr<MessagePort> port = V8MessagePort::toImpl(v8::Han
dle<v8::Object>::Cast(transferrable)); |
| 192 // Check for duplicate MessagePorts. | 192 // Check for duplicate MessagePorts. |
| 193 if (ports.contains(port)) { | 193 if (ports.contains(port)) { |
| 194 exceptionState.throwDOMException(DataCloneError, "Message port a
t index " + String::number(i) + " is a duplicate of an earlier port."); | 194 exceptionState.throwDOMException(DataCloneError, "Message port a
t index " + String::number(i) + " is a duplicate of an earlier port."); |
| 195 return false; | 195 return false; |
| 196 } | 196 } |
| 197 ports.append(port.release()); | 197 ports.append(port.release()); |
| 198 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) { | 198 } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) { |
| 199 RefPtr<DOMArrayBuffer> arrayBuffer = V8ArrayBuffer::toImpl(v8::Handl
e<v8::Object>::Cast(transferrable)); | 199 RefPtr<DOMArrayBuffer> arrayBuffer = V8ArrayBuffer::toImpl(v8::Handl
e<v8::Object>::Cast(transferrable)); |
| 200 if (arrayBuffers.contains(arrayBuffer)) { | 200 if (arrayBuffers.contains(arrayBuffer)) { |
| 201 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at
index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer."); | 201 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at
index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer."); |
| 202 return false; | 202 return false; |
| 203 } | 203 } |
| 204 arrayBuffers.append(arrayBuffer.release()); | 204 arrayBuffers.append(arrayBuffer.release()); |
| 205 } else { | 205 } else { |
| 206 exceptionState.throwDOMException(DataCloneError, "Value at index " +
String::number(i) + " does not have a transferable type."); | 206 exceptionState.throwTypeError("Value at index " + String::number(i)
+ " does not have a transferable type."); |
| 207 return false; | 207 return false; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() | 213 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() |
| 214 { | 214 { |
| 215 if (m_externallyAllocatedMemory) | 215 if (m_externallyAllocatedMemory) |
| 216 return; | 216 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 228 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 228 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 void SerializedScriptValue::transferArrayBuffers(v8::Isolate* isolate, ArrayBuff
erArray& arrayBuffers, ExceptionState& exceptionState) | 232 void SerializedScriptValue::transferArrayBuffers(v8::Isolate* isolate, ArrayBuff
erArray& arrayBuffers, ExceptionState& exceptionState) |
| 233 { | 233 { |
| 234 m_arrayBufferContentsArray = createArrayBuffers(isolate, arrayBuffers, excep
tionState); | 234 m_arrayBufferContentsArray = createArrayBuffers(isolate, arrayBuffers, excep
tionState); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |