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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 { | 114 { |
115 // FIXME: This need to be revisited when we support nested worker one day | 115 // FIXME: This need to be revisited when we support nested worker one day |
116 ASSERT(m_executionContext->isDocument()); | 116 ASSERT(m_executionContext->isDocument()); |
117 if (m_askedToTerminate) { | 117 if (m_askedToTerminate) { |
118 // Worker.terminate() could be called from JS before the thread was crea
ted. | 118 // Worker.terminate() could be called from JS before the thread was crea
ted. |
119 return; | 119 return; |
120 } | 120 } |
121 Document* document = toDocument(m_executionContext.get()); | 121 Document* document = toDocument(m_executionContext.get()); |
122 SecurityOrigin* starterOrigin = document->securityOrigin(); | 122 SecurityOrigin* starterOrigin = document->securityOrigin(); |
123 | 123 |
124 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu
pData::create(scriptURL, userAgent, sourceCode, nullptr, startMode, document->co
ntentSecurityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->de
precatedHeaderType(), starterOrigin, m_workerClients.release()); | 124 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat
e(scriptURL, userAgent, sourceCode, nullptr, startMode, document->contentSecurit
yPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedHead
erType(), starterOrigin, m_workerClients.release()); |
125 double originTime = document->loader() ? document->loader()->timing().refere
nceMonotonicTime() : monotonicallyIncreasingTime(); | 125 double originTime = document->loader() ? document->loader()->timing().refere
nceMonotonicTime() : monotonicallyIncreasingTime(); |
126 | 126 |
127 m_loaderProxy = WorkerLoaderProxy::create(this); | 127 m_loaderProxy = WorkerLoaderProxy::create(this); |
128 RefPtr<WorkerThread> thread = createWorkerThread(originTime, startupData.rel
ease()); | 128 RefPtr<WorkerThread> thread = createWorkerThread(originTime, startupData.rel
ease()); |
129 thread->start(); | 129 thread->start(); |
130 workerThreadCreated(thread); | 130 workerThreadCreated(thread); |
131 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work
erThread.get(), scriptURL); | 131 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work
erThread.get(), scriptURL); |
132 } | 132 } |
133 | 133 |
134 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) | 134 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript
Value> message, PassOwnPtr<MessagePortChannelArray> channels) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(FROM_HERE, earlyTasks.release()); |
213 m_queuedEarlyTasks.clear(); | 213 m_queuedEarlyTasks.clear(); |
214 } | 214 } |
215 | 215 |
216 PassRefPtr<WorkerThread> WorkerMessagingProxy::createWorkerThread(double originT
ime, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData) | 216 PassRefPtr<WorkerThread> WorkerMessagingProxy::createWorkerThread(double originT
ime, PassOwnPtr<WorkerThreadStartupData> startupData) |
217 { | 217 { |
218 return DedicatedWorkerThread::create(loaderProxy(), workerObjectProxy(), ori
ginTime, startupData); | 218 return DedicatedWorkerThread::create(loaderProxy(), workerObjectProxy(), ori
ginTime, startupData); |
219 } | 219 } |
220 | 220 |
221 void WorkerMessagingProxy::workerObjectDestroyed() | 221 void WorkerMessagingProxy::workerObjectDestroyed() |
222 { | 222 { |
223 m_workerObject = nullptr; | 223 m_workerObject = nullptr; |
224 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD
estroyedInternal, AllowCrossThreadAccess(this))); | 224 m_executionContext->postTask(FROM_HERE, createCrossThreadTask(&workerObjectD
estroyedInternal, AllowCrossThreadAccess(this))); |
225 } | 225 } |
226 | 226 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 // FIXME: This need to be revisited when we support nested worker one day | 305 // FIXME: This need to be revisited when we support nested worker one day |
306 ASSERT(m_executionContext->isDocument()); | 306 ASSERT(m_executionContext->isDocument()); |
307 Document* document = toDocument(m_executionContext.get()); | 307 Document* document = toDocument(m_executionContext.get()); |
308 LocalFrame* frame = document->frame(); | 308 LocalFrame* frame = document->frame(); |
309 if (frame) | 309 if (frame) |
310 frame->console().adoptWorkerMessagesAfterTermination(this); | 310 frame->console().adoptWorkerMessagesAfterTermination(this); |
311 } | 311 } |
312 | 312 |
313 } // namespace blink | 313 } // namespace blink |
OLD | NEW |