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

Unified Diff: Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp

Issue 1130113006: ServiceWorker: Introduce ServiceWorkerMessageEvent to replace MessageEvent (3/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: make more tests pass Created 5 years, 6 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
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
« no previous file with comments | « LayoutTests/webexposed/global-interface-listing-expected.txt ('k') | Source/bindings/modules/v8/custom/custom.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698