void HTMLParserThread::setupHTMLParserThread()
{
    m_pendingGCRunner = adoptPtr(new PendingGCRunner);
    m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(&platformThread()));
    platformThread().addTaskObserver(m_pendingGCRunner.get());
    ThreadState::attach();
    ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get());
}
void WebThreadSupportingGC::initialize()
{
    m_pendingGCRunner = adoptPtr(new PendingGCRunner);
    m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(&platformThread()));
    platformThread().addTaskObserver(m_pendingGCRunner.get());
    ThreadState::attach();
    ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get());
}
void WebThreadSupportingGC::shutdown()
{
    // Ensure no posted tasks will run from this point on.
    platformThread().removeTaskObserver(m_pendingGCRunner.get());
    platformThread().scheduler()->shutdown();

    ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
    ThreadState::detach();
    m_pendingGCRunner = nullptr;
    m_messageLoopInterruptor = nullptr;

    // Ensure no posted tasks will run from this point on.
    platformThread().scheduler()->shutdown();
}
void ScriptStreamerThread::postTask(PassOwnPtr<Closure> task)
{
    ASSERT(isMainThread());
    MutexLocker locker(m_mutex);
    ASSERT(!m_runningTask);
    m_runningTask = true;
    platformThread().taskRunner()->postTask(BLINK_FROM_HERE, task);
}
void ScriptStreamerThread::postTask(std::unique_ptr<CrossThreadClosure> task) {
  ASSERT(isMainThread());
  MutexLocker locker(m_mutex);
  ASSERT(!m_runningTask);
  m_runningTask = true;
  platformThread().getWebTaskRunner()->postTask(BLINK_FROM_HERE,
                                                std::move(task));
}
void ScriptStreamerThread::postTask(WebThread::Task* task)
{
    ASSERT(isMainThread());
    MutexLocker locker(m_mutex);
    ASSERT(!m_runningTask);
    m_runningTask = true;
    platformThread().postTask(task);
}
void HTMLParserThread::cleanupHTMLParserThread(TaskSynchronizer* taskSynchronizer)
{
    ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
    ThreadState::detach();
    platformThread().removeTaskObserver(m_pendingGCRunner.get());
    m_pendingGCRunner = nullptr;
    m_messageLoopInterruptor = nullptr;
    taskSynchronizer->taskCompleted();
}
void HTMLParserThread::postTask(const Closure& closure)
{
    platformThread().postTask(new Task(closure));
}