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

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

Issue 1008533005: Initial implementation of stashed message ports, blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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/modules/EventTargetModulesFactory.in » ('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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 if (webChannels.size()) { 178 if (webChannels.size()) {
179 channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); 179 channels = adoptPtr(new MessagePortChannelArray(webChannels.size()));
180 for (size_t i = 0; i < webChannels.size(); ++i) 180 for (size_t i = 0; i < webChannels.size(); ++i)
181 (*channels)[i] = adoptPtr(webChannels[i]); 181 (*channels)[i] = adoptPtr(webChannels[i]);
182 } 182 }
183 message = SerializedScriptValueFactory::instance().createFromWire(messageStr ing); 183 message = SerializedScriptValueFactory::instance().createFromWire(messageStr ing);
184 return true; 184 return true;
185 } 185 }
186 186
187 bool MessagePort::tryGetMessage(RefPtr<SerializedScriptValue>& message, OwnPtr<M essagePortChannelArray>& channels)
188 {
189 if (!m_entangledChannel)
190 return false;
191 return tryGetMessageFrom(*m_entangledChannel, message, channels);
192 }
193
187 void MessagePort::dispatchMessages() 194 void MessagePort::dispatchMessages()
188 { 195 {
189 // Because close() doesn't cancel any in flight calls to dispatchMessages() we need to check if the port is still open before dispatch. 196 // Because close() doesn't cancel any in flight calls to dispatchMessages() we need to check if the port is still open before dispatch.
190 if (m_closed) 197 if (m_closed)
191 return; 198 return;
192 199
193 // Messages for contexts that are not fully active get dispatched too, but J SAbstractEventListener::handleEvent() doesn't call handlers for these. 200 // Messages for contexts that are not fully active get dispatched too, but J SAbstractEventListener::handleEvent() doesn't call handlers for these.
194 // The HTML5 spec specifies that any messages sent to a document that is not fully active should be dropped, so this behavior is OK. 201 // The HTML5 spec specifies that any messages sent to a document that is not fully active should be dropped, so this behavior is OK.
195 if (!started()) 202 if (!started())
196 return; 203 return;
197 204
198 RefPtr<SerializedScriptValue> message; 205 RefPtr<SerializedScriptValue> message;
199 OwnPtr<MessagePortChannelArray> channels; 206 OwnPtr<MessagePortChannelArray> channels;
200 while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message, channels)) { 207 while (tryGetMessage(message, channels)) {
201 // close() in Worker onmessage handler should prevent next message from dispatching. 208 // close() in Worker onmessage handler should prevent next message from dispatching.
202 if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(exe cutionContext())->isClosing()) 209 if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(exe cutionContext())->isClosing())
203 return; 210 return;
204 211
205 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::entanglePorts( *executionContext(), channels.release()); 212 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::entanglePorts( *executionContext(), channels.release());
206 RefPtrWillBeRawPtr<Event> evt = MessageEvent::create(ports.release(), me ssage.release()); 213 RefPtrWillBeRawPtr<Event> evt = MessageEvent::create(ports.release(), me ssage.release());
207 214
208 dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); 215 dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION);
209 } 216 }
210 } 217 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 { 285 {
279 ASSERT(executionContext()); 286 ASSERT(executionContext());
280 if (!m_scriptStateForConversion) { 287 if (!m_scriptStateForConversion) {
281 v8::Isolate* isolate = scriptIsolate(); 288 v8::Isolate* isolate = scriptIsolate();
282 m_scriptStateForConversion = ScriptState::create(v8::Context::New(isolat e), DOMWrapperWorld::create(isolate)); 289 m_scriptStateForConversion = ScriptState::create(v8::Context::New(isolat e), DOMWrapperWorld::create(isolate));
283 } 290 }
284 return m_scriptStateForConversion->context(); 291 return m_scriptStateForConversion->context();
285 } 292 }
286 293
287 } // namespace blink 294 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | Source/modules/EventTargetModulesFactory.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698