Clean up ScriptExecutionContext::Task and subclasses
[WebKit-https.git] / Source / WebCore / workers / WorkerEventQueue.cpp
index 0cc4789..d4cddea 100644 (file)
@@ -48,9 +48,11 @@ WorkerEventQueue::~WorkerEventQueue()
 
 class WorkerEventQueue::EventDispatcherTask FINAL : public ScriptExecutionContext::Task {
 public:
-    static PassOwnPtr<EventDispatcherTask> create(PassRefPtr<Event> event, WorkerEventQueue& eventQueue)
+    EventDispatcherTask(PassRefPtr<Event> event, WorkerEventQueue& eventQueue)
+        : m_event(event)
+        , m_eventQueue(eventQueue)
+        , m_isCancelled(false)
     {
-        return adoptPtr(new EventDispatcherTask(event, eventQueue));
     }
 
     virtual ~EventDispatcherTask()
@@ -59,11 +61,13 @@ public:
             m_eventQueue.m_eventTaskMap.remove(m_event.get());
     }
 
-    void dispatchEvent(ScriptExecutionContext*, PassRefPtr<Event> event)
+    void cancel()
     {
-        event->target()->dispatchEvent(event);
+        m_isCancelled = true;
+        m_event.clear();
     }
 
+private:
     virtual void performTask(ScriptExecutionContext* context) OVERRIDE
     {
         if (m_isCancelled)
@@ -73,18 +77,9 @@ public:
         m_event.clear();
     }
 
-    void cancel()
-    {
-        m_isCancelled = true;
-        m_event.clear();
-    }
-
-private:
-    EventDispatcherTask(PassRefPtr<Event> event, WorkerEventQueue& eventQueue)
-        : m_event(event)
-        , m_eventQueue(eventQueue)
-        , m_isCancelled(false)
+    void dispatchEvent(ScriptExecutionContext*, PassRefPtr<Event> event)
     {
+        event->target()->dispatchEvent(event);
     }
 
     RefPtr<Event> m_event;
@@ -97,9 +92,9 @@ bool WorkerEventQueue::enqueueEvent(PassRefPtr<Event> prpEvent)
     if (m_isClosed)
         return false;
     RefPtr<Event> event = prpEvent;
-    OwnPtr<EventDispatcherTask> task = EventDispatcherTask::create(event, *this);
+    auto task = std::make_unique<EventDispatcherTask>(event, *this);
     m_eventTaskMap.add(event.release(), task.get());
-    m_scriptExecutionContext.postTask(task.release());
+    m_scriptExecutionContext.postTask(std::move(task));
     return true;
 }