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 13 matching lines...) Expand all Loading... |
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 #include "bindings/core/v8/V8PrivateProperty.h" |
| 34 #include <memory> |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 static inline bool isValidSource(EventTarget* source) | 38 static inline bool isValidSource(EventTarget* source) |
38 { | 39 { |
39 return !source || source->toLocalDOMWindow() || source->toMessagePort(); | 40 return !source || source->toLocalDOMWindow() || source->toMessagePort(); |
40 } | 41 } |
41 | 42 |
42 MessageEvent::MessageEvent() | 43 MessageEvent::MessageEvent() |
43 : m_dataType(DataTypeScriptValue) | 44 : m_dataType(DataTypeScriptValue) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 , m_origin(origin) | 81 , m_origin(origin) |
81 , m_lastEventId(lastEventId) | 82 , m_lastEventId(lastEventId) |
82 , m_source(source) | 83 , m_source(source) |
83 , m_ports(ports) | 84 , m_ports(ports) |
84 { | 85 { |
85 if (m_dataAsSerializedScriptValue) | 86 if (m_dataAsSerializedScriptValue) |
86 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC
ontext(); | 87 m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptC
ontext(); |
87 ASSERT(isValidSource(m_source.get())); | 88 ASSERT(isValidSource(m_source.get())); |
88 } | 89 } |
89 | 90 |
90 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
origin, const String& lastEventId, EventTarget* source, PassOwnPtr<MessagePortC
hannelArray> channels, const String& suborigin) | 91 MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
origin, const String& lastEventId, EventTarget* source, std::unique_ptr<Message
PortChannelArray> channels, const String& suborigin) |
91 : Event(EventTypeNames::message, false, false) | 92 : Event(EventTypeNames::message, false, false) |
92 , m_dataType(DataTypeSerializedScriptValue) | 93 , m_dataType(DataTypeSerializedScriptValue) |
93 , m_dataAsSerializedScriptValue(data) | 94 , m_dataAsSerializedScriptValue(data) |
94 , m_origin(origin) | 95 , m_origin(origin) |
95 , m_lastEventId(lastEventId) | 96 , m_lastEventId(lastEventId) |
96 , m_source(source) | 97 , m_source(source) |
97 , m_channels(std::move(channels)) | 98 , m_channels(std::move(channels)) |
98 , m_suborigin(suborigin) | 99 , m_suborigin(suborigin) |
99 { | 100 { |
100 if (m_dataAsSerializedScriptValue) | 101 if (m_dataAsSerializedScriptValue) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 break; | 232 break; |
232 case MessageEvent::DataTypeArrayBuffer: | 233 case MessageEvent::DataTypeArrayBuffer: |
233 V8PrivateProperty::getMessageEventCachedData(isolate).set(isolate->GetCu
rrentContext(), wrapper, toV8(dataAsArrayBuffer(), wrapper, isolate)); | 234 V8PrivateProperty::getMessageEventCachedData(isolate).set(isolate->GetCu
rrentContext(), wrapper, toV8(dataAsArrayBuffer(), wrapper, isolate)); |
234 break; | 235 break; |
235 } | 236 } |
236 | 237 |
237 return wrapper; | 238 return wrapper; |
238 } | 239 } |
239 | 240 |
240 } // namespace blink | 241 } // namespace blink |
OLD | NEW |