| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "V8Worker.h" | 32 #include "V8Worker.h" |
| 33 | 33 |
| 34 #include "bindings/v8/ExceptionMessages.h" | 34 #include "bindings/v8/ExceptionMessages.h" |
| 35 #include "bindings/v8/ExceptionState.h" | 35 #include "bindings/v8/ExceptionState.h" |
| 36 #include "bindings/v8/SerializedScriptValue.h" | 36 #include "bindings/v8/SerializedScriptValue.h" |
| 37 #include "bindings/v8/V8Binding.h" | 37 #include "bindings/v8/V8Binding.h" |
| 38 #include "bindings/v8/V8Utilities.h" | |
| 39 #include "core/workers/Worker.h" | 38 #include "core/workers/Worker.h" |
| 40 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
| 41 #include "wtf/ArrayBuffer.h" | 40 #include "wtf/ArrayBuffer.h" |
| 42 | 41 |
| 43 namespace WebCore { | 42 namespace WebCore { |
| 44 | 43 |
| 45 void V8Worker::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) | 44 void V8Worker::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 46 { | 45 { |
| 47 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Worker", info.Holder(), info.GetIsolate()); | 46 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Worker", info.Holder(), info.GetIsolate()); |
| 48 Worker* worker = V8Worker::toNative(info.Holder()); | 47 Worker* worker = V8Worker::toNative(info.Holder()); |
| 49 MessagePortArray ports; | 48 MessagePortArray ports; |
| 50 ArrayBufferArray arrayBuffers; | 49 ArrayBufferArray arrayBuffers; |
| 51 if (info.Length() > 1) { | 50 if (info.Length() > 1) { |
| 52 const int transferablesArgIndex = 1; | 51 const int transferablesArgIndex = 1; |
| 53 if (!extractTransferables(info[transferablesArgIndex], transferablesArgI
ndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) { | 52 if (!SerializedScriptValue::extractTransferables(info[transferablesArgIn
dex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolat
e())) { |
| 54 exceptionState.throwIfNeeded(); | 53 exceptionState.throwIfNeeded(); |
| 55 return; | 54 return; |
| 56 } | 55 } |
| 57 } | 56 } |
| 58 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(info[0
], &ports, &arrayBuffers, exceptionState, info.GetIsolate()); | 57 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(info[0
], &ports, &arrayBuffers, exceptionState, info.GetIsolate()); |
| 59 if (exceptionState.throwIfNeeded()) | 58 if (exceptionState.throwIfNeeded()) |
| 60 return; | 59 return; |
| 61 worker->postMessage(message.release(), &ports, exceptionState); | 60 worker->postMessage(message.release(), &ports, exceptionState); |
| 62 exceptionState.throwIfNeeded(); | 61 exceptionState.throwIfNeeded(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 } // namespace WebCore | 64 } // namespace WebCore |
| OLD | NEW |