OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007 Henry Mason (hmason@mac.com) | 2 * Copyright (C) 2007 Henry Mason (hmason@mac.com) |
3 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... | |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "core/events/MessageEvent.h" | 28 #include "core/events/MessageEvent.h" |
29 | 29 |
30 #include "bindings/core/v8/ExceptionMessages.h" | 30 #include "bindings/core/v8/ExceptionMessages.h" |
31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
32 #include "bindings/core/v8/V8ArrayBuffer.h" | 32 #include "bindings/core/v8/V8ArrayBuffer.h" |
33 #include "bindings/core/v8/V8PrivateProperty.h" | |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 static inline bool isValidSource(EventTarget* source) | 37 static inline bool isValidSource(EventTarget* source) |
37 { | 38 { |
38 return !source || source->toLocalDOMWindow() || source->toMessagePort(); | 39 return !source || source->toLocalDOMWindow() || source->toMessagePort(); |
39 } | 40 } |
40 | 41 |
41 MessageEvent::MessageEvent() | 42 MessageEvent::MessageEvent() |
42 : m_dataType(DataTypeScriptValue) | 43 : m_dataType(DataTypeScriptValue) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 visitor->trace(m_ports); | 212 visitor->trace(m_ports); |
212 Event::trace(visitor); | 213 Event::trace(visitor); |
213 } | 214 } |
214 | 215 |
215 v8::Local<v8::Object> MessageEvent::associateWithWrapper(v8::Isolate* isolate, c onst WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) | 216 v8::Local<v8::Object> MessageEvent::associateWithWrapper(v8::Isolate* isolate, c onst WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) |
216 { | 217 { |
217 wrapper = Event::associateWithWrapper(isolate, wrapperType, wrapper); | 218 wrapper = Event::associateWithWrapper(isolate, wrapperType, wrapper); |
218 | 219 |
219 // Ensures a wrapper is created for the data to return now so that V8 knows how | 220 // Ensures a wrapper is created for the data to return now so that V8 knows how |
220 // much memory is used via the wrapper. To keep the wrapper alive, it's set to | 221 // much memory is used via the wrapper. To keep the wrapper alive, it's set to |
221 // the wrapper of the MessageEvent as a hidden value. | 222 // the wrapper of the MessageEvent as a private value. |
222 switch (getDataType()) { | 223 switch (getDataType()) { |
223 case MessageEvent::DataTypeScriptValue: | 224 case MessageEvent::DataTypeScriptValue: |
224 case MessageEvent::DataTypeSerializedScriptValue: | 225 case MessageEvent::DataTypeSerializedScriptValue: |
225 break; | 226 break; |
226 case MessageEvent::DataTypeString: | 227 case MessageEvent::DataTypeString: |
227 V8HiddenValue::setHiddenValue(ScriptState::current(isolate), wrapper, V8 HiddenValue::stringData(isolate), v8String(isolate, dataAsString())); | 228 V8PrivateProperty::getMessageEventCachedData(isolate).set(wrapper, v8Str ing(isolate, dataAsString())); |
haraken
2016/05/24 17:33:53
Another possible API would be:
V8PrivatePropert
Ken Russell (switch to Gerrit)
2016/05/24 21:49:18
In this scenario, would the private property be as
Yuki
2016/05/26 10:52:11
Symbol class only holds two simple members, so the
| |
228 break; | 229 break; |
229 case MessageEvent::DataTypeBlob: | 230 case MessageEvent::DataTypeBlob: |
230 break; | 231 break; |
231 case MessageEvent::DataTypeArrayBuffer: | 232 case MessageEvent::DataTypeArrayBuffer: |
232 V8HiddenValue::setHiddenValue(ScriptState::current(isolate), wrapper, V8 HiddenValue::arrayBufferData(isolate), toV8(dataAsArrayBuffer(), wrapper, isolat e)); | 233 V8PrivateProperty::getMessageEventCachedData(isolate).set(wrapper, toV8( dataAsArrayBuffer(), wrapper, isolate)); |
233 break; | 234 break; |
234 } | 235 } |
235 | 236 |
236 return wrapper; | 237 return wrapper; |
237 } | 238 } |
238 | 239 |
239 } // namespace blink | 240 } // namespace blink |
OLD | NEW |