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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
88 | 88 |
89 blink::WebString messageString = message->toWireString(); | 89 blink::WebString messageString = message->toWireString(); |
90 blink::WebMessagePortChannelArray* webChannels = 0; | 90 OwnPtr<blink::WebMessagePortChannelArray> webChannels = toWebMessagePortChan
nelArray(channels.release()); |
| 91 m_entangledChannel->postMessage(messageString, webChannels.leakPtr()); |
| 92 } |
| 93 |
| 94 // static |
| 95 PassOwnPtr<blink::WebMessagePortChannelArray> MessagePort::toWebMessagePortChann
elArray(PassOwnPtr<MessagePortChannelArray> channels) |
| 96 { |
| 97 OwnPtr<blink::WebMessagePortChannelArray> webChannels; |
91 if (channels && channels->size()) { | 98 if (channels && channels->size()) { |
92 webChannels = new blink::WebMessagePortChannelArray(channels->size()); | 99 webChannels = adoptPtr(new blink::WebMessagePortChannelArray(channels->s
ize())); |
93 for (size_t i = 0; i < channels->size(); ++i) | 100 for (size_t i = 0; i < channels->size(); ++i) |
94 (*webChannels)[i] = (*channels)[i].leakPtr(); | 101 (*webChannels)[i] = (*channels)[i].leakPtr(); |
95 } | 102 } |
96 m_entangledChannel->postMessage(messageString, webChannels); | 103 return webChannels.release(); |
| 104 } |
| 105 |
| 106 // static |
| 107 PassOwnPtr<MessagePortArray> MessagePort::toMessagePortArray(ExecutionContext* c
ontext, const blink::WebMessagePortChannelArray& webChannels) |
| 108 { |
| 109 OwnPtr<MessagePortArray> ports; |
| 110 if (!webChannels.isEmpty()) { |
| 111 OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChann
elArray(webChannels.size())); |
| 112 for (size_t i = 0; i < webChannels.size(); ++i) |
| 113 (*channels)[i] = adoptPtr(webChannels[i]); |
| 114 ports = MessagePort::entanglePorts(*context, channels.release()); |
| 115 } |
| 116 return ports.release(); |
97 } | 117 } |
98 | 118 |
99 PassOwnPtr<blink::WebMessagePortChannel> MessagePort::disentangle() | 119 PassOwnPtr<blink::WebMessagePortChannel> MessagePort::disentangle() |
100 { | 120 { |
101 ASSERT(m_entangledChannel); | 121 ASSERT(m_entangledChannel); |
102 m_entangledChannel->setClient(0); | 122 m_entangledChannel->setClient(0); |
103 return m_entangledChannel.release(); | 123 return m_entangledChannel.release(); |
104 } | 124 } |
105 | 125 |
106 // Invoked to notify us that there are messages available for this port. | 126 // Invoked to notify us that there are messages available for this port. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels-
>size())); | 251 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels-
>size())); |
232 for (unsigned int i = 0; i < channels->size(); ++i) { | 252 for (unsigned int i = 0; i < channels->size(); ++i) { |
233 RefPtr<MessagePort> port = MessagePort::create(context); | 253 RefPtr<MessagePort> port = MessagePort::create(context); |
234 port->entangle((*channels)[i].release()); | 254 port->entangle((*channels)[i].release()); |
235 (*portArray)[i] = port.release(); | 255 (*portArray)[i] = port.release(); |
236 } | 256 } |
237 return portArray.release(); | 257 return portArray.release(); |
238 } | 258 } |
239 | 259 |
240 } // namespace WebCore | 260 } // namespace WebCore |
OLD | NEW |