⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 201496 in webkit


Ignore:
Timestamp:
May 29, 2016, 9:30:22 PM (10 years ago)
Author:
beidson@apple.com
Message:

Make ScriptExecutionContext::Task work in terms of wtf::NoncopyableFunction instead of std::function.
​https://bugs.webkit.org/show_bug.cgi?id=158187

Reviewed by Chris Dumez.

No new tests (Refactor, no behavior change).

Also make postTask take an rvalue reference.

  • bindings/js/JSDOMGlobalObjectTask.cpp:

(WebCore::JSGlobalObjectTask::JSGlobalObjectTask):

  • dom/Document.cpp:

(WebCore::Document::postTask):

  • dom/Document.h:
  • dom/ScriptExecutionContext.h:

(WebCore::ScriptExecutionContext::Task::Task):

  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::postTask):

  • workers/WorkerGlobalScope.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201493 r201496  
     12016-05-29  Brady Eidson  <beidson@apple.com>
     2
     3        Make ScriptExecutionContext::Task work in terms of wtf::NoncopyableFunction instead of std::function.
     4        https://bugs.webkit.org/show_bug.cgi?id=158187
     5
     6        Reviewed by Chris Dumez.
     7
     8        No new tests (Refactor, no behavior change).
     9
     10        Also make postTask take an rvalue reference.
     11
     12        * bindings/js/JSDOMGlobalObjectTask.cpp:
     13        (WebCore::JSGlobalObjectTask::JSGlobalObjectTask):
     14       
     15        * dom/Document.cpp:
     16        (WebCore::Document::postTask):
     17        * dom/Document.h:
     18       
     19        * dom/ScriptExecutionContext.h:
     20        (WebCore::ScriptExecutionContext::Task::Task):
     21       
     22        * workers/WorkerGlobalScope.cpp:
     23        (WebCore::WorkerGlobalScope::postTask):
     24        * workers/WorkerGlobalScope.h:
     25
    1262016-05-28  Chris Dumez  <cdumez@apple.com>
    227
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObjectTask.cpp

    r201253 r201496  
    8181
    8282JSGlobalObjectTask::JSGlobalObjectTask(JSDOMGlobalObject* globalObject, Ref<Microtask>&& task)
    83     : ScriptExecutionContext::Task(nullptr)
     83    : ScriptExecutionContext::Task({ })
    8484{
    8585    RefPtr<JSGlobalObjectCallback> callback = JSGlobalObjectCallback::create(globalObject, WTFMove(task));
  • trunk/Source/WebCore/dom/Document.cpp

    r201482 r201496  
    53855385}
    53865386
    5387 void Document::postTask(Task task)
     5387void Document::postTask(Task&& task)
    53885388{
    53895389    callOnMainThread([documentReference = m_weakFactory.createWeakPtr(), task = WTFMove(task)]() mutable {
  • trunk/Source/WebCore/dom/Document.h

    r201471 r201496  
    976976    void parseDNSPrefetchControlHeader(const String&);
    977977
    978     void postTask(Task) final; // Executes the task on context's thread asynchronously.
     978    void postTask(Task&&) final; // Executes the task on context's thread asynchronously.
    979979
    980980#if ENABLE(REQUEST_ANIMATION_FRAME)
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r200503 r201496  
    3636#include <runtime/ConsoleTypes.h>
    3737#include <wtf/HashSet.h>
     38#include <wtf/NoncopyableFunction.h>
    3839
    3940namespace JSC {
    … …  
    133134        enum CleanupTaskTag { CleanupTask };
    134135
    135         template<typename T, typename = typename std::enable_if<!std::is_base_of<Task, T>::value && std::is_convertible<T, std::function<void (ScriptExecutionContext&)>>::value>::type>
     136        template<typename T, typename = typename std::enable_if<!std::is_base_of<Task, T>::value && std::is_convertible<T, NoncopyableFunction<void (ScriptExecutionContext&)>>::value>::type>
    136137        Task(T task)
    137138            : m_task(WTFMove(task))
    … …  
    140141        }
    141142
    142         Task(std::function<void()> task)
     143        Task(std::function<void ()> task)
    143144            : m_task([task](ScriptExecutionContext&) { task(); })
    144145            , m_isCleanupTask(false)
    … …  
    146147        }
    147148
    148         template<typename T, typename = typename std::enable_if<std::is_convertible<T, std::function<void (ScriptExecutionContext&)>>::value>::type>
     149        template<typename T, typename = typename std::enable_if<std::is_convertible<T, NoncopyableFunction<void (ScriptExecutionContext&)>>::value>::type>
    149150        Task(CleanupTaskTag, T task)
    150151            : m_task(WTFMove(task))
    … …  
    163164
    164165    protected:
    165         std::function<void (ScriptExecutionContext&)> m_task;
     166        NoncopyableFunction<void (ScriptExecutionContext&)> m_task;
    166167        bool m_isCleanupTask;
    167168    };
    168169
    169     virtual void postTask(Task) = 0; // Executes the task on context's thread asynchronously.
     170    virtual void postTask(Task&&) = 0; // Executes the task on context's thread asynchronously.
    170171
    171172    template<typename... Arguments>
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r201390 r201496  
    174174}
    175175
    176 void WorkerGlobalScope::postTask(Task task)
     176void WorkerGlobalScope::postTask(Task&& task)
    177177{
    178178    thread().runLoop().postTask(WTFMove(task));
  • trunk/Source/WebCore/workers/WorkerGlobalScope.h

    r201390 r201496  
    8989    using ScriptExecutionContext::hasPendingActivity;
    9090
    91     void postTask(Task) override; // Executes the task on context's thread asynchronously.
     91    void postTask(Task&&) final; // Executes the task on context's thread asynchronously.
    9292
    9393    // WorkerGlobalScope
Note: See TracChangeset for help on using the changeset viewer.