Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PostMessage_h | 5 #ifndef PostMessage_h |
| 6 #define PostMessage_h | 6 #define PostMessage_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/SerializedScriptValue.h" | 9 #include "bindings/core/v8/SerializedScriptValue.h" |
| 10 #include "bindings/core/v8/SerializedScriptValueFactory.h" | |
| 10 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
| 11 #include "bindings/core/v8/V8BindingMacros.h" | 12 #include "bindings/core/v8/V8BindingMacros.h" |
| 12 #include "core/dom/DOMArrayBuffer.h" | 13 #include "core/dom/DOMArrayBuffer.h" |
| 13 #include "core/dom/MessagePort.h" | 14 #include "core/dom/MessagePort.h" |
| 14 #include <v8.h> | 15 #include <v8.h> |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 class ExecutionContext; | 19 class ExecutionContext; |
| 19 | 20 |
| 20 // FIXME: This should be auto-generated by a code generator template. | 21 // FIXME: This should be auto-generated by a code generator template. |
| 21 template <class Type> | 22 template <class Type> |
| 22 void postMessageMethodCommon(const char* interfaceName, Type* instance, const v8 ::FunctionCallbackInfo<v8::Value>& info) | 23 void postMessageMethodCommon(const char* interfaceName, Type* instance, const v8 ::FunctionCallbackInfo<v8::Value>& info) |
| 23 { | 24 { |
| 24 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage ", interfaceName, info.Holder(), info.GetIsolate()); | 25 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage ", interfaceName, info.Holder(), info.GetIsolate()); |
| 25 MessagePortArray ports; | 26 MessagePortArray ports; |
| 26 ArrayBufferArray arrayBuffers; | 27 ArrayBufferArray arrayBuffers; |
| 27 if (info.Length() > 1) { | 28 if (info.Length() > 1) { |
| 28 const int transferablesArgIndex = 1; | 29 const int transferablesArgIndex = 1; |
| 29 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info [transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionSt ate)) { | 30 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info [transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionSt ate)) { |
| 30 exceptionState.throwIfNeeded(); | 31 exceptionState.throwIfNeeded(); |
| 31 return; | 32 return; |
| 32 } | 33 } |
| 33 } | 34 } |
| 34 RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(info[0 ], &ports, &arrayBuffers, exceptionState, info.GetIsolate()); | 35 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::factor y().create(info[0], &ports, &arrayBuffers, exceptionState, info.GetIsolate()); |
|
haraken
2014/11/17 01:27:49
factory => instance (We normally use "instance" fo
tasak
2014/11/17 08:42:30
Done.
| |
| 35 if (exceptionState.throwIfNeeded()) | 36 if (exceptionState.throwIfNeeded()) |
| 36 return; | 37 return; |
| 37 // FIXME: Only pass context/exceptionState if instance really requires it. | 38 // FIXME: Only pass context/exceptionState if instance really requires it. |
| 38 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); | 39 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); |
| 39 instance->postMessage(context, message.release(), &ports, exceptionState); | 40 instance->postMessage(context, message.release(), &ports, exceptionState); |
| 40 exceptionState.throwIfNeeded(); | 41 exceptionState.throwIfNeeded(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 } // namespace blink | 44 } // namespace blink |
| 44 | 45 |
| 45 #endif // PostMessage_h | 46 #endif // PostMessage_h |
| OLD | NEW |