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 18 matching lines...) Expand all Loading... |
29 #include "core/workers/WorkerThread.h" | 29 #include "core/workers/WorkerThread.h" |
30 | 30 |
31 #include "bindings/core/v8/ScriptSourceCode.h" | 31 #include "bindings/core/v8/ScriptSourceCode.h" |
32 #include "bindings/core/v8/V8Initializer.h" | 32 #include "bindings/core/v8/V8Initializer.h" |
33 #include "core/dom/Microtask.h" | 33 #include "core/dom/Microtask.h" |
34 #include "core/inspector/InspectorInstrumentation.h" | 34 #include "core/inspector/InspectorInstrumentation.h" |
35 #include "core/inspector/WorkerInspectorController.h" | 35 #include "core/inspector/WorkerInspectorController.h" |
36 #include "core/workers/DedicatedWorkerGlobalScope.h" | 36 #include "core/workers/DedicatedWorkerGlobalScope.h" |
37 #include "core/workers/WorkerClients.h" | 37 #include "core/workers/WorkerClients.h" |
38 #include "core/workers/WorkerReportingProxy.h" | 38 #include "core/workers/WorkerReportingProxy.h" |
| 39 #include "core/workers/WorkerScriptCachedMetadataHandler.h" |
39 #include "core/workers/WorkerThreadStartupData.h" | 40 #include "core/workers/WorkerThreadStartupData.h" |
40 #include "platform/PlatformThreadData.h" | 41 #include "platform/PlatformThreadData.h" |
41 #include "platform/Task.h" | 42 #include "platform/Task.h" |
42 #include "platform/ThreadTimers.h" | 43 #include "platform/ThreadTimers.h" |
43 #include "platform/heap/ThreadState.h" | 44 #include "platform/heap/ThreadState.h" |
44 #include "platform/weborigin/KURL.h" | 45 #include "platform/weborigin/KURL.h" |
45 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
46 #include "public/platform/WebThread.h" | 47 #include "public/platform/WebThread.h" |
47 #include "public/platform/WebWaitableEvent.h" | 48 #include "public/platform/WebWaitableEvent.h" |
48 #include "public/platform/WebWorkerRunLoop.h" | 49 #include "public/platform/WebWorkerRunLoop.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 if (!m_thread) | 305 if (!m_thread) |
305 return 0; | 306 return 0; |
306 return m_thread->platformThread().threadId(); | 307 return m_thread->platformThread().threadId(); |
307 } | 308 } |
308 | 309 |
309 void WorkerThread::initialize() | 310 void WorkerThread::initialize() |
310 { | 311 { |
311 KURL scriptURL = m_startupData->m_scriptURL; | 312 KURL scriptURL = m_startupData->m_scriptURL; |
312 String sourceCode = m_startupData->m_sourceCode; | 313 String sourceCode = m_startupData->m_sourceCode; |
313 WorkerThreadStartMode startMode = m_startupData->m_startMode; | 314 WorkerThreadStartMode startMode = m_startupData->m_startMode; |
| 315 OwnPtr<Vector<char>> cachedMetaData = m_startupData->m_cachedMetaData.releas
e(); |
| 316 V8CacheOptions v8CacheOptions = m_startupData->m_v8CacheOptions; |
314 | 317 |
315 { | 318 { |
316 MutexLocker lock(m_threadCreationMutex); | 319 MutexLocker lock(m_threadCreationMutex); |
317 | 320 |
318 // The worker was terminated before the thread had a chance to run. | 321 // The worker was terminated before the thread had a chance to run. |
319 if (m_terminated) { | 322 if (m_terminated) { |
320 // Notify the proxy that the WorkerGlobalScope has been disposed of. | 323 // Notify the proxy that the WorkerGlobalScope has been disposed of. |
321 // This can free this thread object, hence it must not be touched af
terwards. | 324 // This can free this thread object, hence it must not be touched af
terwards. |
322 m_workerReportingProxy.workerThreadTerminated(); | 325 m_workerReportingProxy.workerThreadTerminated(); |
323 return; | 326 return; |
(...skipping 11 matching lines...) Expand all Loading... |
335 // The corresponding call to stopRunLoop() is in ~WorkerScriptController(). | 338 // The corresponding call to stopRunLoop() is in ~WorkerScriptController(). |
336 didStartRunLoop(); | 339 didStartRunLoop(); |
337 | 340 |
338 // Notify proxy that a new WorkerGlobalScope has been created and started. | 341 // Notify proxy that a new WorkerGlobalScope has been created and started. |
339 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); | 342 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); |
340 | 343 |
341 WorkerScriptController* script = m_workerGlobalScope->script(); | 344 WorkerScriptController* script = m_workerGlobalScope->script(); |
342 if (!script->isExecutionForbidden()) | 345 if (!script->isExecutionForbidden()) |
343 script->initializeContextIfNeeded(); | 346 script->initializeContextIfNeeded(); |
344 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star
tMode); | 347 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star
tMode); |
345 bool success = script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); | 348 WorkerScriptCachedMetadataHandler handler(workerGlobalScope(), scriptURL, ca
chedMetaData.get()); |
| 349 bool success = script->evaluate(ScriptSourceCode(sourceCode, scriptURL), nul
lptr, &handler, v8CacheOptions); |
346 m_workerGlobalScope->didEvaluateWorkerScript(); | 350 m_workerGlobalScope->didEvaluateWorkerScript(); |
347 m_workerReportingProxy.didEvaluateWorkerScript(success); | 351 m_workerReportingProxy.didEvaluateWorkerScript(success); |
348 | 352 |
349 postInitialize(); | 353 postInitialize(); |
350 | 354 |
351 postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kSho
rtIdleHandlerDelayMs); | 355 postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kSho
rtIdleHandlerDelayMs); |
352 } | 356 } |
353 | 357 |
354 void WorkerThread::cleanup() | 358 void WorkerThread::cleanup() |
355 { | 359 { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); | 570 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); |
567 } | 571 } |
568 | 572 |
569 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
rInspectorController) | 573 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
rInspectorController) |
570 { | 574 { |
571 MutexLocker locker(m_workerInspectorControllerMutex); | 575 MutexLocker locker(m_workerInspectorControllerMutex); |
572 m_workerInspectorController = workerInspectorController; | 576 m_workerInspectorController = workerInspectorController; |
573 } | 577 } |
574 | 578 |
575 } // namespace blink | 579 } // namespace blink |
OLD | NEW |