<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[218118] tags/Safari-604.1.25/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/218118">218118</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2017-06-12 11:49:13 -0700 (Mon, 12 Jun 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/218011">r218011</a>. rdar://problem/32679311</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#tagsSafari604125SourceWebKit2ChangeLog">tags/Safari-604.1.25/Source/WebKit2/ChangeLog</a></li>
<li><a href="#tagsSafari604125SourceWebKit2SharedWebsiteDataWebsiteDataTypeh">tags/Safari-604.1.25/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h</a></li>
<li><a href="#tagsSafari604125SourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordInternalh">tags/Safari-604.1.25/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h</a></li>
<li><a href="#tagsSafari604125SourceWebKit2UIProcessWebProcessProxycpp">tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#tagsSafari604125SourceWebKit2UIProcessWebProcessProxyh">tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.h</a></li>
<li><a href="#tagsSafari604125SourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp">tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp</a></li>
<li><a href="#tagsSafari604125SourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh">tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="tagsSafari604125SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/ChangeLog (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/ChangeLog    2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/ChangeLog       2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2017-06-12  Matthew Hanson  <matthew_hanson@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r218011. rdar://problem/32679311
+
+    2017-06-09  Brent Fulgham  <bfulgham@apple.com>
+
+            Use Function rather than std::function for thread safety in WebsiteDataStore
+            https://bugs.webkit.org/show_bug.cgi?id=173172
+
+            Reviewed by Chris Dumez.
+            <rdar://problem/32679311>
+
+            Remove a few more instances of std::function in the WebsiteDataStore, and WTFMove completion handler to
+            avoid unnecessary copies.
+
+            * Shared/WebsiteData/WebsiteDataType.h: Remove redundant WebsiteDataType from name.
+            * UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
+            (WebKit::toWebsiteDataType): Update for revised name.
+            (WebKit::toWKWebsiteDataTypes): Ditto.
+            * UIProcess/WebProcessProxy.cpp:
+            (WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): ASSERT that
+            this function, as well as its completion handler, are getting called from the main thread.
+            (WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData): Ditto.
+            (WebKit::WebProcessProxy::fetchWebsiteData): Move the completionHandler.
+            (WebKit::WebProcessProxy::deleteWebsiteData): Ditto.
+            (WebKit::WebProcessProxy::deleteWebsiteDataForOrigins): Ditto.
+            * UIProcess/WebProcessProxy.h:
+            * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+            (WebKit::WebsiteDataStore::fetchData): Switch to Function, and move completion handler.
+            (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains): Ditto.
+            (WebKit::WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData): Ditto.
+            (WebKit::WebsiteDataStore::removeData): Ditto.
+            (WebKit::WebsiteDataStore::removeDataForTopPrivatelyControlledDomains): Ditto.
+            * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+2017-06-12  Matthew Hanson  <matthew_hanson@apple.com>
+
</ins><span class="cx">         Cherry-pick r218006. rdar://problem/32598919
</span><span class="cx"> 
</span><span class="cx">     2017-06-09  Chris Dumez  <cdumez@apple.com>
</span></span></pre></div>
<a id="tagsSafari604125SourceWebKit2SharedWebsiteDataWebsiteDataTypeh"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h 2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/Shared/WebsiteData/WebsiteDataType.h    2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     MediaDeviceIdentifier = 1 << 12,
</span><span class="cx"> #endif
</span><del>-    WebsiteDataTypeResourceLoadStatistics = 1 << 13,
</del><ins>+    ResourceLoadStatistics = 1 << 13,
</ins><span class="cx">     Credentials = 1 << 14,
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="tagsSafari604125SourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordInternalh"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h    2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h       2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">         return WebsiteDataType::PlugInData;
</span><span class="cx"> #endif
</span><span class="cx">     if ([websiteDataType isEqualToString:_WKWebsiteDataTypeResourceLoadStatistics])
</span><del>-        return WebsiteDataType::WebsiteDataTypeResourceLoadStatistics;
</del><ins>+        return WebsiteDataType::ResourceLoadStatistics;
</ins><span class="cx">     if ([websiteDataType isEqualToString:_WKWebsiteDataTypeCredentials])
</span><span class="cx">         return WebsiteDataType::Credentials;
</span><span class="cx">     return std::nullopt;
</span><span class="lines">@@ -117,7 +117,7 @@
</span><span class="cx">     if (websiteDataTypes.contains(WebsiteDataType::PlugInData))
</span><span class="cx">         [wkWebsiteDataTypes addObject:_WKWebsiteDataTypePlugInData];
</span><span class="cx"> #endif
</span><del>-    if (websiteDataTypes.contains(WebsiteDataType::WebsiteDataTypeResourceLoadStatistics))
</del><ins>+    if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics))
</ins><span class="cx">         [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeResourceLoadStatistics];
</span><span class="cx">     if (websiteDataTypes.contains(WebsiteDataType::Credentials))
</span><span class="cx">         [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeCredentials];
</span></span></pre></div>
<a id="tagsSafari604125SourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.cpp (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.cpp   2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -211,6 +211,9 @@
</span><span class="cx"> 
</span><span class="cx"> void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, Function<void(Vector<String>)>&& completionHandler)
</span><span class="cx"> {
</span><ins>+    // We expect this to be called on the main thread so we get the default website data store.
+    ASSERT(isMainThread());
+    
</ins><span class="cx">     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
</span><span class="cx">         explicit CallbackAggregator(Function<void(Vector<String>)>&& completionHandler)
</span><span class="cx">             : completionHandler(WTFMove(completionHandler))
</span><span class="lines">@@ -254,19 +257,24 @@
</span><span class="cx">             continue;
</span><span class="cx">         visitedSessionIDs.add(dataStore.sessionID());
</span><span class="cx">         callbackAggregator->addPendingCallback();
</span><del>-        dataStore.removeDataForTopPrivatelyControlledDomains(dataTypes, { }, WTFMove(topPrivatelyControlledDomains), [callbackAggregator, shouldNotifyPage, page](auto domainsWithDeletedWebsiteData) {
</del><ins>+        dataStore.removeDataForTopPrivatelyControlledDomains(dataTypes, { }, WTFMove(topPrivatelyControlledDomains), [callbackAggregator, shouldNotifyPage, page](Vector<String>&& domainsWithDeletedWebsiteData) {
+            // When completing the task, we should be getting called on the main thread.
+            ASSERT(isMainThread());
+            
</ins><span class="cx">             if (shouldNotifyPage)
</span><span class="cx">                 page.value->postMessageToInjectedBundle("WebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished", nullptr);
</span><del>-            WTF::RunLoop::main().dispatch([callbackAggregator, domainsWithDeletedWebsiteData] {
-                callbackAggregator->addDomainsWithDeletedWebsiteData(domainsWithDeletedWebsiteData);
-                callbackAggregator->removePendingCallback();
-            });
</del><ins>+            
+            callbackAggregator->addDomainsWithDeletedWebsiteData(WTFMove(domainsWithDeletedWebsiteData));
+            callbackAggregator->removePendingCallback();
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, Function<void(HashSet<String>&&)> completionHandler)
</del><ins>+void WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, Function<void(HashSet<String>&&)>&& completionHandler)
</ins><span class="cx"> {
</span><ins>+    // We expect this to be called on the main thread so we get the default website data store.
+    ASSERT(isMainThread());
+    
</ins><span class="cx">     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
</span><span class="cx">         explicit CallbackAggregator(Function<void(HashSet<String>&&)>&& completionHandler)
</span><span class="cx">             : completionHandler(WTFMove(completionHandler))
</span><span class="lines">@@ -312,13 +320,14 @@
</span><span class="cx">         visitedSessionIDs.add(dataStore.sessionID());
</span><span class="cx">         callbackAggregator->addPendingCallback();
</span><span class="cx">         dataStore.topPrivatelyControlledDomainsWithWebsiteData(dataTypes, { }, [callbackAggregator, shouldNotifyPage, page](HashSet<String>&& domainsWithDataRecords) {
</span><ins>+            // When completing the task, we should be getting called on the main thread.
+            ASSERT(isMainThread());
+            
</ins><span class="cx">             if (shouldNotifyPage)
</span><span class="cx">                 page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr);
</span><span class="cx">             
</span><del>-            WTF::RunLoop::main().dispatch([callbackAggregator, domainsWithDataRecords = WTFMove(domainsWithDataRecords)]() mutable {
-                callbackAggregator->addDomainsWithDeletedWebsiteData(WTFMove(domainsWithDataRecords));
-                callbackAggregator->removePendingCallback();
-            });
</del><ins>+            callbackAggregator->addDomainsWithDeletedWebsiteData(WTFMove(domainsWithDataRecords));
+            callbackAggregator->removePendingCallback();
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -867,7 +876,7 @@
</span><span class="cx">         page->activityStateDidChange(ActivityState::IsVisuallyIdle);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebProcessProxy::fetchWebsiteData(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, Function<void (WebsiteData)> completionHandler)
</del><ins>+void WebProcessProxy::fetchWebsiteData(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, Function<void(WebsiteData)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(canSendMessage());
</span><span class="cx"> 
</span><span class="lines">@@ -885,7 +894,7 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebProcessProxy::deleteWebsiteData(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, std::chrono::system_clock::time_point modifiedSince, Function<void ()> completionHandler)
</del><ins>+void WebProcessProxy::deleteWebsiteData(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, std::chrono::system_clock::time_point modifiedSince, Function<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(canSendMessage());
</span><span class="cx"> 
</span><span class="lines">@@ -898,7 +907,7 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebProcessProxy::deleteWebsiteDataForOrigins(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, Function<void()> completionHandler)
</del><ins>+void WebProcessProxy::deleteWebsiteDataForOrigins(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, Function<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(canSendMessage());
</span><span class="cx"> 
</span></span></pre></div>
<a id="tagsSafari604125SourceWebKit2UIProcessWebProcessProxyh"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.h (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.h  2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebProcessProxy.h     2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -138,11 +138,11 @@
</span><span class="cx">     void didSaveToPageCache();
</span><span class="cx">     void releasePageCache();
</span><span class="cx"> 
</span><del>-    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);
</del><ins>+    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);
</ins><span class="cx">     static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, Function<void(Vector<String>)>&& completionHandler);
</span><del>-    static void topPrivatelyControlledDomainsWithWebiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, Function<void(HashSet<String>&&)> completionHandler);
</del><ins>+    static void topPrivatelyControlledDomainsWithWebiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, Function<void(HashSet<String>&&)>&& completionHandler);
</ins><span class="cx">     static void notifyPageStatisticsAndDataRecordsProcessed();
</span><span class="cx"> 
</span><span class="cx">     void enableSuddenTermination();
</span></span></pre></div>
<a id="tagsSafari604125SourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp   2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp      2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -182,10 +182,10 @@
</span><span class="cx">     return processAccessType;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, std::function<void (Vector<WebsiteDataRecord>)> completionHandler)
</del><ins>+void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(Vector<WebsiteDataRecord>)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     struct CallbackAggregator final : ThreadSafeRefCounted<CallbackAggregator> {
</span><del>-        explicit CallbackAggregator(OptionSet<WebsiteDataFetchOption> fetchOptions, std::function<void (Vector<WebsiteDataRecord>)> completionHandler)
</del><ins>+        explicit CallbackAggregator(OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(Vector<WebsiteDataRecord>)>&& completionHandler)
</ins><span class="cx">             : fetchOptions(fetchOptions)
</span><span class="cx">             , completionHandler(WTFMove(completionHandler))
</span><span class="cx">         {
</span><span class="lines">@@ -281,7 +281,7 @@
</span><span class="cx">         const OptionSet<WebsiteDataFetchOption> fetchOptions;
</span><span class="cx"> 
</span><span class="cx">         unsigned pendingCallbacks = 0;
</span><del>-        std::function<void (Vector<WebsiteDataRecord>)> completionHandler;
</del><ins>+        Function<void(Vector<WebsiteDataRecord>)> completionHandler;
</ins><span class="cx"> 
</span><span class="cx">         HashMap<String, WebsiteDataRecord> m_websiteDataRecords;
</span><span class="cx">     };
</span><span class="lines">@@ -507,9 +507,9 @@
</span><span class="cx">     callbackAggregator->callIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Vector<String>&& topPrivatelyControlledDomains, std::function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)> completionHandler)
</del><ins>+void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    fetchData(dataTypes, fetchOptions, [topPrivatelyControlledDomains = WTFMove(topPrivatelyControlledDomains), completionHandler](auto&& existingDataRecords) {
</del><ins>+    fetchData(dataTypes, fetchOptions, [topPrivatelyControlledDomains = WTFMove(topPrivatelyControlledDomains), completionHandler = WTFMove(completionHandler)](auto&& existingDataRecords) {
</ins><span class="cx">         Vector<WebsiteDataRecord> matchingDataRecords;
</span><span class="cx">         Vector<String> domainsWithMatchingDataRecords;
</span><span class="cx">         for (auto&& dataRecord : existingDataRecords) {
</span><span class="lines">@@ -525,15 +525,15 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-void WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, std::function<void(HashSet<String>&&)> completionHandler)
</del><ins>+void WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    fetchData(dataTypes, fetchOptions, [completionHandler, this](auto&& existingDataRecords) {
</del><ins>+    fetchData(dataTypes, fetchOptions, [completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](auto&& existingDataRecords) {
</ins><span class="cx">         HashSet<String> domainsWithDataRecords;
</span><span class="cx">         for (auto&& dataRecord : existingDataRecords) {
</span><span class="cx">             String domain = dataRecord.topPrivatelyControlledDomain();
</span><span class="cx">             if (domain.isEmpty())
</span><span class="cx">                 continue;
</span><del>-            domainsWithDataRecords.add(domain);
</del><ins>+            domainsWithDataRecords.add(WTFMove(domain));
</ins><span class="cx">         }
</span><span class="cx">         completionHandler(WTFMove(domainsWithDataRecords));
</span><span class="cx">     });
</span><span class="lines">@@ -577,10 +577,10 @@
</span><span class="cx">     return processAccessType;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler)
</del><ins>+void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, std::chrono::system_clock::time_point modifiedSince, Function<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
</span><del>-        explicit CallbackAggregator (std::function<void ()> completionHandler)
</del><ins>+        explicit CallbackAggregator(Function<void()>&& completionHandler)
</ins><span class="cx">             : completionHandler(WTFMove(completionHandler))
</span><span class="cx">         {
</span><span class="cx">         }
</span><span class="lines">@@ -605,7 +605,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         unsigned pendingCallbacks = 0;
</span><del>-        std::function<void()> completionHandler;
</del><ins>+        Function<void()> completionHandler;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
</span><span class="lines">@@ -800,7 +800,7 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (dataTypes.contains(WebsiteDataType::WebsiteDataTypeResourceLoadStatistics))
</del><ins>+    if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics))
</ins><span class="cx">         WebCore::ResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore(modifiedSince);
</span><span class="cx"> 
</span><span class="cx">     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
</span><span class="lines">@@ -807,7 +807,7 @@
</span><span class="cx">     callbackAggregator->callIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Vector<WebsiteDataRecord>& dataRecords, std::function<void ()> completionHandler)
</del><ins>+void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Vector<WebsiteDataRecord>& dataRecords, Function<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     Vector<WebCore::SecurityOriginData> origins;
</span><span class="cx"> 
</span><span class="lines">@@ -817,7 +817,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
</span><del>-        explicit CallbackAggregator (std::function<void ()> completionHandler)
</del><ins>+        explicit CallbackAggregator(Function<void()>&& completionHandler)
</ins><span class="cx">             : completionHandler(WTFMove(completionHandler))
</span><span class="cx">         {
</span><span class="cx">         }
</span><span class="lines">@@ -842,7 +842,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         unsigned pendingCallbacks = 0;
</span><del>-        std::function<void()> completionHandler;
</del><ins>+        Function<void()> completionHandler;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
</span><span class="lines">@@ -1069,7 +1069,7 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (dataTypes.contains(WebsiteDataType::WebsiteDataTypeResourceLoadStatistics))
</del><ins>+    if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics))
</ins><span class="cx">         WebCore::ResourceLoadObserver::sharedObserver().clearInMemoryAndPersistentStore();
</span><span class="cx"> 
</span><span class="cx">     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
</span><span class="lines">@@ -1076,11 +1076,11 @@
</span><span class="cx">     callbackAggregator->callIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Vector<String>&& topPrivatelyControlledDomains, std::function<void(Vector<String>)> completionHandler)
</del><ins>+void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<String>&&)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, WTFMove(topPrivatelyControlledDomains), [dataTypes, completionHandler, this](auto websiteDataRecords, auto domainsWithDataRecords) {
-        this->removeData(dataTypes, websiteDataRecords, [domainsWithDataRecords, completionHandler]() {
-            completionHandler(domainsWithDataRecords);
</del><ins>+    fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, WTFMove(topPrivatelyControlledDomains), [dataTypes, completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](Vector<WebsiteDataRecord>&& websiteDataRecords, Vector<String>&& domainsWithDataRecords) mutable {
+        this->removeData(dataTypes, websiteDataRecords, [domainsWithDataRecords = WTFMove(domainsWithDataRecords), completionHandler = WTFMove(completionHandler)]() mutable {
+            completionHandler(WTFMove(domainsWithDataRecords));
</ins><span class="cx">         });
</span><span class="cx">     });
</span><span class="cx"> }
</span></span></pre></div>
<a id="tagsSafari604125SourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (218117 => 218118)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h     2017-06-12 18:49:09 UTC (rev 218117)
+++ tags/Safari-604.1.25/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2017-06-12 18:49:13 UTC (rev 218118)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include <WebCore/SecurityOriginHash.h>
</span><span class="cx"> #include <WebCore/SessionID.h>
</span><span class="cx"> #include <functional>
</span><ins>+#include <wtf/Function.h>
</ins><span class="cx"> #include <wtf/HashSet.h>
</span><span class="cx"> #include <wtf/OptionSet.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -93,12 +94,12 @@
</span><span class="cx"> 
</span><span class="cx">     static void cloneSessionData(WebPageProxy& sourcePage, WebPageProxy& newPage);
</span><span class="cx"> 
</span><del>-    void fetchData(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, std::function<void (Vector<WebsiteDataRecord>)> completionHandler);
-    void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, std::function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)> completionHandler);
-    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, std::function<void(HashSet<String>&&)> completionHandler);
-    void removeData(OptionSet<WebsiteDataType>, std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler);
-    void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, std::function<void ()> completionHandler);
-    void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, std::function<void(Vector<String>)> completionHandler);
</del><ins>+    void fetchData(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Function<void(Vector<WebsiteDataRecord>)>&& completionHandler);
+    void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)>&& completionHandler);
+    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler);
+    void removeData(OptionSet<WebsiteDataType>, std::chrono::system_clock::time_point modifiedSince, Function<void()>&& completionHandler);
+    void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler);
+    void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<String>&&)>&& completionHandler);
</ins><span class="cx"> 
</span><span class="cx"> #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
</span><span class="cx">     void shouldPartitionCookiesForTopPrivatelyOwnedDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
</span></span></pre>
</div>
</div>

</body>
</html>