Index: Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp |
diff --git a/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp b/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5746d7ef35db2f0f3f8bd7ccc6d81b3b9b1afa84 |
--- /dev/null |
+++ b/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp |
@@ -0,0 +1,37 @@ |
+// Copyright 2015 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/V8ServiceWorkerMessageEvent.h" |
+ |
+#include "bindings/core/v8/SerializedScriptValue.h" |
+#include "bindings/core/v8/V8HiddenValue.h" |
+ |
+namespace blink { |
+ |
+void V8ServiceWorkerMessageEvent::dataAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ ServiceWorkerMessageEvent* event = V8ServiceWorkerMessageEvent::toImpl(info.Holder()); |
+ v8::Isolate* isolate = info.GetIsolate(); |
+ v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(isolate, info.Holder(), V8HiddenValue::data(isolate)); |
+ |
+ if (!result.IsEmpty()) { |
+ v8SetReturnValue(info, result); |
+ return; |
+ } |
+ |
+ v8::Local<v8::Value> data; |
+ if (SerializedScriptValue* serializedValue = event->serializedData()) { |
+ MessagePortArray ports = event->ports(); |
+ data = serializedValue->deserialize(isolate, &ports); |
+ } else { |
+ data = event->data().v8ValueFor(ScriptState::current(isolate)); |
+ } |
+ if (data.IsEmpty()) |
+ data = v8::Null(isolate); |
+ V8HiddenValue::setHiddenValue(isolate, info.Holder(), V8HiddenValue::data(isolate), data); |
+ v8SetReturnValue(info, data); |
+} |
+ |
+} // namespace blink |