ScriptExecutionContext::Task, FileThread::Task parameters should be values
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jun 2014 05:54:44 +0000 (05:54 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jun 2014 05:54:44 +0000 (05:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134035

Reviewed by Anders Carlsson.

r170106 and similar previous changesets enforced ScriptExecutionContext::Task and
FileThread::Task parameters as rvalue references. There's technically nothing wrong
with that, but since both classes are move-only it is also not strictly required.
Accepting these parameters as values is more common in C++ value semantics as well.

* dom/Document.cpp:
(WebCore::Document::postTask):
* dom/Document.h:
* dom/ScriptExecutionContext.h:
* fileapi/FileThread.cpp:
(WebCore::FileThread::postTask):
* fileapi/FileThread.h:
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerProxy::postTaskToLoader):
(WebCore::SharedWorkerProxy::postTaskForModeToWorkerGlobalScope):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::postTask):
* workers/WorkerGlobalScope.h:
* workers/WorkerLoaderProxy.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postTaskToLoader):
(WebCore::WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope):
* workers/WorkerMessagingProxy.h:
* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::postTask):
(WebCore::WorkerRunLoop::postTaskAndTerminate):
(WebCore::WorkerRunLoop::postTaskForMode):
(WebCore::WorkerRunLoop::Task::create):
(WebCore::WorkerRunLoop::Task::Task):
* workers/WorkerRunLoop.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170143 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/fileapi/FileThread.cpp
Source/WebCore/fileapi/FileThread.h
Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerGlobalScope.h
Source/WebCore/workers/WorkerLoaderProxy.h
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/workers/WorkerMessagingProxy.h
Source/WebCore/workers/WorkerRunLoop.cpp
Source/WebCore/workers/WorkerRunLoop.h

index 3637d57f968d19226f4d1a9426ab353ea0780fa0..b9ada941aabf214b2b3bb1aecf95f21145acb7b4 100644 (file)
@@ -1,3 +1,41 @@
+2014-06-18  Zan Dobersek  <zdobersek@igalia.com>
+
+        ScriptExecutionContext::Task, FileThread::Task parameters should be values
+        https://bugs.webkit.org/show_bug.cgi?id=134035
+
+        Reviewed by Anders Carlsson.
+
+        r170106 and similar previous changesets enforced ScriptExecutionContext::Task and
+        FileThread::Task parameters as rvalue references. There's technically nothing wrong
+        with that, but since both classes are move-only it is also not strictly required.
+        Accepting these parameters as values is more common in C++ value semantics as well.
+
+        * dom/Document.cpp:
+        (WebCore::Document::postTask):
+        * dom/Document.h:
+        * dom/ScriptExecutionContext.h:
+        * fileapi/FileThread.cpp:
+        (WebCore::FileThread::postTask):
+        * fileapi/FileThread.h:
+        * workers/DefaultSharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerProxy::postTaskToLoader):
+        (WebCore::SharedWorkerProxy::postTaskForModeToWorkerGlobalScope):
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::postTask):
+        * workers/WorkerGlobalScope.h:
+        * workers/WorkerLoaderProxy.h:
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::postTaskToLoader):
+        (WebCore::WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope):
+        * workers/WorkerMessagingProxy.h:
+        * workers/WorkerRunLoop.cpp:
+        (WebCore::WorkerRunLoop::postTask):
+        (WebCore::WorkerRunLoop::postTaskAndTerminate):
+        (WebCore::WorkerRunLoop::postTaskForMode):
+        (WebCore::WorkerRunLoop::Task::create):
+        (WebCore::WorkerRunLoop::Task::Task):
+        * workers/WorkerRunLoop.h:
+
 2014-06-18  James Craig  <jcraig@apple.com>
 
         Web Inspector: AXI: expose aria-relevant
index 5abeeac0ca2dcc66cf5488704e93d2229f0f7bbb..153266c13ede41100644577a420136356c8dfd3c 100644 (file)
@@ -4902,7 +4902,7 @@ SecurityOrigin* Document::topOrigin() const
     return topDocument().securityOrigin();
 }
 
-void Document::postTask(Task&& task)
+void Document::postTask(Task task)
 {
     Task* taskPtr = std::make_unique<Task>(std::move(task)).release();
     WeakPtr<Document> documentReference(m_weakFactory.createWeakPtr());
index c7958c96ab8a8d50e5c3b3c026b55bbc3b9481d4..781b93587235929f23be2992809d92a1a53ada2d 100644 (file)
@@ -1008,7 +1008,7 @@ public:
     bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
     void parseDNSPrefetchControlHeader(const String&);
 
-    virtual void postTask(Task&&) override; // Executes the task on context's thread asynchronously.
+    virtual void postTask(Task) override; // Executes the task on context's thread asynchronously.
 
     void suspendScriptedAnimationControllerCallbacks();
     void resumeScriptedAnimationControllerCallbacks();
index 106eff9927bc059206084d74962463abd689559d..cd8bc37d1d447cfd73bb125b3290bdd2f477e365 100644 (file)
@@ -145,7 +145,7 @@ public:
         bool m_isCleanupTask;
     };
 
-    virtual void postTask(Task&&) = 0; // Executes the task on context's thread asynchronously.
+    virtual void postTask(Task) = 0; // Executes the task on context's thread asynchronously.
 
     // Gets the next id in a circular sequence from 1 to 2^31-1.
     int circularSequentialID();
index e80ae9f935dcf7ff889db4802646092b4916a568..efc07df73f53408871f6d8a9a8288023c8854613 100644 (file)
@@ -62,7 +62,7 @@ void FileThread::stop()
     m_queue.kill();
 }
 
-void FileThread::postTask(Task&& task)
+void FileThread::postTask(Task task)
 {
     m_queue.append(std::make_unique<FileThread::Task>(std::move(task)));
 }
index a44b046663284bb931ddb2bf7cb31a448b7e96cd..63d11593e82351c925e32db07db39e0946f72e07 100644 (file)
@@ -79,7 +79,7 @@ public:
         void* m_instance;
     };
 
-    void postTask(Task&&);
+    void postTask(Task);
 
     void unscheduleTasks(const void* instance);
 
index 2e95490dfde3f1e651082920ba45d5f82da18488..1d098d847df99dc7aaa16181eb294c2bb223eb41 100644 (file)
@@ -80,8 +80,8 @@ public:
     bool matches(const String& name, PassRefPtr<SecurityOrigin> origin, const URL& urlToMatch) const;
 
     // WorkerLoaderProxy
-    virtual void postTaskToLoader(ScriptExecutionContext::Task&&);
-    virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String&);
+    virtual void postTaskToLoader(ScriptExecutionContext::Task);
+    virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task, const String&);
 
     // WorkerReportingProxy
     virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL);
@@ -140,7 +140,7 @@ bool SharedWorkerProxy::matches(const String& name, PassRefPtr<SecurityOrigin> o
     return name == m_name;
 }
 
-void SharedWorkerProxy::postTaskToLoader(ScriptExecutionContext::Task&& task)
+void SharedWorkerProxy::postTaskToLoader(ScriptExecutionContext::Task task)
 {
     MutexLocker lock(m_workerDocumentsLock);
 
@@ -156,7 +156,7 @@ void SharedWorkerProxy::postTaskToLoader(ScriptExecutionContext::Task&& task)
     document->postTask(std::move(task));
 }
 
-bool SharedWorkerProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&& task, const String& mode)
+bool SharedWorkerProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task task, const String& mode)
 {
     if (isClosing())
         return false;
index 48d9bd0ad252ef5222e70f34f9dff93857e7539b..1c610ca5166811271f97a779fdc3d9dfd37af095 100644 (file)
@@ -147,7 +147,7 @@ WorkerNavigator* WorkerGlobalScope::navigator() const
     return m_navigator.get();
 }
 
-void WorkerGlobalScope::postTask(Task&& task)
+void WorkerGlobalScope::postTask(Task task)
 {
     thread().runLoop().postTask(std::move(task));
 }
index 1fe08e954cd44e9580ee8f83c28d97963d66e28e..9bd899e3f82680498041c1ff4901901c1877109f 100644 (file)
@@ -78,7 +78,7 @@ namespace WebCore {
 
         using ScriptExecutionContext::hasPendingActivity;
 
-        virtual void postTask(Task&&) override; // Executes the task on context's thread asynchronously.
+        virtual void postTask(Task) override; // Executes the task on context's thread asynchronously.
 
         // WorkerGlobalScope
         WorkerGlobalScope* self() { return this; }
index 3534e9f641a5d3183f6fff7458fb447f3b937204..6ed35876fd569c98a66c8ee05243aac95809686c 100644 (file)
@@ -46,12 +46,12 @@ namespace WebCore {
         virtual ~WorkerLoaderProxy() { }
 
         // Posts a task to the thread which runs the loading code (normally, the main thread).
-        virtual void postTaskToLoader(ScriptExecutionContext::Task&&) = 0;
+        virtual void postTaskToLoader(ScriptExecutionContext::Task) = 0;
 
         // Posts callbacks from loading code to the WorkerGlobalScope. The 'mode' is used to differentiate
         // specific synchronous loading requests so they can be 'nested', per spec.
         // Returns true if the task was posted successfully.
-        virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) = 0;
+        virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task, const String& mode) = 0;
     };
 
 } // namespace WebCore
index ffa4e157402f579d9d2d3900e2ae9f97769d8353..5501f55da523ee0c523346e66c40ed2877b6ebe2 100644 (file)
@@ -127,14 +127,14 @@ void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedS
         m_queuedEarlyTasks.append(std::make_unique<ScriptExecutionContext::Task>(std::move(task)));
 }
 
-void WorkerMessagingProxy::postTaskToLoader(ScriptExecutionContext::Task&& task)
+void WorkerMessagingProxy::postTaskToLoader(ScriptExecutionContext::Task task)
 {
     // FIXME: In case of nested workers, this should go directly to the root Document context.
     ASSERT(m_scriptExecutionContext->isDocument());
     m_scriptExecutionContext->postTask(std::move(task));
 }
 
-bool WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&& task, const String& mode)
+bool WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task task, const String& mode)
 {
     if (m_askedToTerminate)
         return false;
index 4931342cdd3dbf071d797836457e8aa61a79c4d3..3120d9b49e94e069e372824e7dfa1e0497a2b34c 100644 (file)
@@ -79,8 +79,8 @@ namespace WebCore {
         // Implementation of WorkerLoaderProxy.
         // These methods are called on different threads to schedule loading
         // requests and to send callbacks back to WorkerGlobalScope.
-        virtual void postTaskToLoader(ScriptExecutionContext::Task&&) override;
-        virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) override;
+        virtual void postTaskToLoader(ScriptExecutionContext::Task) override;
+        virtual bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task, const String& mode) override;
 
         void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>);
 
index 05941be079546faa21877cbb6daf6099f3e77f1e..d7b7a7e928fc5e001353773c74960ee0dd79008a 100644 (file)
@@ -192,22 +192,22 @@ void WorkerRunLoop::terminate()
     m_messageQueue.kill();
 }
 
-void WorkerRunLoop::postTask(ScriptExecutionContext::Task&& task)
+void WorkerRunLoop::postTask(ScriptExecutionContext::Task task)
 {
     postTaskForMode(std::move(task), defaultMode());
 }
 
-void WorkerRunLoop::postTaskAndTerminate(ScriptExecutionContext::Task&& task)
+void WorkerRunLoop::postTaskAndTerminate(ScriptExecutionContext::Task task)
 {
     m_messageQueue.appendAndKill(Task::create(std::move(task), defaultMode().isolatedCopy()));
 }
 
-void WorkerRunLoop::postTaskForMode(ScriptExecutionContext::Task&& task, const String& mode)
+void WorkerRunLoop::postTaskForMode(ScriptExecutionContext::Task task, const String& mode)
 {
     m_messageQueue.append(Task::create(std::move(task), mode.isolatedCopy()));
 }
 
-std::unique_ptr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(ScriptExecutionContext::Task&& task, const String& mode)
+std::unique_ptr<WorkerRunLoop::Task> WorkerRunLoop::Task::create(ScriptExecutionContext::Task task, const String& mode)
 {
     return std::unique_ptr<Task>(new Task(std::move(task), mode));
 }
@@ -218,7 +218,7 @@ void WorkerRunLoop::Task::performTask(const WorkerRunLoop& runLoop, WorkerGlobal
         m_task.performTask(*context);
 }
 
-WorkerRunLoop::Task::Task(ScriptExecutionContext::Task&& task, const String& mode)
+WorkerRunLoop::Task::Task(ScriptExecutionContext::Task task, const String& mode)
     : m_task(std::move(task))
     , m_mode(mode.isolatedCopy())
 {
index 6de967ca41d6902ff455415e2938279e7f4a4ec9..a767917734e87f7c9dacc428ec5fd92ae838b14d 100644 (file)
@@ -57,9 +57,9 @@ namespace WebCore {
         void terminate();
         bool terminated() const { return m_messageQueue.killed(); }
 
-        void postTask(ScriptExecutionContext::Task&&);
-        void postTaskAndTerminate(ScriptExecutionContext::Task&&);
-        void postTaskForMode(ScriptExecutionContext::Task&&, const String& mode);
+        void postTask(ScriptExecutionContext::Task);
+        void postTaskAndTerminate(ScriptExecutionContext::Task);
+        void postTaskForMode(ScriptExecutionContext::Task, const String& mode);
 
         unsigned long createUniqueId() { return ++m_uniqueId; }
 
@@ -68,13 +68,13 @@ namespace WebCore {
         class Task {
             WTF_MAKE_NONCOPYABLE(Task); WTF_MAKE_FAST_ALLOCATED;
         public:
-            static std::unique_ptr<Task> create(ScriptExecutionContext::Task&&, const String& mode);
+            static std::unique_ptr<Task> create(ScriptExecutionContext::Task, const String& mode);
             ~Task() { }
             const String& mode() const { return m_mode; }
             void performTask(const WorkerRunLoop&, WorkerGlobalScope*);
 
         private:
-            Task(ScriptExecutionContext::Task&&, const String& mode);
+            Task(ScriptExecutionContext::Task, const String& mode);
         
             ScriptExecutionContext::Task m_task;
             String m_mode;