| Index: Source/core/workers/WorkerThread.cpp
|
| diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
|
| index 166679e448d1e49897a71187389409c8dec51f31..d93ead1582f5f5546d4caa41b72bf40ff0ce8fed 100644
|
| --- a/Source/core/workers/WorkerThread.cpp
|
| +++ b/Source/core/workers/WorkerThread.cpp
|
| @@ -34,6 +34,8 @@
|
| #include "core/inspector/WorkerInspectorController.h"
|
| #include "core/workers/DedicatedWorkerGlobalScope.h"
|
| #include "core/workers/WorkerClients.h"
|
| +#include "core/workers/WorkerGlobalScope.h"
|
| +#include "core/workers/WorkerLanguageTasks.h"
|
| #include "core/workers/WorkerReportingProxy.h"
|
| #include "core/workers/WorkerThreadStartupData.h"
|
| #include "platform/PlatformThreadData.h"
|
| @@ -225,7 +227,7 @@ void WorkerThread::start()
|
| if (m_thread)
|
| return;
|
|
|
| - m_thread = WebThreadSupportingGC::create("WebCore: Worker");
|
| + m_thread = adoptPtr(blink::Platform::current()->createThread("WebCore: Worker"));
|
| m_thread->postTask(new Task(WTF::bind(&WorkerThread::initialize, this)));
|
| }
|
|
|
| @@ -240,7 +242,7 @@ PlatformThreadId WorkerThread::platformThreadId() const
|
| {
|
| if (!m_thread)
|
| return 0;
|
| - return m_thread->platformThread().threadId();
|
| + return m_thread->threadId();
|
| }
|
|
|
| void WorkerThread::initialize()
|
| @@ -262,7 +264,11 @@ void WorkerThread::initialize()
|
|
|
| m_microtaskRunner = adoptPtr(new MicrotaskRunner);
|
| m_thread->addTaskObserver(m_microtaskRunner.get());
|
| - m_thread->attachGC();
|
| + m_pendingGCRunner = adoptPtr(new PendingGCRunner);
|
| + m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(m_thread.get()));
|
| + m_thread->addTaskObserver(m_pendingGCRunner.get());
|
| + ThreadState::attach();
|
| + ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get());
|
| m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release());
|
|
|
| m_sharedTimer = adoptPtr(new WorkerSharedTimer(this));
|
| @@ -302,10 +308,23 @@ void WorkerThread::cleanup()
|
| m_workerGlobalScope->dispose();
|
| m_workerGlobalScope = nullptr;
|
|
|
| - m_thread->detachGC();
|
| + ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
|
| +
|
| + // Detach the ThreadState, cleaning out the thread's heap by
|
| + // performing a final GC. The cleanup operation will at the end
|
| + // assert that the heap is empty. If the heap does not become
|
| + // empty, there are still pointers into the heap and those
|
| + // pointers will be dangling after thread termination because we
|
| + // are destroying the heap. It is important to detach while the
|
| + // thread is still valid. In particular, finalizers for objects in
|
| + // the heap for this thread will need to access thread local data.
|
| + ThreadState::detach();
|
|
|
| m_thread->removeTaskObserver(m_microtaskRunner.get());
|
| m_microtaskRunner = nullptr;
|
| + m_thread->removeTaskObserver(m_pendingGCRunner.get());
|
| + m_pendingGCRunner = nullptr;
|
| + m_messageLoopInterruptor = nullptr;
|
|
|
| // Notify the proxy that the WorkerGlobalScope has been disposed of.
|
| // This can free this thread object, hence it must not be touched afterwards.
|
| @@ -485,4 +504,38 @@ void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
|
| m_workerInspectorController = workerInspectorController;
|
| }
|
|
|
| +void WorkerThread::postTaskLanguageChanged()
|
| +{
|
| + postTask(WorkerThreadAcceptLanguagesChangedTask::create());
|
| +}
|
| +
|
| +void WorkerThread::notifyAcceptLanguagesChanged(const Vector<String>& newLanguagesList)
|
| +{
|
| + MutexLocker lock(threadSetMutex());
|
| + HashSet<WorkerThread*> threads = workerThreads();
|
| +
|
| + for (HashSet<WorkerThread*>::iterator itr = threads.begin(); itr != threads.end(); ++itr) {
|
| + // Set the new languages list
|
| + (*itr)->postTask(WorkerThreadSetUserPreferredLanguagesTask::create(newLanguagesList));
|
| + // Mark the langs have changed and queue up an event
|
| + (*itr)->postTask(WorkerThreadAcceptLanguagesChangedTask::create());
|
| + }
|
| +}
|
| +
|
| +// void WorkerThread::notifyAcceptLanguagesChanged(const String& newLanguagesList)
|
| +// {
|
| +// MutexLocker lock(threadSetMutex());
|
| +// HashSet<WorkerThread*> threads = workerThreads();
|
| +// Vector<String> languages;
|
| +// String acceptLanguages = m_frame->host()->chrome().client().acceptLanguages();
|
| +// acceptLanguages.split(',', languages);
|
| +
|
| +// for (HashSet<WorkerThread*>::iterator itr = threads.begin(); itr != threads.end(); ++itr) {
|
| +// // Set the new languages list
|
| +// (*itr)->postTask(WorkerThreadSetUserPreferredLanguagesTask::create(languages));
|
| +// // Mark the langs have changed and queue up an event
|
| +// (*itr)->postTask(WorkerThreadAcceptLanguagesChangedTask::create());
|
| +// }
|
| +// }
|
| +
|
| } // namespace blink
|
|
|