Remove MainThreadTask
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Oct 2014 09:34:56 +0000 (09:34 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Oct 2014 09:34:56 +0000 (09:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137563

Reviewed by Darin Adler.

Replace the remaining uses of MainThreadTask with C++11 lambdas.
Remove the MainThreadTask header from the build.

* WebCore.order:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* platform/MainThreadTask.h: Removed.
* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownloadManager::downloadThread):
(WebCore::CurlDownload::didReceiveHeader):
(WebCore::CurlDownload::didReceiveData):

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.order
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/MainThreadTask.h [deleted file]
Source/WebCore/platform/network/curl/CurlDownload.cpp

index 474e468..df315f4 100644 (file)
@@ -1,3 +1,23 @@
+2014-10-10  Zan Dobersek  <zdobersek@igalia.com>
+
+        Remove MainThreadTask
+        https://bugs.webkit.org/show_bug.cgi?id=137563
+
+        Reviewed by Darin Adler.
+
+        Replace the remaining uses of MainThreadTask with C++11 lambdas.
+        Remove the MainThreadTask header from the build.
+
+        * WebCore.order:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/MainThreadTask.h: Removed.
+        * platform/network/curl/CurlDownload.cpp:
+        (WebCore::CurlDownloadManager::downloadThread):
+        (WebCore::CurlDownload::didReceiveHeader):
+        (WebCore::CurlDownload::didReceiveData):
+
 2014-10-10  Andrzej Badowski  <a.badowski@samsung.com>
 
         [ATK] Changing the mapping of ARIA rowheader and columnheader into respective ATK roles.
index 8cf0e61..590449e 100644 (file)
@@ -19541,10 +19541,8 @@ __ZN7WebCore13ProgressEventD0Ev
 __ZThn24_N7WebCore10FileReader16derefEventTargetEv
 __ZN7WebCore18BlobResourceHandle12notifyFinishEv
 __ZN7WebCoreL21executeMainThreadTaskEPv
-__ZN7WebCore15MainThreadTask1IPNS_15AsyncFileStreamES2_E11performTaskEv
 __ZN7WebCoreL8didStartEPNS_15AsyncFileStreamE
 __ZN7WebCore16FileStreamClient8didStartEv
-__ZN7WebCore15MainThreadTask1IPNS_15AsyncFileStreamES2_ED0Ev
 __ZN7WebCoreL14doNotifyFinishEPv
 __ZThn8_N7WebCore18BlobResourceHandleD0Ev
 __ZN7WebCore18BlobResourceHandleD2Ev
index a51fb57..1cad58f 100644 (file)
     <ClInclude Include="..\platform\LocalizedStrings.h" />
     <ClInclude Include="..\platform\Logging.h" />
     <ClInclude Include="..\platform\MemoryPressureHandler.h" />
-    <ClInclude Include="..\platform\MainThreadTask.h" />
     <ClInclude Include="..\platform\MIMETypeRegistry.h" />
     <ClInclude Include="..\platform\NotImplemented.h" />
     <ClInclude Include="..\platform\Pasteboard.h" />
index ff17443..56b8141 100644 (file)
     <ClInclude Include="..\platform\MemoryPressureHandler.h">
       <Filter>platform</Filter>
     </ClInclude>
-    <ClInclude Include="..\platform\MainThreadTask.h">
-      <Filter>platform</Filter>
-    </ClInclude>
     <ClInclude Include="..\platform\MIMETypeRegistry.h">
       <Filter>platform</Filter>
     </ClInclude>
index b7ec2b4..5dc4dec 100644 (file)
                E182568F0EF2B02D00933242 /* JSWorkerGlobalScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E182568D0EF2B02D00933242 /* JSWorkerGlobalScope.cpp */; };
                E18256900EF2B02D00933242 /* JSWorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E182568E0EF2B02D00933242 /* JSWorkerGlobalScope.h */; };
                E18258AC0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */; };
-               E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */ = {isa = PBXBuildFile; fileRef = E187056216E54A0D00585E97 /* MainThreadTask.h */; };
                E18772F1126E2629003DD586 /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E18772F0126E2629003DD586 /* Language.cpp */; };
                E18DF33518AAF12C00773E59 /* SerializedCryptoKeyWrap.h in Headers */ = {isa = PBXBuildFile; fileRef = E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E18DF33818AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E18DF33618AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm */; };
                E182568D0EF2B02D00933242 /* JSWorkerGlobalScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerGlobalScope.cpp; sourceTree = "<group>"; };
                E182568E0EF2B02D00933242 /* JSWorkerGlobalScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerGlobalScope.h; sourceTree = "<group>"; };
                E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerGlobalScopeCustom.cpp; sourceTree = "<group>"; };
-               E187056216E54A0D00585E97 /* MainThreadTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainThreadTask.h; sourceTree = "<group>"; };
                E18772F0126E2629003DD586 /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Language.cpp; sourceTree = "<group>"; };
                E18DF33418AAF12C00773E59 /* SerializedCryptoKeyWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedCryptoKeyWrap.h; sourceTree = "<group>"; };
                E18DF33618AAF14D00773E59 /* SerializedCryptoKeyWrapMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SerializedCryptoKeyWrapMac.mm; path = mac/SerializedCryptoKeyWrapMac.mm; sourceTree = "<group>"; };
                                935207BD09BD410A00F2038D /* LocalizedStrings.h */,
                                A8239DFE09B3CF8A00B60641 /* Logging.cpp */,
                                A8239DFF09B3CF8A00B60641 /* Logging.h */,
-                               E187056216E54A0D00585E97 /* MainThreadTask.h */,
                                CDF2B003181F059C00F2B424 /* MediaDescription.h */,
                                CD641EC7181ED60100EE4C41 /* MediaSample.h */,
                                657EDA061385CB97004E0645 /* MemoryPressureHandler.cpp */,
                                A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
                                9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */,
                                932AD70617EFA2C40038F8FF /* MainFrame.h in Headers */,
-                               E187056316E54A0D00585E97 /* MainThreadTask.h in Headers */,
                                1A8F6BC60DB55CDC001DB794 /* ManifestParser.h in Headers */,
                                7C73FB12191EF6F4007DE061 /* JSUserMessageHandler.h in Headers */,
                                93309DF8099E64920056E581 /* markup.h in Headers */,
diff --git a/Source/WebCore/platform/MainThreadTask.h b/Source/WebCore/platform/MainThreadTask.h
deleted file mode 100644 (file)
index 8d14e02..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2009-2010 Google Inc. All rights reserved.
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MainThreadTask_h
-#define MainThreadTask_h
-
-#include "CrossThreadCopier.h"
-#include <functional>
-
-namespace WebCore {
-
-class MainThreadTask : public std::function<void ()> {
-public:
-    template<typename Method, typename... Parameters>
-    MainThreadTask(Method method, const Parameters&... parameters)
-        : std::function<void ()>(std::bind(method, typename CrossThreadCopier<Parameters>::Type(CrossThreadCopier<Parameters>::copy(parameters))...))
-    {
-    }
-};
-
-} // namespace WebCore
-
-
-#endif // MainThreadTask_h
index b06b52c..b5c2c7e 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "HTTPHeaderNames.h"
 #include "HTTPParsers.h"
-#include "MainThreadTask.h"
 #include "ResourceHandleManager.h"
 #include "ResourceRequest.h"
 #include <wtf/MainThread.h>
@@ -214,9 +213,15 @@ void CurlDownloadManager::downloadThread(void* data)
 
         if (msg->msg == CURLMSG_DONE) {
             if (msg->data.result == CURLE_OK)
-                callOnMainThread(MainThreadTask(CurlDownload::downloadFinishedCallback, download));
+                callOnMainThread([download] {
+                    if (download)
+                        download->didFinish();
+                });
             else
-                callOnMainThread(MainThreadTask(CurlDownload::downloadFailedCallback, download));
+                callOnMainThread([download] {
+                    if (download)
+                        download->didFail();
+                });
 
             downloadManager->removeFromCurl(msg->easy_handle);
         }
@@ -400,7 +405,9 @@ void CurlDownload::didReceiveHeader(const String& header)
             m_response.setMimeType(extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)));
             m_response.setTextEncodingName(extractCharsetFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)));
 
-            callOnMainThread(MainThreadTask(receivedResponseCallback, this));
+            callOnMainThread([this] {
+                didReceiveResponse();
+            });
         }
     } else {
         int splitPos = header.find(":");
@@ -413,7 +420,9 @@ void CurlDownload::didReceiveData(void* data, int size)
 {
     MutexLocker locker(m_mutex);
 
-    callOnMainThread(MainThreadTask(receivedDataCallback, this, size));
+    callOnMainThread([this, size] {
+        didReceiveDataOfLength(size);
+    });
 
     writeDataToFile(static_cast<const char*>(data), size);
 }