OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 14 matching lines...) Expand all Loading... |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/dom/MessagePort.h" | 28 #include "core/dom/MessagePort.h" |
29 | 29 |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/EventNames.h" | 31 #include "core/dom/EventNames.h" |
32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
33 #include "core/dom/MessageEvent.h" | 33 #include "core/dom/MessageEvent.h" |
34 #include "core/page/DOMWindow.h" | 34 #include "core/page/DOMWindow.h" |
35 #include "core/workers/WorkerContext.h" | 35 #include "core/workers/WorkerGlobalScope.h" |
36 #include "wtf/text/AtomicString.h" | 36 #include "wtf/text/AtomicString.h" |
37 | 37 |
38 namespace WebCore { | 38 namespace WebCore { |
39 | 39 |
40 MessagePort::MessagePort(ScriptExecutionContext& scriptExecutionContext) | 40 MessagePort::MessagePort(ScriptExecutionContext& scriptExecutionContext) |
41 : m_started(false) | 41 : m_started(false) |
42 , m_closed(false) | 42 , m_closed(false) |
43 , m_scriptExecutionContext(&scriptExecutionContext) | 43 , m_scriptExecutionContext(&scriptExecutionContext) |
44 { | 44 { |
45 ScriptWrappable::init(this); | 45 ScriptWrappable::init(this); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 { | 155 { |
156 // Messages for contexts that are not fully active get dispatched too, but J
SAbstractEventListener::handleEvent() doesn't call handlers for these. | 156 // Messages for contexts that are not fully active get dispatched too, but J
SAbstractEventListener::handleEvent() doesn't call handlers for these. |
157 // The HTML5 spec specifies that any messages sent to a document that is not
fully active should be dropped, so this behavior is OK. | 157 // The HTML5 spec specifies that any messages sent to a document that is not
fully active should be dropped, so this behavior is OK. |
158 ASSERT(started()); | 158 ASSERT(started()); |
159 | 159 |
160 RefPtr<SerializedScriptValue> message; | 160 RefPtr<SerializedScriptValue> message; |
161 OwnPtr<MessagePortChannelArray> channels; | 161 OwnPtr<MessagePortChannelArray> channels; |
162 while (m_entangledChannel && m_entangledChannel->tryGetMessageFromRemote(mes
sage, channels)) { | 162 while (m_entangledChannel && m_entangledChannel->tryGetMessageFromRemote(mes
sage, channels)) { |
163 | 163 |
164 // close() in Worker onmessage handler should prevent next message from
dispatching. | 164 // close() in Worker onmessage handler should prevent next message from
dispatching. |
165 if (m_scriptExecutionContext->isWorkerContext() && static_cast<WorkerCon
text*>(m_scriptExecutionContext)->isClosing()) | 165 if (m_scriptExecutionContext->isWorkerGlobalScope() && static_cast<Worke
rGlobalScope*>(m_scriptExecutionContext)->isClosing()) |
166 return; | 166 return; |
167 | 167 |
168 OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExe
cutionContext, channels.release()); | 168 OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExe
cutionContext, channels.release()); |
169 RefPtr<Event> evt = MessageEvent::create(ports.release(), message.releas
e()); | 169 RefPtr<Event> evt = MessageEvent::create(ports.release(), message.releas
e()); |
170 | 170 |
171 dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); | 171 dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 bool MessagePort::hasPendingActivity() | 175 bool MessagePort::hasPendingActivity() |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 { | 233 { |
234 return &m_eventTargetData; | 234 return &m_eventTargetData; |
235 } | 235 } |
236 | 236 |
237 EventTargetData* MessagePort::ensureEventTargetData() | 237 EventTargetData* MessagePort::ensureEventTargetData() |
238 { | 238 { |
239 return &m_eventTargetData; | 239 return &m_eventTargetData; |
240 } | 240 } |
241 | 241 |
242 } // namespace WebCore | 242 } // namespace WebCore |
OLD | NEW |