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