| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); | 176 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); |
| 177 for (size_t i = 0; i < webChannels.size(); ++i) | 177 for (size_t i = 0; i < webChannels.size(); ++i) |
| 178 (*channels)[i] = adoptPtr(webChannels[i]); | 178 (*channels)[i] = adoptPtr(webChannels[i]); |
| 179 } | 179 } |
| 180 message = SerializedScriptValue::createFromWire(messageString); | 180 message = SerializedScriptValue::createFromWire(messageString); |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| 183 | 183 |
| 184 void MessagePort::dispatchMessages() | 184 void MessagePort::dispatchMessages() |
| 185 { | 185 { |
| 186 // Because close() doesn't cancel any in flight calls to dispatchMessages()
we need to check if the port is still open before dispatch. |
| 187 if (m_closed) |
| 188 return; |
| 189 |
| 186 // Messages for contexts that are not fully active get dispatched too, but J
SAbstractEventListener::handleEvent() doesn't call handlers for these. | 190 // Messages for contexts that are not fully active get dispatched too, but J
SAbstractEventListener::handleEvent() doesn't call handlers for these. |
| 187 // The HTML5 spec specifies that any messages sent to a document that is not
fully active should be dropped, so this behavior is OK. | 191 // The HTML5 spec specifies that any messages sent to a document that is not
fully active should be dropped, so this behavior is OK. |
| 188 if (!started()) | 192 if (!started()) |
| 189 return; | 193 return; |
| 190 | 194 |
| 191 RefPtr<SerializedScriptValue> message; | 195 RefPtr<SerializedScriptValue> message; |
| 192 OwnPtr<MessagePortChannelArray> channels; | 196 OwnPtr<MessagePortChannelArray> channels; |
| 193 while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message,
channels)) { | 197 while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message,
channels)) { |
| 194 // close() in Worker onmessage handler should prevent next message from
dispatching. | 198 // close() in Worker onmessage handler should prevent next message from
dispatching. |
| 195 if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(exe
cutionContext())->isClosing()) | 199 if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(exe
cutionContext())->isClosing()) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess
agePortArray(channels->size())); | 253 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess
agePortArray(channels->size())); |
| 250 for (unsigned i = 0; i < channels->size(); ++i) { | 254 for (unsigned i = 0; i < channels->size(); ++i) { |
| 251 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context); | 255 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context); |
| 252 port->entangle((*channels)[i].release()); | 256 port->entangle((*channels)[i].release()); |
| 253 (*portArray)[i] = port.release(); | 257 (*portArray)[i] = port.release(); |
| 254 } | 258 } |
| 255 return portArray.release(); | 259 return portArray.release(); |
| 256 } | 260 } |
| 257 | 261 |
| 258 } // namespace blink | 262 } // namespace blink |
| OLD | NEW |