Title: [195785] trunk/Source/WebCore
Revision
195785
Author
dba...@webkit.org
Date
2016-01-28 15:04:03 -0800 (Thu, 28 Jan 2016)

Log Message

Cleanup: Make DedicatedWorkerThread::create() an inline template method
https://bugs.webkit.org/show_bug.cgi?id=153612

Reviewed by Andy Estes.

Make use of variadic template arguments and std::forward() to forward the arguments passed
to DedicatedWorkerThread::create() to DedicatedWorkerThread::DedicatedWorkerThread(). This
removes the need to duplicate code whenever we modify the parameter types or number of
parameters taken by DedicatedWorkerThread::DedicatedWorkerThread().

* workers/DedicatedWorkerThread.cpp:
(WebCore::DedicatedWorkerThread::create): Deleted.
* workers/DedicatedWorkerThread.h: Reorganized listing of member functions such that we
group the creation/constructor and destructor functions.
(WebCore::DedicatedWorkerThread::create): Modified to be an inline template with variadic
parameters that std::forward()s its arguments to DedicatedWorkerThread::DedicatedWorkerThread().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (195784 => 195785)


--- trunk/Source/WebCore/ChangeLog	2016-01-28 22:52:05 UTC (rev 195784)
+++ trunk/Source/WebCore/ChangeLog	2016-01-28 23:04:03 UTC (rev 195785)
@@ -1,3 +1,22 @@
+2016-01-28  Daniel Bates  <daba...@apple.com>
+
+        Cleanup: Make DedicatedWorkerThread::create() an inline template method
+        https://bugs.webkit.org/show_bug.cgi?id=153612
+
+        Reviewed by Andy Estes.
+
+        Make use of variadic template arguments and std::forward() to forward the arguments passed
+        to DedicatedWorkerThread::create() to DedicatedWorkerThread::DedicatedWorkerThread(). This
+        removes the need to duplicate code whenever we modify the parameter types or number of
+        parameters taken by DedicatedWorkerThread::DedicatedWorkerThread().
+
+        * workers/DedicatedWorkerThread.cpp:
+        (WebCore::DedicatedWorkerThread::create): Deleted.
+        * workers/DedicatedWorkerThread.h: Reorganized listing of member functions such that we
+        group the creation/constructor and destructor functions.
+        (WebCore::DedicatedWorkerThread::create): Modified to be an inline template with variadic
+        parameters that std::forward()s its arguments to DedicatedWorkerThread::DedicatedWorkerThread().
+
 2016-01-28  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: SQLite backend doesn't handle mutation during cursor iteration.

Modified: trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp (195784 => 195785)


--- trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp	2016-01-28 22:52:05 UTC (rev 195784)
+++ trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp	2016-01-28 23:04:03 UTC (rev 195785)
@@ -38,11 +38,6 @@
 
 namespace WebCore {
 
-Ref<DedicatedWorkerThread> DedicatedWorkerThread::create(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
-{
-    return adoptRef(*new DedicatedWorkerThread(scriptURL, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin));
-}
-
 DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
     : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin)
     , m_workerObjectProxy(workerObjectProxy)

Modified: trunk/Source/WebCore/workers/DedicatedWorkerThread.h (195784 => 195785)


--- trunk/Source/WebCore/workers/DedicatedWorkerThread.h	2016-01-28 22:52:05 UTC (rev 195784)
+++ trunk/Source/WebCore/workers/DedicatedWorkerThread.h	2016-01-28 23:04:03 UTC (rev 195785)
@@ -39,10 +39,14 @@
 
     class DedicatedWorkerThread : public WorkerThread {
     public:
-        static Ref<DedicatedWorkerThread> create(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin);
-        WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
+        template<class... Args> static Ref<DedicatedWorkerThread> create(Args&&... args)
+        {
+            return adoptRef(*new DedicatedWorkerThread(std::forward<Args>(args)...));
+        }
         virtual ~DedicatedWorkerThread();
 
+        WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
+
     protected:
         virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) override;
         virtual void runEventLoop() override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to