| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 { | 195 { |
| 196 MutexLocker locker(m_workerInspectorControllerMutex); | 196 MutexLocker locker(m_workerInspectorControllerMutex); |
| 197 if (m_workerInspectorController) | 197 if (m_workerInspectorController) |
| 198 m_workerInspectorController->interruptAndDispatchInspectorCommands(); | 198 m_workerInspectorController->interruptAndDispatchInspectorCommands(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 PlatformThreadId WorkerThread::platformThreadId() | 201 PlatformThreadId WorkerThread::platformThreadId() |
| 202 { | 202 { |
| 203 if (!m_started) | 203 if (!m_started) |
| 204 return 0; | 204 return 0; |
| 205 return backingThread().platformThread().threadId(); | 205 return backingThread().threadId(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void WorkerThread::initialize(PassOwnPtr<WorkerThreadStartupData> startupData) | 208 void WorkerThread::initialize(PassOwnPtr<WorkerThreadStartupData> startupData) |
| 209 { | 209 { |
| 210 KURL scriptURL = startupData->m_scriptURL; | 210 KURL scriptURL = startupData->m_scriptURL; |
| 211 String sourceCode = startupData->m_sourceCode; | 211 String sourceCode = startupData->m_sourceCode; |
| 212 WorkerThreadStartMode startMode = startupData->m_startMode; | 212 WorkerThreadStartMode startMode = startupData->m_startMode; |
| 213 OwnPtr<Vector<char>> cachedMetaData = startupData->m_cachedMetaData.release(
); | 213 OwnPtr<Vector<char>> cachedMetaData = startupData->m_cachedMetaData.release(
); |
| 214 V8CacheOptions v8CacheOptions = startupData->m_v8CacheOptions; | 214 V8CacheOptions v8CacheOptions = startupData->m_v8CacheOptions; |
| 215 m_webScheduler = backingThread().platformThread().scheduler(); | 215 m_webScheduler = backingThread().scheduler(); |
| 216 | 216 |
| 217 { | 217 { |
| 218 MutexLocker lock(m_threadStateMutex); | 218 MutexLocker lock(m_threadStateMutex); |
| 219 | 219 |
| 220 // The worker was terminated before the thread had a chance to run. | 220 // The worker was terminated before the thread had a chance to run. |
| 221 if (m_terminated) { | 221 if (m_terminated) { |
| 222 // Notify the proxy that the WorkerGlobalScope has been disposed of. | 222 // Notify the proxy that the WorkerGlobalScope has been disposed of. |
| 223 // This can free this thread object, hence it must not be touched af
terwards. | 223 // This can free this thread object, hence it must not be touched af
terwards. |
| 224 m_workerReportingProxy.workerThreadTerminated(); | 224 m_workerReportingProxy.workerThreadTerminated(); |
| 225 // Notify the main thread that it is safe to deallocate our resource
s. | 225 // Notify the main thread that it is safe to deallocate our resource
s. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 if (deadlineSeconds > Platform::current()->monotonicallyIncreasingTime()) | 408 if (deadlineSeconds > Platform::current()->monotonicallyIncreasingTime()) |
| 409 gcFinished = isolate()->IdleNotificationDeadline(deadlineSeconds); | 409 gcFinished = isolate()->IdleNotificationDeadline(deadlineSeconds); |
| 410 return gcFinished; | 410 return gcFinished; |
| 411 } | 411 } |
| 412 | 412 |
| 413 void WorkerThread::postTask(const WebTraceLocation& location, PassOwnPtr<Executi
onContextTask> task) | 413 void WorkerThread::postTask(const WebTraceLocation& location, PassOwnPtr<Executi
onContextTask> task) |
| 414 { | 414 { |
| 415 backingThread().postTask(location, WorkerThreadTask::create(*this, task, tru
e).leakPtr()); | 415 backingThread().postTask(location, WorkerThreadTask::create(*this, task, tru
e).leakPtr()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void WorkerThread::postDelayedTask(const WebTraceLocation& location, PassOwnPtr<
ExecutionContextTask> task, long long delayMs) | |
| 419 { | |
| 420 backingThread().postDelayedTask(location, WorkerThreadTask::create(*this, ta
sk, true).leakPtr(), delayMs); | |
| 421 } | |
| 422 | |
| 423 void WorkerThread::initializeBackingThread() | 418 void WorkerThread::initializeBackingThread() |
| 424 { | 419 { |
| 425 ASSERT(isCurrentThread()); | 420 ASSERT(isCurrentThread()); |
| 426 backingThread().initialize(); | 421 m_gcSupport = GCSupportForWebThread::create(backingThread()); |
| 427 } | 422 } |
| 428 | 423 |
| 429 void WorkerThread::shutdownBackingThread() | 424 void WorkerThread::shutdownBackingThread() |
| 430 { | 425 { |
| 431 ASSERT(isCurrentThread()); | 426 ASSERT(isCurrentThread()); |
| 432 backingThread().shutdown(); | 427 m_webScheduler->shutdown(); |
| 428 m_gcSupport.clear(); |
| 433 } | 429 } |
| 434 | 430 |
| 435 v8::Isolate* WorkerThread::initializeIsolate() | 431 v8::Isolate* WorkerThread::initializeIsolate() |
| 436 { | 432 { |
| 437 ASSERT(isCurrentThread()); | 433 ASSERT(isCurrentThread()); |
| 438 ASSERT(!m_isolate); | 434 ASSERT(!m_isolate); |
| 439 v8::Isolate* isolate = V8PerIsolateData::initialize(); | 435 v8::Isolate* isolate = V8PerIsolateData::initialize(); |
| 440 V8Initializer::initializeWorker(isolate); | 436 V8Initializer::initializeWorker(isolate); |
| 441 | 437 |
| 442 OwnPtr<V8IsolateInterruptor> interruptor = adoptPtr(new V8IsolateInterruptor
(isolate)); | 438 OwnPtr<V8IsolateInterruptor> interruptor = adoptPtr(new V8IsolateInterruptor
(isolate)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); | 503 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); |
| 508 } | 504 } |
| 509 | 505 |
| 510 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
rInspectorController) | 506 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
rInspectorController) |
| 511 { | 507 { |
| 512 MutexLocker locker(m_workerInspectorControllerMutex); | 508 MutexLocker locker(m_workerInspectorControllerMutex); |
| 513 m_workerInspectorController = workerInspectorController; | 509 m_workerInspectorController = workerInspectorController; |
| 514 } | 510 } |
| 515 | 511 |
| 516 } // namespace blink | 512 } // namespace blink |
| OLD | NEW |