Chromium Code Reviews| 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..ee13979bafcf1e9dc17efe344d983d1c7abdd422 |
| --- /dev/null |
| +++ b/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp |
| @@ -0,0 +1,42 @@ |
| +// 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 { |
| + |
| +static v8::Local<v8::Value> cacheState(v8::Isolate* isolate, v8::Local<v8::Object> event, v8::Local<v8::Value> data) |
|
haraken
2015/06/25 04:18:48
Can we remove this helper function?
xiang
2015/06/29 02:32:24
Done.
|
| +{ |
| + V8HiddenValue::setHiddenValue(isolate, event, V8HiddenValue::data(isolate), data); |
| + return data; |
| +} |
| + |
| +void V8ServiceWorkerMessageEvent::dataAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) |
| +{ |
| + ServiceWorkerMessageEvent* event = V8ServiceWorkerMessageEvent::toImpl(info.Holder()); |
| + |
| + v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate())); |
| + |
| + if (!result.IsEmpty()) { |
| + v8SetReturnValue(info, result); |
| + return; |
| + } |
| + |
| + v8::Local<v8::Value> data; |
| + if (SerializedScriptValue* serializedValue = event->serializedData()) { |
| + MessagePortArray ports = event->ports(); |
| + data = serializedValue->deserialize(info.GetIsolate(), &ports); |
| + } else { |
| + data = event->data().v8ValueFor(ScriptState::current(info.GetIsolate())); |
| + } |
| + if (data.IsEmpty()) |
| + data = v8::Null(info.GetIsolate()); |
| + v8SetReturnValue(info, cacheState(info.GetIsolate(), info.Holder(), data)); |
| +} |
| + |
| +} // namespace blink |