<!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>[282110] trunk/Source/WebKit</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/282110">282110</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2021-09-07 15:14:26 -0700 (Tue, 07 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Replace PrivateClickMeasurementNetworkLoader::start with an implementation that doesn't need NetworkSession
https://bugs.webkit.org/show_bug.cgi?id=230015

Reviewed by John Wilander.

This is needed to run this code in a process that doesn't have NetworkSession, which is a class tied closely to WKWebsiteDataStore.
This replaces it with a simple implementation that does the same things:
1. Uses an ephemeral stateless session that doesn't accept cookies or use credentials.
2. Does not allow redirects.
3. Only accepts JSON mime types.
4. Calls processPCMRequest

We still need to call NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost to get tests to pass.
Covered by existing tests.

* NetworkProcess/NetworkLoadParameters.h:
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):
* NetworkProcess/NetworkSession.h:
(WebKit::NetworkSession::addPrivateClickMeasurementNetworkLoader): Deleted.
(WebKit::NetworkSession::removePrivateClickMeasurementNetworkLoader): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h:
(WebKit::PCM::Client::~Client):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp:
(WebKit::PCM::ClientImpl::loadFromNetwork): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h:
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp:
(WebKit::PrivateClickMeasurementManager::getTokenPublicKey):
(WebKit::PrivateClickMeasurementManager::getSignedUnlinkableToken):
(WebKit::PrivateClickMeasurementManager::fireConversionRequestImpl):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp:
(WebKit::PCM::NetworkLoader::start):
(WebKit::generateNetworkLoadParameters): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::start): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::PrivateClickMeasurementNetworkLoader): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::~PrivateClickMeasurementNetworkLoader): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::fail): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::cancel): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::willSendRedirectedRequest): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::didReceiveResponse): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::didReceiveBuffer): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::didFinishLoading): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::didFailLoading): Deleted.
(WebKit::PrivateClickMeasurementNetworkLoader::didComplete): Deleted.
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.h:
(): Deleted.
* NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm: Added.
(processPCMRequest):
(-[WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
(-[WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON URLSession:dataTask:didReceiveResponse:completionHandler:]):
(-[WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON URLSession:task:didReceiveChallenge:completionHandler:]):
(WebKit::PCM::taskMap):
(WebKit::PCM::statelessSessionWithoutRedirects):
(WebKit::PCM::NetworkLoader::start):
* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
(processPCMRequest): Deleted.
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkLoadParametersh">trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkResourceLoadParameterscpp">trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSessionh">trunk/Source/WebKit/NetworkProcess/NetworkSession.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementClienth">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementClientImplcpp">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementClientImplh">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementManagercpp">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementNetworkLoadercpp">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementNetworkLoaderh">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkDataTaskCocoah">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcesscocoaNetworkDataTaskCocoamm">trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitSourcesCocoatxt">trunk/Source/WebKit/SourcesCocoa.txt</a></li>
<li><a href="#trunkSourceWebKitWebKitxcodeprojprojectpbxproj">trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/</li>
<li><a href="#trunkSourceWebKitNetworkProcessPrivateClickMeasurementcocoaPrivateClickMeasurementNetworkLoaderCocoamm">trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/ChangeLog       2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -1,5 +1,69 @@
</span><span class="cx"> 2021-09-07  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><ins>+        Replace PrivateClickMeasurementNetworkLoader::start with an implementation that doesn't need NetworkSession
+        https://bugs.webkit.org/show_bug.cgi?id=230015
+
+        Reviewed by John Wilander.
+
+        This is needed to run this code in a process that doesn't have NetworkSession, which is a class tied closely to WKWebsiteDataStore.
+        This replaces it with a simple implementation that does the same things:
+        1. Uses an ephemeral stateless session that doesn't accept cookies or use credentials.
+        2. Does not allow redirects.
+        3. Only accepts JSON mime types.
+        4. Calls processPCMRequest
+
+        We still need to call NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost to get tests to pass.
+        Covered by existing tests.
+
+        * NetworkProcess/NetworkLoadParameters.h:
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode const):
+        (WebKit::NetworkResourceLoadParameters::decode):
+        * NetworkProcess/NetworkSession.h:
+        (WebKit::NetworkSession::addPrivateClickMeasurementNetworkLoader): Deleted.
+        (WebKit::NetworkSession::removePrivateClickMeasurementNetworkLoader): Deleted.
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h:
+        (WebKit::PCM::Client::~Client):
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp:
+        (WebKit::PCM::ClientImpl::loadFromNetwork): Deleted.
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h:
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp:
+        (WebKit::PrivateClickMeasurementManager::getTokenPublicKey):
+        (WebKit::PrivateClickMeasurementManager::getSignedUnlinkableToken):
+        (WebKit::PrivateClickMeasurementManager::fireConversionRequestImpl):
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp:
+        (WebKit::PCM::NetworkLoader::start):
+        (WebKit::generateNetworkLoadParameters): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::start): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::PrivateClickMeasurementNetworkLoader): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::~PrivateClickMeasurementNetworkLoader): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::fail): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::cancel): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::willSendRedirectedRequest): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::didReceiveResponse): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::didReceiveBuffer): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::didFinishLoading): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::didFailLoading): Deleted.
+        (WebKit::PrivateClickMeasurementNetworkLoader::didComplete): Deleted.
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.h:
+        (): Deleted.
+        * NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm: Added.
+        (processPCMRequest):
+        (-[WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+        (-[WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON URLSession:dataTask:didReceiveResponse:completionHandler:]):
+        (-[WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON URLSession:task:didReceiveChallenge:completionHandler:]):
+        (WebKit::PCM::taskMap):
+        (WebKit::PCM::statelessSessionWithoutRedirects):
+        (WebKit::PCM::NetworkLoader::start):
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
+        (processPCMRequest): Deleted.
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+
+2021-09-07  Alex Christensen  <achristensen@webkit.org>
+
</ins><span class="cx">         Simplify PrivateClickMeasurementManager interface
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=230014
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkLoadParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h       2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoadParameters.h  2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -67,7 +67,6 @@
</span><span class="cx">     PreconnectOnly shouldPreconnectOnly { PreconnectOnly::No };
</span><span class="cx">     std::optional<NetworkActivityTracker> networkActivityTracker;
</span><span class="cx">     std::optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain { NavigatingToAppBoundDomain::No };
</span><del>-    std::optional<WebCore::PrivateClickMeasurement::PcmDataCarried> pcmDataCarried;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkResourceLoadParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp     2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp        2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -127,7 +127,6 @@
</span><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx">     encoder << isNavigatingToAppBoundDomain;
</span><del>-    encoder << pcmDataCarried;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::optional<NetworkResourceLoadParameters> NetworkResourceLoadParameters::decode(IPC::Decoder& decoder)
</span><span class="lines">@@ -329,12 +328,6 @@
</span><span class="cx">     if (!isNavigatingToAppBoundDomain)
</span><span class="cx">         return std::nullopt;
</span><span class="cx">     result.isNavigatingToAppBoundDomain = *isNavigatingToAppBoundDomain;
</span><del>-
-    std::optional<std::optional<WebCore::PrivateClickMeasurement::PcmDataCarried>> pcmDataCarried;
-    decoder >> pcmDataCarried;
-    if (!pcmDataCarried)
-        return std::nullopt;
-    result.pcmDataCarried = *pcmDataCarried;
</del><span class="cx">     
</span><span class="cx">     return result;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h      2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -29,7 +29,6 @@
</span><span class="cx"> #include "NavigatingToAppBoundDomain.h"
</span><span class="cx"> #include "NetworkResourceLoadIdentifier.h"
</span><span class="cx"> #include "PrefetchCache.h"
</span><del>-#include "PrivateClickMeasurementNetworkLoader.h"
</del><span class="cx"> #include "SandboxExtension.h"
</span><span class="cx"> #include "ServiceWorkerSoftUpdateLoader.h"
</span><span class="cx"> #include "WebResourceLoadStatisticsStore.h"
</span><span class="lines">@@ -174,9 +173,6 @@
</span><span class="cx">     AppPrivacyReportTestingData& appPrivacyReportTestingData() { return m_appPrivacyReportTestingData; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void addPrivateClickMeasurementNetworkLoader(std::unique_ptr<PrivateClickMeasurementNetworkLoader>&& loader) { m_privateClickMeasurementNetworkLoaders.add(WTFMove(loader)); }
-    void removePrivateClickMeasurementNetworkLoader(PrivateClickMeasurementNetworkLoader* loader) { m_privateClickMeasurementNetworkLoaders.remove(loader); }
-
</del><span class="cx">     virtual void removeNetworkWebsiteData(std::optional<WallTime>, std::optional<HashSet<WebCore::RegistrableDomain>>&&, CompletionHandler<void()>&& completionHandler) { completionHandler(); }
</span><span class="cx"> 
</span><span class="cx">     virtual void addWebPageNetworkParameters(WebPageProxyIdentifier, WebPageNetworkParameters&&) { }
</span><span class="lines">@@ -248,7 +244,6 @@
</span><span class="cx">     AppPrivacyReportTestingData m_appPrivacyReportTestingData;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    HashSet<std::unique_ptr<PrivateClickMeasurementNetworkLoader>> m_privateClickMeasurementNetworkLoaders;
</del><span class="cx">     HashMap<WebPageProxyIdentifier, String> m_attributedBundleIdentifierFromPageIdentifiers;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h       2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClient.h  2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -46,8 +46,6 @@
</span><span class="cx"> class Client {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~Client() { }
</span><del>-    using NetworkLoadCallback = CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&, const RefPtr<JSON::Object>&)>;
-    virtual void loadFromNetwork(URL&&, RefPtr<JSON::Object>&&, WebCore::PrivateClickMeasurement::PcmDataCarried, NetworkLoadCallback&&) = 0;
</del><span class="cx">     virtual void broadcastConsoleMessage(JSC::MessageLevel, const String&) = 0;
</span><span class="cx">     virtual bool featureEnabled() const = 0;
</span><span class="cx">     virtual bool debugModeEnabled() const = 0;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementClientImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp 2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp    2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -37,14 +37,6 @@
</span><span class="cx">     : m_networkSession(makeWeakPtr(session))
</span><span class="cx">     , m_networkProcess(networkProcess) { }
</span><span class="cx"> 
</span><del>-void ClientImpl::loadFromNetwork(URL&& url, RefPtr<JSON::Object>&& jsonPayload, WebCore::PrivateClickMeasurement::PcmDataCarried pcmDataCarried, NetworkLoadCallback&& completionHandler)
-{
-    if (!featureEnabled())
-        return completionHandler(WebCore::ResourceError(WebCore::ResourceError::Type::Cancellation), { }, { });
-
-    PrivateClickMeasurementNetworkLoader::start(*m_networkSession, WTFMove(url), WTFMove(jsonPayload), pcmDataCarried, WTFMove(completionHandler));
-}
-
</del><span class="cx"> void ClientImpl::broadcastConsoleMessage(JSC::MessageLevel messageLevel, const String& message)
</span><span class="cx"> {
</span><span class="cx">     if (!featureEnabled())
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h   2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.h      2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -43,7 +43,6 @@
</span><span class="cx">     ClientImpl(NetworkSession&, NetworkProcess&);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void loadFromNetwork(URL&&, RefPtr<JSON::Object>&&, WebCore::PrivateClickMeasurement::PcmDataCarried, NetworkLoadCallback&&) final;
</del><span class="cx">     void broadcastConsoleMessage(JSC::MessageLevel, const String&) final;
</span><span class="cx">     bool featureEnabled() const final;
</span><span class="cx">     bool debugModeEnabled() const final;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp    2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp       2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "Logging.h"
</span><span class="cx"> #include "NetworkSession.h"
</span><span class="cx"> #include "PrivateClickMeasurementDebugInfo.h"
</span><ins>+#include "PrivateClickMeasurementNetworkLoader.h"
</ins><span class="cx"> #include <JavaScriptCore/ConsoleTypes.h>
</span><span class="cx"> #include <WebCore/FetchOptions.h>
</span><span class="cx"> #include <WebCore/FormData.h>
</span><span class="lines">@@ -131,7 +132,7 @@
</span><span class="cx">     RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire a token public key request.");
</span><span class="cx">     m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] About to fire a token public key request."_s);
</span><span class="cx"> 
</span><del>-    m_client->loadFromNetwork(WTFMove(tokenPublicKeyURL), nullptr, pcmDataCarried, [weakThis = makeWeakPtr(*this), this, attribution = WTFMove(attribution), callback = WTFMove(callback)] (auto& error, auto& response, auto& jsonObject) mutable {
</del><ins>+    PCM::NetworkLoader::start(WTFMove(tokenPublicKeyURL), nullptr, pcmDataCarried, [weakThis = makeWeakPtr(*this), this, attribution = WTFMove(attribution), callback = WTFMove(callback)] (auto& error, auto& response, auto& jsonObject) mutable {
</ins><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -149,7 +150,6 @@
</span><span class="cx"> 
</span><span class="cx">         callback(WTFMove(attribution), jsonObject->getString("token_public_key"_s));
</span><span class="cx">     });
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PrivateClickMeasurementManager::getSignedUnlinkableToken(PrivateClickMeasurement&& measurement)
</span><span class="lines">@@ -175,7 +175,7 @@
</span><span class="cx">     RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire a unlinkable token signing request.");
</span><span class="cx">     m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] About to fire a unlinkable token signing request."_s);
</span><span class="cx"> 
</span><del>-    m_client->loadFromNetwork(WTFMove(tokenSignatureURL), measurement.tokenSignatureJSON(), pcmDataCarried, [weakThis = makeWeakPtr(*this), this, measurement = WTFMove(measurement)] (auto& error, auto& response, auto& jsonObject) mutable {
</del><ins>+    PCM::NetworkLoader::start(WTFMove(tokenSignatureURL), measurement.tokenSignatureJSON(), pcmDataCarried, [weakThis = makeWeakPtr(*this), this, measurement = WTFMove(measurement)] (auto& error, auto& response, auto& jsonObject) mutable {
</ins><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -357,7 +357,7 @@
</span><span class="cx">     RELEASE_LOG_INFO(PrivateClickMeasurement, "About to fire an attribution request.");
</span><span class="cx">     m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] About to fire an attribution request."_s);
</span><span class="cx"> 
</span><del>-    m_client->loadFromNetwork(WTFMove(attributionURL), attribution.attributionReportJSON(), pcmDataCarried, [weakThis = makeWeakPtr(*this), this](auto& error, auto& response, auto&) {
</del><ins>+    PCM::NetworkLoader::start(WTFMove(attributionURL), attribution.attributionReportJSON(), pcmDataCarried, [weakThis = makeWeakPtr(*this), this](auto& error, auto& response, auto&) {
</ins><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementNetworkLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp      2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp 2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -26,124 +26,20 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "PrivateClickMeasurementNetworkLoader.h"
</span><span class="cx"> 
</span><del>-#include "NetworkLoad.h"
-#include "NetworkSession.h"
-#include <WebCore/HTTPHeaderValues.h>
-#include <WebCore/MIMETypeRegistry.h>
-#include <WebCore/RuntimeApplicationChecks.h>
-#include <WebCore/TextResourceDecoder.h>
</del><ins>+#include <WebCore/NotImplemented.h>
</ins><span class="cx"> 
</span><del>-#include <wtf/JSONValues.h>
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-using namespace WebCore;
</del><ins>+namespace PCM {
</ins><span class="cx"> 
</span><del>-static NetworkLoadParameters generateNetworkLoadParameters(URL&& url, RefPtr<JSON::Object>&& jsonPayload, PrivateClickMeasurement::PcmDataCarried pcmDataCarried)
</del><ins>+#if !PLATFORM(COCOA)
+void NetworkLoader::start(URL&&, RefPtr<JSON::Object>&&, PrivateClickMeasurement::PcmDataCarried, Callback&& completionHandler)
</ins><span class="cx"> {
</span><del>-    String httpMethod = jsonPayload ? "POST"_s : "GET"_s;
-
-    ResourceRequest request { WTFMove(url) };
-    request.setHTTPMethod(httpMethod);
-    request.setHTTPHeaderField(HTTPHeaderName::CacheControl, WebCore::HTTPHeaderValues::maxAge0());
-    if (jsonPayload) {
-        request.setHTTPContentType(WebCore::HTTPHeaderValues::applicationJSONContentType());
-        request.setHTTPBody(WebCore::FormData::create(jsonPayload->toJSONString().utf8()));
-    }
-
-    NetworkLoadParameters loadParameters;
-    loadParameters.request = request;
-    loadParameters.parentPID = presentingApplicationPID();
-    loadParameters.storedCredentialsPolicy = StoredCredentialsPolicy::EphemeralStateless;
-    loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = true;
-    loadParameters.pcmDataCarried = pcmDataCarried;
-
-    return loadParameters;
</del><ins>+    notImplemented();
+    completionHandler({ }, { }, { });
</ins><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><del>-void PrivateClickMeasurementNetworkLoader::start(NetworkSession& session, URL&& url, RefPtr<JSON::Object>&& jsonPayload, PrivateClickMeasurement::PcmDataCarried pcmDataCarried, Callback&& completionHandler)
-{
-    auto parameters = generateNetworkLoadParameters(WTFMove(url), WTFMove(jsonPayload), pcmDataCarried);
-    auto loader = std::unique_ptr<PrivateClickMeasurementNetworkLoader>(new PrivateClickMeasurementNetworkLoader(session, WTFMove(parameters), WTFMove(completionHandler)));
-    session.addPrivateClickMeasurementNetworkLoader(WTFMove(loader));
-}
</del><ins>+} // namespace PCM
</ins><span class="cx"> 
</span><del>-PrivateClickMeasurementNetworkLoader::PrivateClickMeasurementNetworkLoader(NetworkSession& session, NetworkLoadParameters&& parameters, Callback&& completionHandler)
-    : m_session(makeWeakPtr(session))
-    , m_completionHandler(WTFMove(completionHandler))
-{
-    m_networkLoad = makeUnique<NetworkLoad>(*this, nullptr, WTFMove(parameters), *m_session);
-    m_networkLoad->start();
-}
-
-PrivateClickMeasurementNetworkLoader::~PrivateClickMeasurementNetworkLoader()
-{
-    cancel();
-}
-
-void PrivateClickMeasurementNetworkLoader::fail(ResourceError&& error)
-{
-    if (!m_completionHandler)
-        return;
-
-    m_completionHandler(WTFMove(error), { }, nullptr);
-    didComplete();
-}
-
-void PrivateClickMeasurementNetworkLoader::cancel()
-{
-    fail(ResourceError { ResourceError::Type::Cancellation });
-}
-
-void PrivateClickMeasurementNetworkLoader::willSendRedirectedRequest(ResourceRequest&&, ResourceRequest&&, ResourceResponse&&)
-{
-    cancel();
-}
-
-void PrivateClickMeasurementNetworkLoader::didReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
-{
-    if (!MIMETypeRegistry::isSupportedJSONMIMEType(response.mimeType())) {
-        fail({ errorDomainWebKitInternal, 0, response.url(), "MIME Type is not a JSON MIME type"_s });
-        completionHandler(PolicyAction::Ignore);
-        return;
-    }
-
-    m_response = WTFMove(response);
-    completionHandler(PolicyAction::Use);
-}
-
-void PrivateClickMeasurementNetworkLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, int reportedEncodedDataLength)
-{
-    if (!m_decoder)
-        m_decoder = TextResourceDecoder::create("application/json"_s, m_response.textEncodingName().isEmpty() ? WebCore::TextEncoding("UTF-8") : WebCore::TextEncoding(m_response.textEncodingName()));
-
-    if (auto size = buffer->size())
-        m_jsonString.append(m_decoder->decode(buffer->data(), size));
-}
-
-void PrivateClickMeasurementNetworkLoader::didFinishLoading(const WebCore::NetworkLoadMetrics&)
-{
-    if (m_decoder)
-        m_jsonString.append(m_decoder->flush());
-
-    if (auto jsonValue = JSON::Value::parseJSON(m_jsonString.toString()))
-        m_completionHandler({ }, m_response, jsonValue->asObject());
-    else
-        m_completionHandler({ }, m_response, nullptr);
-
-    didComplete();
-}
-
-void PrivateClickMeasurementNetworkLoader::didFailLoading(const ResourceError& error)
-{
-    fail(ResourceError(error));
-}
-
-void PrivateClickMeasurementNetworkLoader::didComplete()
-{
-    m_networkLoad = nullptr;
-    if (m_session)
-        m_session->removePrivateClickMeasurementNetworkLoader(this);
-}
-
</del><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementPrivateClickMeasurementNetworkLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.h (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.h        2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.h   2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -25,49 +25,25 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#include "NetworkLoad.h"
-#include "NetworkLoadClient.h"
-#include "NetworkLoadParameters.h"
-#include <WebCore/TextResourceDecoder.h>
</del><span class="cx"> #include <wtf/CompletionHandler.h>
</span><del>-#include <wtf/WeakPtr.h>
</del><ins>+#include <wtf/JSONValues.h>
</ins><span class="cx"> 
</span><ins>+namespace WebCore {
+class ResourceError;
+class ResourceResponse;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-class NetworkSession;
</del><ins>+namespace PCM {
</ins><span class="cx"> 
</span><del>-class PrivateClickMeasurementNetworkLoader final : public NetworkLoadClient {
</del><ins>+class NetworkLoader {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="cx">     using Callback = CompletionHandler<void(const WebCore::ResourceError&, const WebCore::ResourceResponse&, const RefPtr<JSON::Object>&)>;
</span><del>-    static void start(NetworkSession&, URL&&, RefPtr<JSON::Object>&&, WebCore::PrivateClickMeasurement::PcmDataCarried, Callback&&);
</del><ins>+    static void start(URL&&, RefPtr<JSON::Object>&&, WebCore::PrivateClickMeasurement::PcmDataCarried, Callback&&);
+};
</ins><span class="cx"> 
</span><del>-    ~PrivateClickMeasurementNetworkLoader();
</del><ins>+} // namespace PCM
</ins><span class="cx"> 
</span><del>-private:
-    PrivateClickMeasurementNetworkLoader(NetworkSession&, NetworkLoadParameters&&, Callback&&);
-
-    // NetworkLoadClient.
-    void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) final { }
-    bool isSynchronous() const final { return false; }
-    bool isAllowedToAskUserForCredentials() const final { return false; }
-    void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final;
-    void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) final;
-    void didFinishLoading(const WebCore::NetworkLoadMetrics&) final;
-    void didFailLoading(const WebCore::ResourceError&) final;
-
-    void fail(WebCore::ResourceError&&);
-    void cancel();
-    void didComplete();
-
-    WeakPtr<NetworkSession> m_session;
-    std::unique_ptr<NetworkLoad> m_networkLoad;
-    Callback m_completionHandler;
-
-    WebCore::ResourceResponse m_response;
-    RefPtr<WebCore::TextResourceDecoder> m_decoder;
-    StringBuilder m_jsonString;
-};
-
</del><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessPrivateClickMeasurementcocoaPrivateClickMeasurementNetworkLoaderCocoamm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm (0 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm                            (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm       2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -0,0 +1,123 @@
</span><ins>+/*
+ * Copyright (C) 2021 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#import "config.h"
+#import "PrivateClickMeasurementNetworkLoader.h"
+
+#import "NetworkSessionCocoa.h"
+#import <WebCore/HTTPHeaderValues.h>
+#import <WebCore/MIMETypeRegistry.h>
+#import <pal/spi/cf/CFNetworkSPI.h>
+#import <wtf/NeverDestroyed.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/NetworkDataTaskCocoaAdditions.h>
+#else
+static void processPCMRequest(WebCore::PrivateClickMeasurement::PcmDataCarried, NSMutableURLRequest *) { }
+#endif
+
+@interface WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON : NSObject <NSURLSessionDataDelegate>
+@end
+
+@implementation WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON
+
+- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task willPerformHTTPRedirection:(NSHTTPURLResponse *)response newRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLRequest *))completionHandler
+{
+    completionHandler(nil);
+}
+
+- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler
+{
+    if (MIMETypeRegistry::isSupportedJSONMIMEType(response.MIMEType))
+        return completionHandler(NSURLSessionResponseAllow);
+    completionHandler(NSURLSessionResponseCancel);
+}
+
+- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
+{
+    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]
+        && NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost(challenge))
+        return completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+    completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
+}
+
+@end
+
+namespace WebKit {
+
+namespace PCM {
+
+enum LoadTaskIdentifierType { };
+using LoadTaskIdentifier = ObjectIdentifier<LoadTaskIdentifierType>;
+static HashMap<LoadTaskIdentifier, RetainPtr<NSURLSessionDataTask>>& taskMap()
+{
+    static NeverDestroyed<HashMap<LoadTaskIdentifier, RetainPtr<NSURLSessionDataTask>>> map;
+    return map.get();
+}
+
+static NSURLSession *statelessSessionWithoutRedirects()
+{
+    static NeverDestroyed<RetainPtr<WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON>> delegate = adoptNS([WKNetworkSessionDelegateAllowingOnlyNonRedirectedJSON new]);
+    static NeverDestroyed<RetainPtr<NSURLSession>> session = [&] {
+        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
+        configuration.HTTPCookieAcceptPolicy = NSHTTPCookieAcceptPolicyNever;
+        configuration.URLCredentialStorage = nil;
+        configuration.URLCache = nil;
+        configuration.HTTPCookieStorage = nil;
+        configuration._shouldSkipPreferredClientCertificateLookup = YES;
+        return adoptNS([NSURLSession sessionWithConfiguration:configuration delegate:delegate.get().get() delegateQueue:[NSOperationQueue mainQueue]]);
+    }();
+    return session.get().get();
+}
+
+void NetworkLoader::start(URL&& url, RefPtr<JSON::Object>&& jsonPayload, WebCore::PrivateClickMeasurement::PcmDataCarried pcmDataCarried, Callback&& callback)
+{
+    auto request = adoptNS([[NSMutableURLRequest alloc] initWithURL:url]);
+    [request setValue:WebCore::HTTPHeaderValues::maxAge0() forHTTPHeaderField:@"Cache-Control"];
+    if (jsonPayload) {
+        request.get().HTTPMethod = @"POST";
+        [request setValue:WebCore::HTTPHeaderValues::applicationJSONContentType() forHTTPHeaderField:@"Content-Type"];
+        auto body = jsonPayload->toJSONString().utf8();
+        request.get().HTTPBody = adoptNS([[NSData alloc] initWithBytes:body.data() length:body.length()]).get();
+    }
+
+    processPCMRequest(pcmDataCarried, request.get());
+
+    auto identifier = LoadTaskIdentifier::generate();
+    NSURLSessionDataTask *task = [statelessSessionWithoutRedirects() dataTaskWithRequest:request.get() completionHandler:makeBlockPtr([callback = WTFMove(callback), identifier](NSData *data, NSURLResponse *response, NSError *error) mutable {
+        taskMap().remove(identifier);
+        if (error)
+            return callback(error, { }, { });
+        if (auto jsonValue = JSON::Value::parseJSON(String::fromUTF8(static_cast<const LChar*>(data.bytes), data.length)))
+            return callback({ }, response, jsonValue->asObject());
+        callback({ }, response, nullptr);
+    }).get()];
+    [task resume];
+    taskMap().add(identifier, task);
+}
+
+} // namespace PCM
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkDataTaskCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h  2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h     2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -29,10 +29,12 @@
</span><span class="cx"> #include "NetworkDataTask.h"
</span><span class="cx"> #include "NetworkLoadParameters.h"
</span><span class="cx"> #include <WebCore/NetworkLoadMetrics.h>
</span><ins>+#include <WebCore/PrivateClickMeasurement.h>
</ins><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><span class="cx"> OBJC_CLASS NSHTTPCookieStorage;
</span><span class="cx"> OBJC_CLASS NSURLSessionDataTask;
</span><ins>+OBJC_CLASS NSMutableURLRequest;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class RegistrableDomain;
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcesscocoaNetworkDataTaskCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm    2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -57,7 +57,6 @@
</span><span class="cx"> #if USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> #import <WebKitAdditions/NetworkDataTaskCocoaAdditions.h>
</span><span class="cx"> #else
</span><del>-static void processPCMRequest(WebCore::PrivateClickMeasurement::PcmDataCarried, NSMutableURLRequest *) { }
</del><span class="cx"> static void overrideAttributionContext(NSMutableURLRequest *) { }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -347,9 +346,6 @@
</span><span class="cx"> 
</span><span class="cx">     overrideAttributionContext(mutableRequest.get());
</span><span class="cx"> 
</span><del>-    if (parameters.pcmDataCarried)
-        processPCMRequest(*parameters.pcmDataCarried, mutableRequest.get());
-
</del><span class="cx">     nsRequest = mutableRequest;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(APP_PRIVACY_REPORT)
</span></span></pre></div>
<a id="trunkSourceWebKitSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/SourcesCocoa.txt (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/SourcesCocoa.txt     2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/SourcesCocoa.txt        2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -41,6 +41,8 @@
</span><span class="cx"> NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm
</span><span class="cx"> NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm
</span><span class="cx"> 
</span><ins>+NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm
+
</ins><span class="cx"> NetworkProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm
</span><span class="cx"> 
</span><span class="cx"> NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm
</span></span></pre></div>
<a id="trunkSourceWebKitWebKitxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (282109 => 282110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj     2021-09-07 22:13:17 UTC (rev 282109)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj        2021-09-07 22:14:26 UTC (rev 282110)
</span><span class="lines">@@ -4555,6 +4555,7 @@
</span><span class="cx">          5CB930BF26E0542E0032B1C0 /* PrivateClickMeasurementClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementClient.h; sourceTree = "<group>"; };
</span><span class="cx">          5CB930C026E0542F0032B1C0 /* PrivateClickMeasurementClientImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementClientImpl.cpp; sourceTree = "<group>"; };
</span><span class="cx">          5CB930C126E054B80032B1C0 /* PrivateClickMeasurementClientImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementClientImpl.h; sourceTree = "<group>"; };
</span><ins>+               5CB930F226E7EEE00032B1C0 /* PrivateClickMeasurementNetworkLoaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateClickMeasurementNetworkLoaderCocoa.mm; sourceTree = "<group>"; };
</ins><span class="cx">           5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; };
</span><span class="cx">          5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          5CBE908F26D7FB62005A2E95 /* PrivateClickMeasurementDebugInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDebugInfo.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -9260,6 +9261,7 @@
</span><span class="cx">          5C01BC3526D46AD400FEB42F /* PrivateClickMeasurement */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><ins>+                               5CB930F126E7EE890032B1C0 /* cocoa */,
</ins><span class="cx">                           5CB930BF26E0542E0032B1C0 /* PrivateClickMeasurementClient.h */,
</span><span class="cx">                          5CB930C026E0542F0032B1C0 /* PrivateClickMeasurementClientImpl.cpp */,
</span><span class="cx">                          5CB930C126E054B80032B1C0 /* PrivateClickMeasurementClientImpl.h */,
</span><span class="lines">@@ -9353,6 +9355,14 @@
</span><span class="cx">                  path = Cocoa;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="cx">          };
</span><ins>+               5CB930F126E7EE890032B1C0 /* cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               5CB930F226E7EEE00032B1C0 /* PrivateClickMeasurementNetworkLoaderCocoa.mm */,
+                       );
+                       path = cocoa;
+                       sourceTree = "<group>";
+               };
</ins><span class="cx">           6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span></span></pre>
</div>
</div>

</body>
</html>