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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Element.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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Don't need to call processMessagePortMessagesSoon() here, because the por t will not be opened until start() is invoked. 51 // Don't need to call processMessagePortMessagesSoon() here, because the por t will not be opened until start() is invoked.
52 } 52 }
53 53
54 MessagePort::~MessagePort() 54 MessagePort::~MessagePort()
55 { 55 {
56 close(); 56 close();
57 if (m_executionContext) 57 if (m_executionContext)
58 m_executionContext->destroyedMessagePort(this); 58 m_executionContext->destroyedMessagePort(this);
59 } 59 }
60 60
61 void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M essagePortArray* ports, ExceptionState& es) 61 void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M essagePortArray* ports, ExceptionState& exceptionState)
62 { 62 {
63 if (!isEntangled()) 63 if (!isEntangled())
64 return; 64 return;
65 ASSERT(m_executionContext); 65 ASSERT(m_executionContext);
66 66
67 OwnPtr<MessagePortChannelArray> channels; 67 OwnPtr<MessagePortChannelArray> channels;
68 // Make sure we aren't connected to any of the passed-in ports. 68 // Make sure we aren't connected to any of the passed-in ports.
69 if (ports) { 69 if (ports) {
70 for (unsigned int i = 0; i < ports->size(); ++i) { 70 for (unsigned int i = 0; i < ports->size(); ++i) {
71 MessagePort* dataPort = (*ports)[i].get(); 71 MessagePort* dataPort = (*ports)[i].get();
72 if (dataPort == this) { 72 if (dataPort == this) {
73 es.throwDOMException(DataCloneError, ExceptionMessages::failedTo Execute("postMessage", "MessagePort", "Item #" + String::number(i) + " in the ar ray of ports contains the source port.")); 73 exceptionState.throwDOMException(DataCloneError, ExceptionMessag es::failedToExecute("postMessage", "MessagePort", "Item #" + String::number(i) + " in the array of ports contains the source port."));
74 return; 74 return;
75 } 75 }
76 } 76 }
77 channels = MessagePort::disentanglePorts(ports, es); 77 channels = MessagePort::disentanglePorts(ports, exceptionState);
78 if (es.hadException()) 78 if (exceptionState.hadException())
79 return; 79 return;
80 } 80 }
81 m_entangledChannel->postMessageToRemote(message, channels.release()); 81 m_entangledChannel->postMessageToRemote(message, channels.release());
82 } 82 }
83 83
84 PassOwnPtr<MessagePortChannel> MessagePort::disentangle() 84 PassOwnPtr<MessagePortChannel> MessagePort::disentangle()
85 { 85 {
86 ASSERT(m_entangledChannel); 86 ASSERT(m_entangledChannel);
87 87
88 m_entangledChannel->disentangle(); 88 m_entangledChannel->disentangle();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 bool MessagePort::hasPendingActivity() 177 bool MessagePort::hasPendingActivity()
178 { 178 {
179 // The spec says that entangled message ports should always be treated as if they have a strong reference. 179 // The spec says that entangled message ports should always be treated as if they have a strong reference.
180 // We'll also stipulate that the queue needs to be open (if the app drops it s reference to the port before start()-ing it, then it's not really entangled as it's unreachable). 180 // We'll also stipulate that the queue needs to be open (if the app drops it s reference to the port before start()-ing it, then it's not really entangled as it's unreachable).
181 if (m_started && m_entangledChannel && m_entangledChannel->hasPendingActivit y()) 181 if (m_started && m_entangledChannel && m_entangledChannel->hasPendingActivit y())
182 return true; 182 return true;
183 return isEntangled(); 183 return isEntangled();
184 } 184 }
185 185
186 PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessageP ortArray* ports, ExceptionState& es) 186 PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessageP ortArray* ports, ExceptionState& exceptionState)
187 { 187 {
188 if (!ports || !ports->size()) 188 if (!ports || !ports->size())
189 return nullptr; 189 return nullptr;
190 190
191 // HashSet used to efficiently check for duplicates in the passed-in array. 191 // HashSet used to efficiently check for duplicates in the passed-in array.
192 HashSet<MessagePort*> portSet; 192 HashSet<MessagePort*> portSet;
193 193
194 // Walk the incoming array - if there are any duplicate ports, or null ports or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec). 194 // Walk the incoming array - if there are any duplicate ports, or null ports or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
195 for (unsigned i = 0; i < ports->size(); ++i) { 195 for (unsigned i = 0; i < ports->size(); ++i) {
196 MessagePort* port = (*ports)[i].get(); 196 MessagePort* port = (*ports)[i].get();
197 if (!port || port->isNeutered() || portSet.contains(port)) { 197 if (!port || port->isNeutered() || portSet.contains(port)) {
198 String type; 198 String type;
199 if (!port) 199 if (!port)
200 type = "null"; 200 type = "null";
201 else if (port->isNeutered()) 201 else if (port->isNeutered())
202 type = "already neutered"; 202 type = "already neutered";
203 else 203 else
204 type = "a duplicate"; 204 type = "a duplicate";
205 es.throwDOMException(DataCloneError, ExceptionMessages::failedToExec ute("disentanglePorts", "MessagePort", "Item #" + String::number(i) + " in the array of ports is " + type + ".")); 205 exceptionState.throwDOMException(DataCloneError, ExceptionMessages:: failedToExecute("disentanglePorts", "MessagePort", "Item #" + String::number(i) + " in the array of ports is " + type + "."));
206 return nullptr; 206 return nullptr;
207 } 207 }
208 portSet.add(port); 208 portSet.add(port);
209 } 209 }
210 210
211 // Passed-in ports passed validity checks, so we can disentangle them. 211 // Passed-in ports passed validity checks, so we can disentangle them.
212 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size())); 212 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size()));
213 for (unsigned i = 0; i < ports->size(); ++i) 213 for (unsigned i = 0; i < ports->size(); ++i)
214 (*portArray)[i] = (*ports)[i]->disentangle(); 214 (*portArray)[i] = (*ports)[i]->disentangle();
215 return portArray.release(); 215 return portArray.release();
216 } 216 }
217 217
218 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels) 218 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels)
219 { 219 {
220 if (!channels || !channels->size()) 220 if (!channels || !channels->size())
221 return nullptr; 221 return nullptr;
222 222
223 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size())); 223 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size()));
224 for (unsigned int i = 0; i < channels->size(); ++i) { 224 for (unsigned int i = 0; i < channels->size(); ++i) {
225 RefPtr<MessagePort> port = MessagePort::create(context); 225 RefPtr<MessagePort> port = MessagePort::create(context);
226 port->entangle((*channels)[i].release()); 226 port->entangle((*channels)[i].release());
227 (*portArray)[i] = port.release(); 227 (*portArray)[i] = port.release();
228 } 228 }
229 return portArray.release(); 229 return portArray.release();
230 } 230 }
231 231
232 } // namespace WebCore 232 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Element.cpp ('k') | Source/core/dom/MutationObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698