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

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

Issue 344833002: Oilpan: move MessagePortArray to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 6 months 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/MessagePort.h ('k') | Source/core/events/MessageEvent.h » ('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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 OwnPtr<blink::WebMessagePortChannelArray> webChannels; 96 OwnPtr<blink::WebMessagePortChannelArray> webChannels;
97 if (channels && channels->size()) { 97 if (channels && channels->size()) {
98 webChannels = adoptPtr(new blink::WebMessagePortChannelArray(channels->s ize())); 98 webChannels = adoptPtr(new blink::WebMessagePortChannelArray(channels->s ize()));
99 for (size_t i = 0; i < channels->size(); ++i) 99 for (size_t i = 0; i < channels->size(); ++i)
100 (*webChannels)[i] = (*channels)[i].leakPtr(); 100 (*webChannels)[i] = (*channels)[i].leakPtr();
101 } 101 }
102 return webChannels.release(); 102 return webChannels.release();
103 } 103 }
104 104
105 // static 105 // static
106 PassOwnPtr<MessagePortArray> MessagePort::toMessagePortArray(ExecutionContext* c ontext, const blink::WebMessagePortChannelArray& webChannels) 106 PassOwnPtrWillBeRawPtr<MessagePortArray> MessagePort::toMessagePortArray(Executi onContext* context, const blink::WebMessagePortChannelArray& webChannels)
107 { 107 {
108 OwnPtr<MessagePortArray> ports; 108 OwnPtrWillBeRawPtr<MessagePortArray> ports = nullptr;
109 if (!webChannels.isEmpty()) { 109 if (!webChannels.isEmpty()) {
110 OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChann elArray(webChannels.size())); 110 OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChann elArray(webChannels.size()));
111 for (size_t i = 0; i < webChannels.size(); ++i) 111 for (size_t i = 0; i < webChannels.size(); ++i)
112 (*channels)[i] = adoptPtr(webChannels[i]); 112 (*channels)[i] = adoptPtr(webChannels[i]);
113 ports = MessagePort::entanglePorts(*context, channels.release()); 113 ports = MessagePort::entanglePorts(*context, channels.release());
114 } 114 }
115 return ports.release(); 115 return ports.release();
116 } 116 }
117 117
118 PassOwnPtr<blink::WebMessagePortChannel> MessagePort::disentangle() 118 PassOwnPtr<blink::WebMessagePortChannel> MessagePort::disentangle()
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (!started()) 189 if (!started())
190 return; 190 return;
191 191
192 RefPtr<SerializedScriptValue> message; 192 RefPtr<SerializedScriptValue> message;
193 OwnPtr<MessagePortChannelArray> channels; 193 OwnPtr<MessagePortChannelArray> channels;
194 while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message, channels)) { 194 while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message, channels)) {
195 // close() in Worker onmessage handler should prevent next message from dispatching. 195 // close() in Worker onmessage handler should prevent next message from dispatching.
196 if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(exe cutionContext())->isClosing()) 196 if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(exe cutionContext())->isClosing())
197 return; 197 return;
198 198
199 OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*executionCo ntext(), channels.release()); 199 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::entanglePorts( *executionContext(), channels.release());
200 RefPtrWillBeRawPtr<Event> evt = MessageEvent::create(ports.release(), me ssage.release()); 200 RefPtrWillBeRawPtr<Event> evt = MessageEvent::create(ports.release(), me ssage.release());
201 201
202 dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); 202 dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION);
203 } 203 }
204 } 204 }
205 205
206 bool MessagePort::hasPendingActivity() const 206 bool MessagePort::hasPendingActivity() const
207 { 207 {
208 // The spec says that entangled message ports should always be treated as if they have a strong reference. 208 // The spec says that entangled message ports should always be treated as if they have a strong reference.
209 // 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). 209 // 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).
(...skipping 25 matching lines...) Expand all
235 portSet.add(port); 235 portSet.add(port);
236 } 236 }
237 237
238 // Passed-in ports passed validity checks, so we can disentangle them. 238 // Passed-in ports passed validity checks, so we can disentangle them.
239 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size())); 239 OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelA rray(ports->size()));
240 for (unsigned i = 0; i < ports->size(); ++i) 240 for (unsigned i = 0; i < ports->size(); ++i)
241 (*portArray)[i] = (*ports)[i]->disentangle(); 241 (*portArray)[i] = (*ports)[i]->disentangle();
242 return portArray.release(); 242 return portArray.release();
243 } 243 }
244 244
245 PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionContext& contex t, PassOwnPtr<MessagePortChannelArray> channels) 245 PassOwnPtrWillBeRawPtr<MessagePortArray> MessagePort::entanglePorts(ExecutionCon text& context, PassOwnPtr<MessagePortChannelArray> channels)
246 { 246 {
247 if (!channels || !channels->size()) 247 if (!channels || !channels->size())
248 return nullptr; 248 return nullptr;
249 249
250 OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels- >size())); 250 OwnPtrWillBeRawPtr<MessagePortArray> portArray = adoptPtrWillBeNoop(new Mess agePortArray(channels->size()));
251 for (unsigned i = 0; i < channels->size(); ++i) { 251 for (unsigned i = 0; i < channels->size(); ++i) {
252 RefPtr<MessagePort> port = MessagePort::create(context); 252 RefPtrWillBeRawPtr<MessagePort> port = MessagePort::create(context);
253 port->entangle((*channels)[i].release()); 253 port->entangle((*channels)[i].release());
254 (*portArray)[i] = port.release(); 254 (*portArray)[i] = port.release();
255 } 255 }
256 return portArray.release(); 256 return portArray.release();
257 } 257 }
258 258
259 } // namespace WebCore 259 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | Source/core/events/MessageEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698