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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
essagePortArray* ports, ExceptionState& exceptionState) | 67 void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
essagePortArray* ports, ExceptionState& exceptionState) |
68 { | 68 { |
69 if (!isEntangled()) | 69 if (!isEntangled()) |
70 return; | 70 return; |
71 ASSERT(executionContext()); | 71 ASSERT(executionContext()); |
72 ASSERT(m_entangledChannel); | 72 ASSERT(m_entangledChannel); |
73 | 73 |
74 OwnPtr<MessagePortChannelArray> channels; | 74 OwnPtr<MessagePortChannelArray> channels; |
75 // Make sure we aren't connected to any of the passed-in ports. | 75 // Make sure we aren't connected to any of the passed-in ports. |
76 if (ports) { | 76 if (ports) { |
77 for (unsigned int i = 0; i < ports->size(); ++i) { | 77 for (unsigned i = 0; i < ports->size(); ++i) { |
78 MessagePort* dataPort = (*ports)[i].get(); | 78 MessagePort* dataPort = (*ports)[i].get(); |
79 if (dataPort == this) { | 79 if (dataPort == this) { |
80 exceptionState.throwDOMException(DataCloneError, "Port at index
" + String::number(i) + " contains the source port."); | 80 exceptionState.throwDOMException(DataCloneError, "Port at index
" + String::number(i) + " contains the source port."); |
81 return; | 81 return; |
82 } | 82 } |
83 } | 83 } |
84 channels = MessagePort::disentanglePorts(ports, exceptionState); | 84 channels = MessagePort::disentanglePorts(ports, exceptionState); |
85 if (exceptionState.hadException()) | 85 if (exceptionState.hadException()) |
86 return; | 86 return; |
87 } | 87 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 (*portArray)[i] = (*ports)[i]->disentangle(); | 222 (*portArray)[i] = (*ports)[i]->disentangle(); |
223 return portArray.release(); | 223 return portArray.release(); |
224 } | 224 } |
225 | 225 |
226 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex
t, PassOwnPtr<MessagePortChannelArray> channels) | 226 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex
t, PassOwnPtr<MessagePortChannelArray> channels) |
227 { | 227 { |
228 if (!channels || !channels->size()) | 228 if (!channels || !channels->size()) |
229 return nullptr; | 229 return nullptr; |
230 | 230 |
231 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels-
>size())); | 231 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels-
>size())); |
232 for (unsigned int i = 0; i < channels->size(); ++i) { | 232 for (unsigned i = 0; i < channels->size(); ++i) { |
233 RefPtr<MessagePort> port = MessagePort::create(context); | 233 RefPtr<MessagePort> port = MessagePort::create(context); |
234 port->entangle((*channels)[i].release()); | 234 port->entangle((*channels)[i].release()); |
235 (*portArray)[i] = port.release(); | 235 (*portArray)[i] = port.release(); |
236 } | 236 } |
237 return portArray.release(); | 237 return portArray.release(); |
238 } | 238 } |
239 | 239 |
240 } // namespace WebCore | 240 } // namespace WebCore |
OLD | NEW |