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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 int 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, "Item #" + Stri
ng::number(i) + " in the array of ports 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 } |
88 | 88 |
89 blink::WebString messageString = message->toWireString(); | 89 blink::WebString messageString = message->toWireString(); |
90 blink::WebMessagePortChannelArray* webChannels = 0; | 90 blink::WebMessagePortChannelArray* webChannels = 0; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 for (unsigned i = 0; i < ports->size(); ++i) { | 205 for (unsigned i = 0; i < ports->size(); ++i) { |
206 MessagePort* port = (*ports)[i].get(); | 206 MessagePort* port = (*ports)[i].get(); |
207 if (!port || port->isNeutered() || portSet.contains(port)) { | 207 if (!port || port->isNeutered() || portSet.contains(port)) { |
208 String type; | 208 String type; |
209 if (!port) | 209 if (!port) |
210 type = "null"; | 210 type = "null"; |
211 else if (port->isNeutered()) | 211 else if (port->isNeutered()) |
212 type = "already neutered"; | 212 type = "already neutered"; |
213 else | 213 else |
214 type = "a duplicate"; | 214 type = "a duplicate"; |
215 exceptionState.throwDOMException(DataCloneError, "Item #" + String:
:number(i) + " in the array of ports is " + type + "."); | 215 exceptionState.throwDOMException(DataCloneError, "Port at index " +
String::number(i) + " is " + type + "."); |
216 return nullptr; | 216 return nullptr; |
217 } | 217 } |
218 portSet.add(port); | 218 portSet.add(port); |
219 } | 219 } |
220 | 220 |
221 // Passed-in ports passed validity checks, so we can disentangle them. | 221 // Passed-in ports passed validity checks, so we can disentangle them. |
222 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA
rray(ports->size())); | 222 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA
rray(ports->size())); |
223 for (unsigned i = 0; i < ports->size(); ++i) | 223 for (unsigned i = 0; i < ports->size(); ++i) |
224 (*portArray)[i] = (*ports)[i]->disentangle(); | 224 (*portArray)[i] = (*ports)[i]->disentangle(); |
225 return portArray.release(); | 225 return portArray.release(); |
226 } | 226 } |
227 | 227 |
228 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex
t, PassOwnPtr<MessagePortChannelArray> channels) | 228 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex
t, PassOwnPtr<MessagePortChannelArray> channels) |
229 { | 229 { |
230 if (!channels || !channels->size()) | 230 if (!channels || !channels->size()) |
231 return nullptr; | 231 return nullptr; |
232 | 232 |
233 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels-
>size())); | 233 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels-
>size())); |
234 for (unsigned int i = 0; i < channels->size(); ++i) { | 234 for (unsigned int i = 0; i < channels->size(); ++i) { |
235 RefPtr<MessagePort> port = MessagePort::create(context); | 235 RefPtr<MessagePort> port = MessagePort::create(context); |
236 port->entangle((*channels)[i].release()); | 236 port->entangle((*channels)[i].release()); |
237 (*portArray)[i] = port.release(); | 237 (*portArray)[i] = port.release(); |
238 } | 238 } |
239 return portArray.release(); | 239 return portArray.release(); |
240 } | 240 } |
241 | 241 |
242 } // namespace WebCore | 242 } // namespace WebCore |
OLD | NEW |