Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: Source/core/dom/MessagePort.cpp

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/MutationObserver.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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/v8/ExceptionMessages.h"
31 #include "bindings/v8/ExceptionState.h" 30 #include "bindings/v8/ExceptionState.h"
32 #include "bindings/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/v8/ExceptionStatePlaceholder.h"
33 #include "bindings/v8/SerializedScriptValue.h" 32 #include "bindings/v8/SerializedScriptValue.h"
34 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
35 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
36 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
37 #include "core/events/MessageEvent.h" 36 #include "core/events/MessageEvent.h"
38 #include "core/events/ThreadLocalEventNames.h" 37 #include "core/events/ThreadLocalEventNames.h"
39 #include "core/frame/DOMWindow.h" 38 #include "core/frame/DOMWindow.h"
40 #include "core/workers/WorkerGlobalScope.h" 39 #include "core/workers/WorkerGlobalScope.h"
(...skipping 30 matching lines...) Expand all
71 return; 70 return;
72 ASSERT(executionContext()); 71 ASSERT(executionContext());
73 ASSERT(m_entangledChannel); 72 ASSERT(m_entangledChannel);
74 73
75 OwnPtr<MessagePortChannelArray> channels; 74 OwnPtr<MessagePortChannelArray> channels;
76 // 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.
77 if (ports) { 76 if (ports) {
78 for (unsigned int i = 0; i < ports->size(); ++i) { 77 for (unsigned int i = 0; i < ports->size(); ++i) {
79 MessagePort* dataPort = (*ports)[i].get(); 78 MessagePort* dataPort = (*ports)[i].get();
80 if (dataPort == this) { 79 if (dataPort == this) {
81 exceptionState.throwDOMException(DataCloneError, ExceptionMessag es::failedToExecute("postMessage", "MessagePort", "Item #" + String::number(i) + " in the array of ports contains the source port.")); 80 exceptionState.throwDOMException(DataCloneError, "Item #" + Stri ng::number(i) + " in the array of ports contains the source port.");
82 return; 81 return;
83 } 82 }
84 } 83 }
85 channels = MessagePort::disentanglePorts(ports, exceptionState); 84 channels = MessagePort::disentanglePorts(ports, exceptionState);
86 if (exceptionState.hadException()) 85 if (exceptionState.hadException())
87 return; 86 return;
88 } 87 }
89 88
90 blink::WebString messageString = message->toWireString(); 89 blink::WebString messageString = message->toWireString();
91 blink::WebMessagePortChannelArray* webChannels = 0; 90 blink::WebMessagePortChannelArray* webChannels = 0;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 for (unsigned i = 0; i < ports->size(); ++i) { 205 for (unsigned i = 0; i < ports->size(); ++i) {
207 MessagePort* port = (*ports)[i].get(); 206 MessagePort* port = (*ports)[i].get();
208 if (!port || port->isNeutered() || portSet.contains(port)) { 207 if (!port || port->isNeutered() || portSet.contains(port)) {
209 String type; 208 String type;
210 if (!port) 209 if (!port)
211 type = "null"; 210 type = "null";
212 else if (port->isNeutered()) 211 else if (port->isNeutered())
213 type = "already neutered"; 212 type = "already neutered";
214 else 213 else
215 type = "a duplicate"; 214 type = "a duplicate";
216 exceptionState.throwDOMException(DataCloneError, ExceptionMessages:: failedToExecute("disentanglePorts", "MessagePort", "Item #" + String::number(i) + " in the array of ports is " + type + ".")); 215 exceptionState.throwDOMException(DataCloneError, "Item #" + String: :number(i) + " in the array of ports is " + type + ".");
217 return nullptr; 216 return nullptr;
218 } 217 }
219 portSet.add(port); 218 portSet.add(port);
220 } 219 }
221 220
222 // Passed-in ports passed validity checks, so we can disentangle them. 221 // Passed-in ports passed validity checks, so we can disentangle them.
223 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size())); 222 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size()));
224 for (unsigned i = 0; i < ports->size(); ++i) 223 for (unsigned i = 0; i < ports->size(); ++i)
225 (*portArray)[i] = (*ports)[i]->disentangle(); 224 (*portArray)[i] = (*ports)[i]->disentangle();
226 return portArray.release(); 225 return portArray.release();
227 } 226 }
228 227
229 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels) 228 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels)
230 { 229 {
231 if (!channels || !channels->size()) 230 if (!channels || !channels->size())
232 return nullptr; 231 return nullptr;
233 232
234 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size())); 233 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size()));
235 for (unsigned int i = 0; i < channels->size(); ++i) { 234 for (unsigned int i = 0; i < channels->size(); ++i) {
236 RefPtr<MessagePort> port = MessagePort::create(context); 235 RefPtr<MessagePort> port = MessagePort::create(context);
237 port->entangle((*channels)[i].release()); 236 port->entangle((*channels)[i].release());
238 (*portArray)[i] = port.release(); 237 (*portArray)[i] = port.release();
239 } 238 }
240 return portArray.release(); 239 return portArray.release();
241 } 240 }
242 241
243 } // namespace WebCore 242 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/MutationObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698