Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 | 28 |
| 29 #include "core/workers/WorkerThread.h" | 29 #include "core/workers/WorkerThread.h" |
| 30 | 30 |
| 31 #include "bindings/v8/ScriptSourceCode.h" | 31 #include "bindings/v8/ScriptSourceCode.h" |
| 32 #include "core/inspector/InspectorInstrumentation.h" | 32 #include "core/inspector/InspectorInstrumentation.h" |
| 33 #include "core/inspector/WorkerDebuggerAgent.h" | |
| 34 #include "core/inspector/WorkerInspectorController.h" | |
| 33 #include "core/workers/DedicatedWorkerGlobalScope.h" | 35 #include "core/workers/DedicatedWorkerGlobalScope.h" |
| 34 #include "core/workers/WorkerClients.h" | 36 #include "core/workers/WorkerClients.h" |
| 35 #include "core/workers/WorkerReportingProxy.h" | 37 #include "core/workers/WorkerReportingProxy.h" |
| 36 #include "core/workers/WorkerThreadStartupData.h" | 38 #include "core/workers/WorkerThreadStartupData.h" |
| 37 #include "platform/PlatformThreadData.h" | 39 #include "platform/PlatformThreadData.h" |
| 38 #include "platform/heap/ThreadState.h" | 40 #include "platform/heap/ThreadState.h" |
| 39 #include "platform/weborigin/KURL.h" | 41 #include "platform/weborigin/KURL.h" |
| 40 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
| 41 #include "public/platform/WebWaitableEvent.h" | 43 #include "public/platform/WebWaitableEvent.h" |
| 42 #include "public/platform/WebWorkerRunLoop.h" | 44 #include "public/platform/WebWorkerRunLoop.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 m_threadID = createThread(WorkerThread::workerThreadStart, this, "WebCore: W orker"); | 97 m_threadID = createThread(WorkerThread::workerThreadStart, this, "WebCore: W orker"); |
| 96 | 98 |
| 97 return m_threadID; | 99 return m_threadID; |
| 98 } | 100 } |
| 99 | 101 |
| 100 void WorkerThread::workerThreadStart(void* thread) | 102 void WorkerThread::workerThreadStart(void* thread) |
| 101 { | 103 { |
| 102 static_cast<WorkerThread*>(thread)->workerThread(); | 104 static_cast<WorkerThread*>(thread)->workerThread(); |
| 103 } | 105 } |
| 104 | 106 |
| 107 void WorkerThread::interruptAndDispatchInspectorCommands() | |
| 108 { | |
| 109 if (m_workerDebuggerAgent) | |
|
yurys
2014/06/24 08:49:52
m_workerDebuggerAgent is never initialized as I po
keishi
2014/06/24 14:53:29
I added a mutex to WorkerThread so that WorkerThre
yurys
2014/06/25 05:51:57
The simplest way would be to add a layout test bas
yurys
2014/06/25 07:50:27
Never mind, I'm adding a new test for this: https:
| |
| 110 m_workerDebuggerAgent->interruptAndDispatchInspectorCommands(this); | |
| 111 } | |
| 112 | |
| 105 void WorkerThread::workerThread() | 113 void WorkerThread::workerThread() |
| 106 { | 114 { |
| 107 KURL scriptURL = m_startupData->m_scriptURL; | 115 KURL scriptURL = m_startupData->m_scriptURL; |
| 108 String sourceCode = m_startupData->m_sourceCode; | 116 String sourceCode = m_startupData->m_sourceCode; |
| 109 WorkerThreadStartMode startMode = m_startupData->m_startMode; | 117 WorkerThreadStartMode startMode = m_startupData->m_startMode; |
| 110 | |
| 111 { | 118 { |
| 112 MutexLocker lock(m_threadCreationMutex); | 119 MutexLocker lock(m_threadCreationMutex); |
| 113 ThreadState::attach(); | 120 ThreadState::attach(); |
| 114 m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release()); | 121 m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release()); |
| 115 m_runLoop.setWorkerGlobalScope(workerGlobalScope()); | 122 m_runLoop.setWorkerGlobalScope(workerGlobalScope()); |
| 116 | 123 |
| 117 if (m_runLoop.terminated()) { | 124 if (m_runLoop.terminated()) { |
| 118 // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet, | 125 // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet, |
| 119 // forbidExecution() couldn't be called from stop(). | 126 // forbidExecution() couldn't be called from stop(). |
| 120 m_workerGlobalScope->script()->forbidExecution(); | 127 m_workerGlobalScope->script()->forbidExecution(); |
| 121 } | 128 } |
| 122 } | 129 } |
| 123 // The corresponding call to didStopWorkerRunLoop is in | 130 // The corresponding call to didStopWorkerRunLoop is in |
| 124 // ~WorkerScriptController. | 131 // ~WorkerScriptController. |
| 125 blink::Platform::current()->didStartWorkerRunLoop(blink::WebWorkerRunLoop(&m _runLoop)); | 132 blink::Platform::current()->didStartWorkerRunLoop(blink::WebWorkerRunLoop(&m _runLoop)); |
| 126 | 133 |
| 127 // Notify proxy that a new WorkerGlobalScope has been created and started. | 134 // Notify proxy that a new WorkerGlobalScope has been created and started. |
| 128 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); | 135 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); |
| 129 | 136 |
| 130 WorkerScriptController* script = m_workerGlobalScope->script(); | 137 WorkerScriptController* script = m_workerGlobalScope->script(); |
| 131 if (!script->isExecutionForbidden()) | 138 if (!script->isExecutionForbidden()) |
| 132 script->initializeContextIfNeeded(); | 139 script->initializeContextIfNeeded(); |
| 133 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); | 140 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); |
| 134 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); | 141 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); |
| 135 | 142 |
| 136 runEventLoop(); | 143 runEventLoop(); |
| 144 m_workerDebuggerAgent.clear(); | |
| 137 | 145 |
| 138 // This should be called before we start the shutdown procedure. | 146 // This should be called before we start the shutdown procedure. |
| 139 workerReportingProxy().willDestroyWorkerGlobalScope(); | 147 workerReportingProxy().willDestroyWorkerGlobalScope(); |
| 140 | 148 |
| 141 ThreadIdentifier threadID = m_threadID; | 149 ThreadIdentifier threadID = m_threadID; |
| 142 | 150 |
| 143 // The below assignment will destroy the context, which will in turn notify messaging proxy. | 151 // The below assignment will destroy the context, which will in turn notify messaging proxy. |
| 144 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. | 152 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them. |
| 145 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out. | 153 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out. |
| 146 #if !ENABLE(OILPAN) | 154 #if !ENABLE(OILPAN) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 } | 248 } |
| 241 m_runLoop.terminate(); | 249 m_runLoop.terminate(); |
| 242 } | 250 } |
| 243 | 251 |
| 244 bool WorkerThread::isCurrentThread() const | 252 bool WorkerThread::isCurrentThread() const |
| 245 { | 253 { |
| 246 return m_threadID == currentThread(); | 254 return m_threadID == currentThread(); |
| 247 } | 255 } |
| 248 | 256 |
| 249 } // namespace WebCore | 257 } // namespace WebCore |
| OLD | NEW |