Title: [218860] trunk/Source/WebKit2
Revision
218860
Author
[email protected]
Date
2017-06-27 18:47:15 -0700 (Tue, 27 Jun 2017)

Log Message

Move WebsiteDataRecord processing off-thread in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
https://bugs.webkit.org/show_bug.cgi?id=173882
<rdar://problem/32984366>

Reviewed by Darin Adler.

Move WebsiteDataRecord processing off-thread in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
as we have data showing it is slow and hangs the UIProcess' main thread.

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218859 => 218860)


--- trunk/Source/WebKit2/ChangeLog	2017-06-28 01:09:03 UTC (rev 218859)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-28 01:47:15 UTC (rev 218860)
@@ -1,3 +1,17 @@
+2017-06-27  Chris Dumez  <[email protected]>
+
+        Move WebsiteDataRecord processing off-thread in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
+        https://bugs.webkit.org/show_bug.cgi?id=173882
+        <rdar://problem/32984366>
+
+        Reviewed by Darin Adler.
+
+        Move WebsiteDataRecord processing off-thread in WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains()
+        as we have data showing it is slow and hangs the UIProcess' main thread.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):
+
 2017-06-27  Brent Fulgham  <[email protected]>
 
         [WK2][macOS] Expand sandbox to allow access to the CoreMedia volume control endpoint

Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (218859 => 218860)


--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-06-28 01:09:03 UTC (rev 218859)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp	2017-06-28 01:47:15 UTC (rev 218860)
@@ -46,6 +46,7 @@
 #include <WebCore/ResourceLoadObserver.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/SecurityOriginData.h>
+#include <wtf/CrossThreadCopier.h>
 #include <wtf/RunLoop.h>
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
@@ -509,19 +510,23 @@
 
 void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler)
 {
-    fetchData(dataTypes, fetchOptions, [topPrivatelyControlledDomains, completionHandler = WTFMove(completionHandler)](auto&& existingDataRecords) {
-        Vector<WebsiteDataRecord> matchingDataRecords;
-        HashSet<String> domainsWithMatchingDataRecords;
-        for (auto&& dataRecord : existingDataRecords) {
-            for (auto& topPrivatelyControlledDomain : topPrivatelyControlledDomains) {
-                if (dataRecord.matchesTopPrivatelyControlledDomain(topPrivatelyControlledDomain)) {
-                    matchingDataRecords.append(WTFMove(dataRecord));
-                    domainsWithMatchingDataRecords.add(topPrivatelyControlledDomain);
-                    break;
+    fetchData(dataTypes, fetchOptions, [queue = m_queue.copyRef(), topPrivatelyControlledDomains = CrossThreadCopier<Vector<String>>::copy(topPrivatelyControlledDomains), completionHandler = WTFMove(completionHandler)] (auto&& existingDataRecords) mutable {
+        queue->dispatch([queue = WTFMove(queue), topPrivatelyControlledDomains = WTFMove(topPrivatelyControlledDomains), existingDataRecords = WTFMove(existingDataRecords), completionHandler = WTFMove(completionHandler)] () mutable {
+            Vector<WebsiteDataRecord> matchingDataRecords;
+            HashSet<String> domainsWithMatchingDataRecords;
+            for (auto&& dataRecord : existingDataRecords) {
+                for (auto& topPrivatelyControlledDomain : topPrivatelyControlledDomains) {
+                    if (dataRecord.matchesTopPrivatelyControlledDomain(topPrivatelyControlledDomain)) {
+                        matchingDataRecords.append(WTFMove(dataRecord));
+                        domainsWithMatchingDataRecords.add(topPrivatelyControlledDomain.isolatedCopy());
+                        break;
+                    }
                 }
             }
-        }
-        completionHandler(WTFMove(matchingDataRecords), WTFMove(domainsWithMatchingDataRecords));
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), matchingDataRecords = WTFMove(matchingDataRecords), domainsWithMatchingDataRecords = WTFMove(domainsWithMatchingDataRecords)] () mutable {
+                completionHandler(WTFMove(matchingDataRecords), WTFMove(domainsWithMatchingDataRecords));
+            });
+        });
     });
 }
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to