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

Unified Diff: Source/bindings/templates/methods.cpp

Issue 1149623004: [bindings] Implment postMessageImpl and replace the usage of postMessageMethodCommon. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/results/core/V8TestObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 50c344af3ab500a04f7a3b067982e12718fdeff7..46e97081ae8c9e5396f5e408a40345e7fce65ab8 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -444,6 +444,35 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
{##############################################################################}
+{% macro generate_post_message_impl() %}
+void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance, const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", interfaceName, info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 1)) {
+ setMinimumArityTypeError(exceptionState, 1, info.Length());
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ OwnPtrWillBeRawPtr<MessagePortArray> ports = adoptPtrWillBeNoop(new MessagePortArray);
+ ArrayBufferArray arrayBuffers;
+ if (info.Length() > 1) {
+ const int transferablesArgIndex = 1;
+ if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info[transferablesArgIndex], transferablesArgIndex, *ports, arrayBuffers, exceptionState)) {
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ }
+ RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instance().create(info.GetIsolate(), info[0], ports.get(), &arrayBuffers, exceptionState);
+ if (exceptionState.throwIfNeeded())
+ return;
+ // FIXME: Only pass context/exceptionState if instance really requires it.
+ ExecutionContext* context = currentExecutionContext(info.GetIsolate());
+ instance->postMessage(context, message.release(), ports.get(), exceptionState);
+ exceptionState.throwIfNeeded();
+}
+{% endmacro %}
+
+{##############################################################################}
{% macro method_callback(method, world_suffix) %}
{% filter conditional(method.conditional_string) %}
static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
@@ -473,7 +502,7 @@ static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
{% if method.is_custom %}
{{v8_class}}::{{method.name}}MethodCustom(info);
{% elif method.is_post_message %}
- postMessageMethodCommon("{{interface_name}}", {{v8_class}}::toImpl(info.Holder()), info);
+ postMessageImpl("{{interface_name}}", {{v8_class}}::toImpl(info.Holder()), info);
{% else %}
{{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
{% endif %}
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/results/core/V8TestObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698