OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/modules/v8/V8ServiceWorkerMessageEvent.h" | 5 #include "bindings/modules/v8/V8ExtendableMessageEvent.h" |
6 | 6 |
7 #include "bindings/core/v8/SerializedScriptValue.h" | 7 #include "bindings/core/v8/SerializedScriptValue.h" |
8 #include "bindings/core/v8/V8HiddenValue.h" | 8 #include "bindings/core/v8/V8HiddenValue.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 void V8ServiceWorkerMessageEvent::dataAttributeGetterCustom(const v8::FunctionCa
llbackInfo<v8::Value>& info) | 12 void V8ExtendableMessageEvent::dataAttributeGetterCustom(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
13 { | 13 { |
14 ServiceWorkerMessageEvent* event = V8ServiceWorkerMessageEvent::toImpl(info.
Holder()); | 14 ExtendableMessageEvent* event = V8ExtendableMessageEvent::toImpl(info.Holder
()); |
15 v8::Isolate* isolate = info.GetIsolate(); | 15 v8::Isolate* isolate = info.GetIsolate(); |
16 ScriptState* scriptState = ScriptState::current(isolate); | 16 ScriptState* scriptState = ScriptState::current(isolate); |
17 v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(scriptState, inf
o.Holder(), V8HiddenValue::data(isolate)); | 17 v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(scriptState, inf
o.Holder(), V8HiddenValue::data(isolate)); |
18 | 18 |
19 if (!result.IsEmpty()) { | 19 if (!result.IsEmpty()) { |
20 v8SetReturnValue(info, result); | 20 v8SetReturnValue(info, result); |
21 return; | 21 return; |
22 } | 22 } |
23 | 23 |
24 v8::Local<v8::Value> data; | 24 v8::Local<v8::Value> data; |
25 if (SerializedScriptValue* serializedValue = event->serializedData()) { | 25 if (SerializedScriptValue* serializedValue = event->serializedData()) { |
26 MessagePortArray ports = event->ports(); | 26 MessagePortArray ports = event->ports(); |
27 data = serializedValue->deserialize(isolate, &ports); | 27 data = serializedValue->deserialize(isolate, &ports); |
28 } else { | 28 } else { |
29 data = event->data().v8ValueFor(scriptState); | 29 data = event->data().v8ValueFor(scriptState); |
30 } | 30 } |
31 if (data.IsEmpty()) | 31 if (data.IsEmpty()) |
32 data = v8::Null(isolate); | 32 data = v8::Null(isolate); |
33 V8HiddenValue::setHiddenValue(scriptState, info.Holder(), V8HiddenValue::dat
a(isolate), data); | 33 V8HiddenValue::setHiddenValue(scriptState, info.Holder(), V8HiddenValue::dat
a(isolate), data); |
34 v8SetReturnValue(info, data); | 34 v8SetReturnValue(info, data); |
35 } | 35 } |
36 | 36 |
37 } // namespace blink | 37 } // namespace blink |
OLD | NEW |