Title: [218002] trunk/Source/WebKit2
Revision
218002
Author
[email protected]
Date
2017-06-09 11:32:08 -0700 (Fri, 09 Jun 2017)

Log Message

Avoid some ref counting churn in WebResourceLoadStatisticsStore
https://bugs.webkit.org/show_bug.cgi?id=173168

Reviewed by Brent Fulgham.

Move the protectedThis around instead of ref'ing it every time we capture it
in a lambda. Also add a missing protectedThis in WebResourceLoadStatisticsStore::removeDataRecords()
which likely fixes crashes.

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
(WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (218001 => 218002)


--- trunk/Source/WebKit2/ChangeLog	2017-06-09 18:28:37 UTC (rev 218001)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-09 18:32:08 UTC (rev 218002)
@@ -1,3 +1,18 @@
+2017-06-09  Chris Dumez  <[email protected]>
+
+        Avoid some ref counting churn in WebResourceLoadStatisticsStore
+        https://bugs.webkit.org/show_bug.cgi?id=173168
+
+        Reviewed by Brent Fulgham.
+
+        Move the protectedThis around instead of ref'ing it every time we capture it
+        in a lambda. Also add a missing protectedThis in WebResourceLoadStatisticsStore::removeDataRecords()
+        which likely fixes crashes.
+
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
+        (WebKit::WebResourceLoadStatisticsStore::grandfatherExistingWebsiteData):
+
 2017-06-09  Sam Weinig  <[email protected]>
 
         Add SubresourceIntegrity as an experimental feature

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (218001 => 218002)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-06-09 18:28:37 UTC (rev 218001)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-06-09 18:32:08 UTC (rev 218002)
@@ -209,10 +209,10 @@
     return globalPageMap().get(pageID);
 }
 
-void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, std::function<void(Vector<String>)> completionHandler)
+void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, Function<void(Vector<String>)>&& completionHandler)
 {
     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
-        explicit CallbackAggregator(std::function<void(Vector<String>)> completionHandler)
+        explicit CallbackAggregator(Function<void(Vector<String>)>&& completionHandler)
             : completionHandler(WTFMove(completionHandler))
         {
         }
@@ -241,7 +241,7 @@
         }
         
         unsigned pendingCallbacks = 0;
-        std::function<void(Vector<String>)> completionHandler;
+        Function<void(Vector<String>)> completionHandler;
         Vector<String> domainsWithDeletedWebsiteData;
     };
     

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (218001 => 218002)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-06-09 18:28:37 UTC (rev 218001)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-06-09 18:32:08 UTC (rev 218002)
@@ -141,7 +141,7 @@
     void fetchWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType>, Function<void(WebsiteData)> completionHandler);
     void deleteWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType>, std::chrono::system_clock::time_point modifiedSince, Function<void()> completionHandler);
     void deleteWebsiteDataForOrigins(WebCore::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>&, Function<void()> completionHandler);
-    static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, std::function<void(Vector<String>)> completionHandler);
+    static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, Function<void(Vector<String>)>&& completionHandler);
     static void topPrivatelyControlledDomainsWithWebiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, Function<void(HashSet<String>&&)> completionHandler);
     static void notifyPageStatisticsAndDataRecordsProcessed();
 

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp (218001 => 218002)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-06-09 18:28:37 UTC (rev 218001)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-06-09 18:32:08 UTC (rev 218002)
@@ -119,11 +119,11 @@
 
     // Switch to the main thread to get the default website data store
     RunLoop::main().dispatch([prevalentResourceDomains = CrossThreadCopier<Vector<String>>::copy(prevalentResourceDomains), this, protectedThis = makeRef(*this)] () mutable {
-        WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypesToRemove, WTFMove(prevalentResourceDomains), notifyPages, [this](Vector<String> domainsWithDeletedWebsiteData) mutable {
+        WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypesToRemove, WTFMove(prevalentResourceDomains), notifyPages, [this, protectedThis = WTFMove(protectedThis)](Vector<String> domainsWithDeletedWebsiteData) mutable {
             // But always touch the ResourceLoadStatistics store on the worker queue.
-            m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), topDomains = CrossThreadCopier<Vector<String>>::copy(domainsWithDeletedWebsiteData)] () mutable {
-                this->coreStore().updateStatisticsForRemovedDataRecords(topDomains);
-                this->coreStore().dataRecordsWereRemoved();
+            m_statisticsQueue->dispatch([protectedThis = WTFMove(protectedThis), topDomains = CrossThreadCopier<Vector<String>>::copy(domainsWithDeletedWebsiteData)] () mutable {
+                protectedThis->coreStore().updateStatisticsForRemovedDataRecords(topDomains);
+                protectedThis->coreStore().dataRecordsWereRemoved();
             });
         });
     });
@@ -215,10 +215,10 @@
     
     // Switch to the main thread to get the default website data store
     RunLoop::main().dispatch([this, protectedThis = makeRef(*this)] () mutable {
-        WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData(dataTypesToRemove, notifyPages, [this, protectedThis = makeRef(*this)] (HashSet<String>&& topPrivatelyControlledDomainsWithWebsiteData) mutable {
+        WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData(dataTypesToRemove, notifyPages, [this, protectedThis = WTFMove(protectedThis)] (HashSet<String>&& topPrivatelyControlledDomainsWithWebsiteData) mutable {
             // But always touch the ResourceLoadStatistics store on the worker queue
-            m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), topDomains = CrossThreadCopier<HashSet<String>>::copy(topPrivatelyControlledDomainsWithWebsiteData)] () mutable {
-                this->coreStore().handleFreshStartWithEmptyOrNoStore(WTFMove(topDomains));
+            m_statisticsQueue->dispatch([protectedThis = WTFMove(protectedThis), topDomains = CrossThreadCopier<HashSet<String>>::copy(topPrivatelyControlledDomainsWithWebsiteData)] () mutable {
+                protectedThis->coreStore().handleFreshStartWithEmptyOrNoStore(WTFMove(topDomains));
             });
         });
     });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to