OLD | NEW |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 MutexLocker lock(m_threadCreationMutex); | 135 MutexLocker lock(m_threadCreationMutex); |
136 m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_star
tupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_c
ontentSecurityPolicyType); | 136 m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_star
tupData->m_userAgent, m_startupData->m_contentSecurityPolicy, m_startupData->m_c
ontentSecurityPolicyType); |
137 | 137 |
138 if (m_runLoop.terminated()) { | 138 if (m_runLoop.terminated()) { |
139 // The worker was terminated before the thread had a chance to run.
Since the context didn't exist yet, | 139 // The worker was terminated before the thread had a chance to run.
Since the context didn't exist yet, |
140 // forbidExecution() couldn't be called from stop(). | 140 // forbidExecution() couldn't be called from stop(). |
141 m_workerContext->script()->forbidExecution(); | 141 m_workerContext->script()->forbidExecution(); |
142 } | 142 } |
143 } | 143 } |
144 #if PLATFORM(CHROMIUM) | 144 #if PLATFORM(CHROMIUM) |
| 145 // The corresponding call to didStopWorkerRunLoop is in |
| 146 // ~WorkerScriptController. |
145 PlatformSupport::didStartWorkerRunLoop(&m_runLoop); | 147 PlatformSupport::didStartWorkerRunLoop(&m_runLoop); |
146 #endif | 148 #endif |
147 | 149 |
148 WorkerScriptController* script = m_workerContext->script(); | 150 WorkerScriptController* script = m_workerContext->script(); |
149 #if ENABLE(INSPECTOR) | 151 #if ENABLE(INSPECTOR) |
150 InspectorInstrumentation::willEvaluateWorkerScript(workerContext(), m_startu
pData->m_startMode); | 152 InspectorInstrumentation::willEvaluateWorkerScript(workerContext(), m_startu
pData->m_startMode); |
151 #endif | 153 #endif |
152 script->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData
->m_scriptURL)); | 154 script->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData
->m_scriptURL)); |
153 // Free the startup data to cause its member variable deref's happen on the
worker's thread (since | 155 // Free the startup data to cause its member variable deref's happen on the
worker's thread (since |
154 // all ref/derefs of these objects are happening on the thread at this point
). Note that | 156 // all ref/derefs of these objects are happening on the thread at this point
). Note that |
155 // WorkerThread::~WorkerThread happens on a different thread where it was cr
eated. | 157 // WorkerThread::~WorkerThread happens on a different thread where it was cr
eated. |
156 m_startupData.clear(); | 158 m_startupData.clear(); |
157 | 159 |
158 runEventLoop(); | 160 runEventLoop(); |
159 | 161 |
160 #if PLATFORM(CHROMIUM) | |
161 PlatformSupport::didStopWorkerRunLoop(&m_runLoop); | |
162 #endif | |
163 | |
164 ThreadIdentifier threadID = m_threadID; | 162 ThreadIdentifier threadID = m_threadID; |
165 | 163 |
166 ASSERT(m_workerContext->hasOneRef()); | 164 ASSERT(m_workerContext->hasOneRef()); |
167 | 165 |
168 // The below assignment will destroy the context, which will in turn notify
messaging proxy. | 166 // The below assignment will destroy the context, which will in turn notify
messaging proxy. |
169 // We cannot let any objects survive past thread exit, because no other thre
ad will run GC or otherwise destroy them. | 167 // We cannot let any objects survive past thread exit, because no other thre
ad will run GC or otherwise destroy them. |
170 m_workerContext = 0; | 168 m_workerContext = 0; |
171 | 169 |
172 // Clean up WebCore::ThreadGlobalData before WTF::WTFThreadData goes away! | 170 // Clean up WebCore::ThreadGlobalData before WTF::WTFThreadData goes away! |
173 threadGlobalData().destroy(); | 171 threadGlobalData().destroy(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 DatabaseTracker::tracker().interruptAllDatabasesForContext(m_workerConte
xt.get()); | 254 DatabaseTracker::tracker().interruptAllDatabasesForContext(m_workerConte
xt.get()); |
257 #endif | 255 #endif |
258 m_runLoop.postTask(WorkerThreadShutdownStartTask::create()); | 256 m_runLoop.postTask(WorkerThreadShutdownStartTask::create()); |
259 } | 257 } |
260 m_runLoop.terminate(); | 258 m_runLoop.terminate(); |
261 } | 259 } |
262 | 260 |
263 } // namespace WebCore | 261 } // namespace WebCore |
264 | 262 |
265 #endif // ENABLE(WORKERS) | 263 #endif // ENABLE(WORKERS) |
OLD | NEW |