summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/bindings/v8/custom/V8ClientCustom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/bindings/v8/custom/V8ClientCustom.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/bindings/v8/custom/V8ClientCustom.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/bindings/v8/custom/V8ClientCustom.cpp b/chromium/third_party/WebKit/Source/bindings/v8/custom/V8ClientCustom.cpp
new file mode 100644
index 00000000000..b7975759511
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/bindings/v8/custom/V8ClientCustom.cpp
@@ -0,0 +1,39 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "bindings/modules/v8/V8Client.h"
+
+#include "bindings/v8/ExceptionMessages.h"
+#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/SerializedScriptValue.h"
+#include "bindings/v8/V8Binding.h"
+#include "core/dom/MessagePort.h"
+#include "modules/serviceworkers/ServiceWorker.h"
+#include "wtf/ArrayBuffer.h"
+
+namespace WebCore {
+
+void V8Client::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", "ServiceWorker", info.Holder(), info.GetIsolate());
+ Client* client = V8Client::toNative(info.Holder());
+ MessagePortArray ports;
+ ArrayBufferArray arrayBuffers;
+ if (info.Length() > 1) {
+ const int transferablesArgIndex = 1;
+ if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) {
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ }
+ RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(info[0], &ports, &arrayBuffers, exceptionState, info.GetIsolate());
+ if (exceptionState.throwIfNeeded())
+ return;
+ ExecutionContext* context = currentExecutionContext(info.GetIsolate());
+ client->postMessage(context, message.release(), &ports, exceptionState);
+ exceptionState.throwIfNeeded();
+}
+
+} // namespace WebCore