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

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

Issue 64113006: Rename es => exceptionState in core/dom (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Don't need to call processMessagePortMessagesSoon() here, because the por t will not be opened until start() is invoked. 54 // Don't need to call processMessagePortMessagesSoon() here, because the por t will not be opened until start() is invoked.
55 } 55 }
56 56
57 MessagePort::~MessagePort() 57 MessagePort::~MessagePort()
58 { 58 {
59 close(); 59 close();
60 if (m_executionContext) 60 if (m_executionContext)
61 m_executionContext->destroyedMessagePort(this); 61 m_executionContext->destroyedMessagePort(this);
62 } 62 }
63 63
64 void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M essagePortArray* ports, ExceptionState& es) 64 void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M essagePortArray* ports, ExceptionState& exceptionState)
65 { 65 {
66 if (!isEntangled()) 66 if (!isEntangled())
67 return; 67 return;
68 ASSERT(m_executionContext); 68 ASSERT(m_executionContext);
69 ASSERT(m_entangledChannel); 69 ASSERT(m_entangledChannel);
70 70
71 OwnPtr<MessagePortChannelArray> channels; 71 OwnPtr<MessagePortChannelArray> channels;
72 // Make sure we aren't connected to any of the passed-in ports. 72 // Make sure we aren't connected to any of the passed-in ports.
73 if (ports) { 73 if (ports) {
74 for (unsigned int i = 0; i < ports->size(); ++i) { 74 for (unsigned int i = 0; i < ports->size(); ++i) {
75 MessagePort* dataPort = (*ports)[i].get(); 75 MessagePort* dataPort = (*ports)[i].get();
76 if (dataPort == this) { 76 if (dataPort == this) {
77 es.throwDOMException(DataCloneError, ExceptionMessages::failedTo Execute("postMessage", "MessagePort", "Item #" + String::number(i) + " in the ar ray of ports contains the source port.")); 77 exceptionState.throwDOMException(DataCloneError, ExceptionMessag es::failedToExecute("postMessage", "MessagePort", "Item #" + String::number(i) + " in the array of ports contains the source port."));
78 return; 78 return;
79 } 79 }
80 } 80 }
81 channels = MessagePort::disentanglePorts(ports, es); 81 channels = MessagePort::disentanglePorts(ports, exceptionState);
82 if (es.hadException()) 82 if (exceptionState.hadException())
83 return; 83 return;
84 } 84 }
85 85
86 blink::WebString messageString = message->toWireString(); 86 blink::WebString messageString = message->toWireString();
87 blink::WebMessagePortChannelArray* webChannels = 0; 87 blink::WebMessagePortChannelArray* webChannels = 0;
88 if (channels && channels->size()) { 88 if (channels && channels->size()) {
89 webChannels = new blink::WebMessagePortChannelArray(channels->size()); 89 webChannels = new blink::WebMessagePortChannelArray(channels->size());
90 for (size_t i = 0; i < channels->size(); ++i) 90 for (size_t i = 0; i < channels->size(); ++i)
91 (*webChannels)[i] = (*channels)[i].leakPtr(); 91 (*webChannels)[i] = (*channels)[i].leakPtr();
92 } 92 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 bool MessagePort::hasPendingActivity() 203 bool MessagePort::hasPendingActivity()
204 { 204 {
205 // The spec says that entangled message ports should always be treated as if they have a strong reference. 205 // The spec says that entangled message ports should always be treated as if they have a strong reference.
206 // 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). 206 // 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).
207 if (m_started && m_entangledChannel) 207 if (m_started && m_entangledChannel)
208 return true; 208 return true;
209 return isEntangled(); 209 return isEntangled();
210 } 210 }
211 211
212 PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessageP ortArray* ports, ExceptionState& es) 212 PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessageP ortArray* ports, ExceptionState& exceptionState)
213 { 213 {
214 if (!ports || !ports->size()) 214 if (!ports || !ports->size())
215 return nullptr; 215 return nullptr;
216 216
217 // HashSet used to efficiently check for duplicates in the passed-in array. 217 // HashSet used to efficiently check for duplicates in the passed-in array.
218 HashSet<MessagePort*> portSet; 218 HashSet<MessagePort*> portSet;
219 219
220 // 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). 220 // 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).
221 for (unsigned i = 0; i < ports->size(); ++i) { 221 for (unsigned i = 0; i < ports->size(); ++i) {
222 MessagePort* port = (*ports)[i].get(); 222 MessagePort* port = (*ports)[i].get();
223 if (!port || port->isNeutered() || portSet.contains(port)) { 223 if (!port || port->isNeutered() || portSet.contains(port)) {
224 String type; 224 String type;
225 if (!port) 225 if (!port)
226 type = "null"; 226 type = "null";
227 else if (port->isNeutered()) 227 else if (port->isNeutered())
228 type = "already neutered"; 228 type = "already neutered";
229 else 229 else
230 type = "a duplicate"; 230 type = "a duplicate";
231 es.throwDOMException(DataCloneError, ExceptionMessages::failedToExec ute("disentanglePorts", "MessagePort", "Item #" + String::number(i) + " in the array of ports is " + type + ".")); 231 exceptionState.throwDOMException(DataCloneError, ExceptionMessages:: failedToExecute("disentanglePorts", "MessagePort", "Item #" + String::number(i) + " in the array of ports is " + type + "."));
232 return nullptr; 232 return nullptr;
233 } 233 }
234 portSet.add(port); 234 portSet.add(port);
235 } 235 }
236 236
237 // Passed-in ports passed validity checks, so we can disentangle them. 237 // Passed-in ports passed validity checks, so we can disentangle them.
238 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size())); 238 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size()));
239 for (unsigned i = 0; i < ports->size(); ++i) 239 for (unsigned i = 0; i < ports->size(); ++i)
240 (*portArray)[i] = (*ports)[i]->disentangle(); 240 (*portArray)[i] = (*ports)[i]->disentangle();
241 return portArray.release(); 241 return portArray.release();
242 } 242 }
243 243
244 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels) 244 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels)
245 { 245 {
246 if (!channels || !channels->size()) 246 if (!channels || !channels->size())
247 return nullptr; 247 return nullptr;
248 248
249 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size())); 249 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size()));
250 for (unsigned int i = 0; i < channels->size(); ++i) { 250 for (unsigned int i = 0; i < channels->size(); ++i) {
251 RefPtr<MessagePort> port = MessagePort::create(context); 251 RefPtr<MessagePort> port = MessagePort::create(context);
252 port->entangle((*channels)[i].release()); 252 port->entangle((*channels)[i].release());
253 (*portArray)[i] = port.release(); 253 (*portArray)[i] = port.release();
254 } 254 }
255 return portArray.release(); 255 return portArray.release();
256 } 256 }
257 257
258 } // namespace WebCore 258 } // 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