| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 m_workerObject->dispatchEvent(MessageEvent::create(ports.release(), message)
); | 140 m_workerObject->dispatchEvent(MessageEvent::create(ports.release(), message)
); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
criptValue> message, PassOwnPtr<MessagePortChannelArray> channels) | 143 void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
criptValue> message, PassOwnPtr<MessagePortChannelArray> channels) |
| 144 { | 144 { |
| 145 if (m_askedToTerminate) | 145 if (m_askedToTerminate) |
| 146 return; | 146 return; |
| 147 | 147 |
| 148 if (m_workerThread) { | 148 if (m_workerThread) { |
| 149 ++m_unconfirmedMessageCount; | 149 ++m_unconfirmedMessageCount; |
| 150 m_workerThread->postTask(FROM_HERE, MessageWorkerGlobalScopeTask::create
(message, channels)); | 150 m_workerThread->postTask(MessageWorkerGlobalScopeTask::create(message, c
hannels)); |
| 151 } else | 151 } else |
| 152 m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message,
channels)); | 152 m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message,
channels)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool WorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionConte
xtTask> task) | 155 bool WorkerMessagingProxy::postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionConte
xtTask> task) |
| 156 { | 156 { |
| 157 if (m_askedToTerminate) | 157 if (m_askedToTerminate) |
| 158 return false; | 158 return false; |
| 159 | 159 |
| 160 ASSERT(m_workerThread); | 160 ASSERT(m_workerThread); |
| 161 m_workerThread->postTask(FROM_HERE, task); | 161 m_workerThread->postTask(task); |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ExecutionContextTask> tas
k) | 165 void WorkerMessagingProxy::postTaskToLoader(PassOwnPtr<ExecutionContextTask> tas
k) |
| 166 { | 166 { |
| 167 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. | 167 // FIXME: In case of nested workers, this should go directly to the root Doc
ument context. |
| 168 ASSERT(m_executionContext->isDocument()); | 168 ASSERT(m_executionContext->isDocument()); |
| 169 m_executionContext->postTask(FROM_HERE, task); | 169 m_executionContext->postTask(FROM_HERE, task); |
| 170 } | 170 } |
| 171 | 171 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 202 void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<DedicatedWorkerThread>
workerThread) | 202 void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<DedicatedWorkerThread>
workerThread) |
| 203 { | 203 { |
| 204 ASSERT(!m_askedToTerminate); | 204 ASSERT(!m_askedToTerminate); |
| 205 m_workerThread = workerThread; | 205 m_workerThread = workerThread; |
| 206 | 206 |
| 207 ASSERT(!m_unconfirmedMessageCount); | 207 ASSERT(!m_unconfirmedMessageCount); |
| 208 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); | 208 m_unconfirmedMessageCount = m_queuedEarlyTasks.size(); |
| 209 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe
nding activity. | 209 m_workerThreadHadPendingActivity = true; // Worker initialization means a pe
nding activity. |
| 210 | 210 |
| 211 for (auto& earlyTasks : m_queuedEarlyTasks) | 211 for (auto& earlyTasks : m_queuedEarlyTasks) |
| 212 m_workerThread->postTask(FROM_HERE, earlyTasks.release()); | 212 m_workerThread->postTask(earlyTasks.release()); |
| 213 m_queuedEarlyTasks.clear(); | 213 m_queuedEarlyTasks.clear(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void WorkerMessagingProxy::workerObjectDestroyed() | 216 void WorkerMessagingProxy::workerObjectDestroyed() |
| 217 { | 217 { |
| 218 m_workerObject = nullptr; | 218 m_workerObject = nullptr; |
| 219 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD
estroyedInternal, AllowCrossThreadAccess(this))); | 219 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD
estroyedInternal, AllowCrossThreadAccess(this))); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void WorkerMessagingProxy::workerObjectDestroyedInternal(ExecutionContext*, Work
erMessagingProxy* proxy) | 222 void WorkerMessagingProxy::workerObjectDestroyedInternal(ExecutionContext*, Work
erMessagingProxy* proxy) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 // FIXME: This need to be revisited when we support nested worker one day | 300 // FIXME: This need to be revisited when we support nested worker one day |
| 301 ASSERT(m_executionContext->isDocument()); | 301 ASSERT(m_executionContext->isDocument()); |
| 302 Document* document = toDocument(m_executionContext.get()); | 302 Document* document = toDocument(m_executionContext.get()); |
| 303 LocalFrame* frame = document->frame(); | 303 LocalFrame* frame = document->frame(); |
| 304 if (frame) | 304 if (frame) |
| 305 frame->console().adoptWorkerMessagesAfterTermination(this); | 305 frame->console().adoptWorkerMessagesAfterTermination(this); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace blink | 308 } // namespace blink |
| OLD | NEW |