OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 MessagePortArray* ports = MessagePort::entanglePorts(*getExecutionContext(),
std::move(channels)); | 137 MessagePortArray* ports = MessagePort::entanglePorts(*getExecutionContext(),
std::move(channels)); |
138 m_workerObject->dispatchEvent(MessageEvent::create(ports, message)); | 138 m_workerObject->dispatchEvent(MessageEvent::create(ports, message)); |
139 } | 139 } |
140 | 140 |
141 void InProcessWorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<Se
rializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels) | 141 void InProcessWorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<Se
rializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels) |
142 { | 142 { |
143 DCHECK(isParentContextThread()); | 143 DCHECK(isParentContextThread()); |
144 if (m_askedToTerminate) | 144 if (m_askedToTerminate) |
145 return; | 145 return; |
146 | 146 |
147 std::unique_ptr<ExecutionContextTask> task = createCrossThreadTask(&processM
essageOnWorkerGlobalScope, message, passed(std::move(channels)), AllowCrossThrea
dAccess(&workerObjectProxy())); | 147 std::unique_ptr<ExecutionContextTask> task = createCrossThreadTask(&processM
essageOnWorkerGlobalScope, message, passed(std::move(channels)), crossThreadUnre
tained(&workerObjectProxy())); |
148 if (m_workerThread) { | 148 if (m_workerThread) { |
149 ++m_unconfirmedMessageCount; | 149 ++m_unconfirmedMessageCount; |
150 m_workerThread->postTask(BLINK_FROM_HERE, std::move(task)); | 150 m_workerThread->postTask(BLINK_FROM_HERE, std::move(task)); |
151 } else { | 151 } else { |
152 m_queuedEarlyTasks.append(std::move(task)); | 152 m_queuedEarlyTasks.append(std::move(task)); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 bool InProcessWorkerMessagingProxy::postTaskToWorkerGlobalScope(std::unique_ptr<
ExecutionContextTask> task) | 156 bool InProcessWorkerMessagingProxy::postTaskToWorkerGlobalScope(std::unique_ptr<
ExecutionContextTask> task) |
157 { | 157 { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 void InProcessWorkerMessagingProxy::workerObjectDestroyed() | 215 void InProcessWorkerMessagingProxy::workerObjectDestroyed() |
216 { | 216 { |
217 DCHECK(isParentContextThread()); | 217 DCHECK(isParentContextThread()); |
218 | 218 |
219 // workerObjectDestroyed() is called in InProcessWorkerBase's destructor. | 219 // workerObjectDestroyed() is called in InProcessWorkerBase's destructor. |
220 // Thus it should be guaranteed that a weak pointer m_workerObject has been | 220 // Thus it should be guaranteed that a weak pointer m_workerObject has been |
221 // cleared before this method gets called. | 221 // cleared before this method gets called. |
222 DCHECK(!m_workerObject); | 222 DCHECK(!m_workerObject); |
223 | 223 |
224 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::workerObjectDestroyedInternal, AllowCrossThreadAccess
(this))); | 224 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&InPr
ocessWorkerMessagingProxy::workerObjectDestroyedInternal, crossThreadUnretained(
this))); |
225 } | 225 } |
226 | 226 |
227 void InProcessWorkerMessagingProxy::workerObjectDestroyedInternal() | 227 void InProcessWorkerMessagingProxy::workerObjectDestroyedInternal() |
228 { | 228 { |
229 DCHECK(isParentContextThread()); | 229 DCHECK(isParentContextThread()); |
230 m_mayBeDestroyed = true; | 230 m_mayBeDestroyed = true; |
231 if (m_workerThread) | 231 if (m_workerThread) |
232 terminateWorkerGlobalScope(); | 232 terminateWorkerGlobalScope(); |
233 else | 233 else |
234 workerThreadTerminated(); | 234 workerThreadTerminated(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 bool InProcessWorkerMessagingProxy::isParentContextThread() const | 306 bool InProcessWorkerMessagingProxy::isParentContextThread() const |
307 { | 307 { |
308 // TODO(nhiroki): Nested worker is not supported yet, so the parent context | 308 // TODO(nhiroki): Nested worker is not supported yet, so the parent context |
309 // thread should be equal to the main thread (http://crbug.com/31666). | 309 // thread should be equal to the main thread (http://crbug.com/31666). |
310 DCHECK(getExecutionContext()->isDocument()); | 310 DCHECK(getExecutionContext()->isDocument()); |
311 return isMainThread(); | 311 return isMainThread(); |
312 } | 312 } |
313 | 313 |
314 } // namespace blink | 314 } // namespace blink |
OLD | NEW |