diff options
author | Steve Block <steveblock@google.com> | 2009-12-15 10:12:09 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-12-17 17:41:10 +0000 |
commit | 643ca7872b450ea4efacab6188849e5aac2ba161 (patch) | |
tree | 6982576c228bcd1a7efe98afed544d840751094c /WebCore/workers/WorkerRunLoop.cpp | |
parent | d026980fde6eb3b01c1fe49441174e89cd1be298 (diff) | |
download | external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.zip external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.gz external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.bz2 |
Merge webkit.org at r51976 : Initial merge by git.
Change-Id: Ib0e7e2f0fb4bee5a186610272edf3186f0986b43
Diffstat (limited to 'WebCore/workers/WorkerRunLoop.cpp')
-rw-r--r-- | WebCore/workers/WorkerRunLoop.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/WebCore/workers/WorkerRunLoop.cpp b/WebCore/workers/WorkerRunLoop.cpp index 39b21c6..445fa65 100644 --- a/WebCore/workers/WorkerRunLoop.cpp +++ b/WebCore/workers/WorkerRunLoop.cpp @@ -64,27 +64,6 @@ private: double m_nextFireTime; }; -class WorkerRunLoop::Task : public RefCounted<Task> { -public: - static PassRefPtr<Task> create(PassRefPtr<ScriptExecutionContext::Task> task, const String& mode) - { - return adoptRef(new Task(task, mode)); - } - - const String& mode() const { return m_mode; } - void performTask(ScriptExecutionContext* context) { m_task->performTask(context); } - -private: - Task(PassRefPtr<ScriptExecutionContext::Task> task, const String& mode) - : m_task(task) - , m_mode(mode.crossThreadString()) - { - } - - RefPtr<ScriptExecutionContext::Task> m_task; - String m_mode; -}; - class ModePredicate { public: ModePredicate(const String& mode) @@ -98,7 +77,7 @@ public: return m_defaultMode; } - bool operator()(PassRefPtr<WorkerRunLoop::Task> task) const + bool operator()(WorkerRunLoop::Task* task) const { return m_defaultMode || m_mode == task->mode(); } @@ -169,9 +148,9 @@ MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerContext* context, const Mo ASSERT(context->thread()); ASSERT(context->thread()->threadID() == currentThread()); - double absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<RefPtr<Task> >::infiniteTime(); - RefPtr<Task> task; - MessageQueueWaitResult result = m_messageQueue.waitForMessageFilteredWithTimeout(task, predicate, absoluteTime); + double absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime(); + MessageQueueWaitResult result; + OwnPtr<WorkerRunLoop::Task> task = m_messageQueue.waitForMessageFilteredWithTimeout(result, predicate, absoluteTime); // If the context is closing, don't dispatch any further tasks (per section 4.1.1 of the Web Workers spec). if (context->isClosing()) @@ -198,16 +177,33 @@ void WorkerRunLoop::terminate() m_messageQueue.kill(); } -void WorkerRunLoop::postTask(PassRefPtr<ScriptExecutionContext::Task> task) +void WorkerRunLoop::postTask(PassOwnPtr<ScriptExecutionContext::Task> task) { postTaskForMode(task, defaultMode()); } -void WorkerRunLoop::postTaskForMode(PassRefPtr<ScriptExecutionContext::Task> task, const String& mode) +void WorkerRunLoop::postTaskForMode(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) { m_messageQueue.append(Task::create(task, mode.crossThreadString())); } +PassOwnPtr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) +{ + return new Task(task, mode); +} + +void WorkerRunLoop::Task::performTask(ScriptExecutionContext* context) +{ + m_task->performTask(context); +} + +WorkerRunLoop::Task::Task(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode) + : m_task(task) + , m_mode(mode.crossThreadString()) +{ +} + + } // namespace WebCore #endif // ENABLE(WORKERS) |