Cleanup: Make DedicatedWorkerThread::create() an inline template method
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 23:04:03 +0000 (23:04 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jan 2016 23:04:03 +0000 (23:04 +0000)
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().

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

Source/WebCore/ChangeLog
Source/WebCore/workers/DedicatedWorkerThread.cpp
Source/WebCore/workers/DedicatedWorkerThread.h

index 3c2cff4..7cd6dbf 100644 (file)
@@ -1,3 +1,22 @@
+2016-01-28  Daniel Bates  <dabates@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  <beidson@apple.com>
 
         Modern IDB: SQLite backend doesn't handle mutation during cursor iteration.
index bd41330..19005cb 100644 (file)
 
 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)
index b566e3b..22f8d17 100644 (file)
@@ -39,10 +39,14 @@ namespace WebCore {
 
     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;