| 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 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 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 "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
| 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 32 #include "bindings/core/v8/SerializedScriptValue.h" | 32 #include "bindings/core/v8/SerializedScriptValue.h" |
| 33 #include "core/dom/CrossThreadTask.h" |
| 33 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 34 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 35 #include "core/events/MessageEvent.h" | 36 #include "core/events/MessageEvent.h" |
| 36 #include "core/frame/LocalDOMWindow.h" | 37 #include "core/frame/LocalDOMWindow.h" |
| 37 #include "core/workers/WorkerGlobalScope.h" | 38 #include "core/workers/WorkerGlobalScope.h" |
| 38 #include "public/platform/WebString.h" | 39 #include "public/platform/WebString.h" |
| 39 #include "wtf/Functional.h" | 40 #include "wtf/Functional.h" |
| 40 #include "wtf/text/AtomicString.h" | 41 #include "wtf/text/AtomicString.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ASSERT(m_entangledChannel); | 120 ASSERT(m_entangledChannel); |
| 120 m_entangledChannel->setClient(0); | 121 m_entangledChannel->setClient(0); |
| 121 return m_entangledChannel.release(); | 122 return m_entangledChannel.release(); |
| 122 } | 123 } |
| 123 | 124 |
| 124 // Invoked to notify us that there are messages available for this port. | 125 // Invoked to notify us that there are messages available for this port. |
| 125 // This code may be called from another thread, and so should not call any non-t
hreadsafe APIs (i.e. should not call into the entangled channel or access mutabl
e variables). | 126 // This code may be called from another thread, and so should not call any non-t
hreadsafe APIs (i.e. should not call into the entangled channel or access mutabl
e variables). |
| 126 void MessagePort::messageAvailable() | 127 void MessagePort::messageAvailable() |
| 127 { | 128 { |
| 128 ASSERT(executionContext()); | 129 ASSERT(executionContext()); |
| 129 executionContext()->postTask(bind(&MessagePort::dispatchMessages, m_weakFact
ory.createWeakPtr())); | 130 executionContext()->postTask(createCrossThreadTask(&MessagePort::dispatchMes
sages, m_weakFactory.createWeakPtr())); |
| 130 } | 131 } |
| 131 | 132 |
| 132 void MessagePort::start() | 133 void MessagePort::start() |
| 133 { | 134 { |
| 134 // Do nothing if we've been cloned or closed. | 135 // Do nothing if we've been cloned or closed. |
| 135 if (!isEntangled()) | 136 if (!isEntangled()) |
| 136 return; | 137 return; |
| 137 | 138 |
| 138 ASSERT(executionContext()); | 139 ASSERT(executionContext()); |
| 139 if (m_started) | 140 if (m_started) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess
agePortArray(channels->size())); | 250 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess
agePortArray(channels->size())); |
| 250 for (unsigned i = 0; i < channels->size(); ++i) { | 251 for (unsigned i = 0; i < channels->size(); ++i) { |
| 251 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context); | 252 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context); |
| 252 port->entangle((*channels)[i].release()); | 253 port->entangle((*channels)[i].release()); |
| 253 (*portArray)[i] = port.release(); | 254 (*portArray)[i] = port.release(); |
| 254 } | 255 } |
| 255 return portArray.release(); | 256 return portArray.release(); |
| 256 } | 257 } |
| 257 | 258 |
| 258 } // namespace WebCore | 259 } // namespace WebCore |
| OLD | NEW |