<!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>[197568] trunk/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/197568">197568</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2016-03-04 10:01:37 -0800 (Fri, 04 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use NetworkSession for pings
https://bugs.webkit.org/show_bug.cgi?id=154984

Reviewed by Antti Koivisto.

Before this patch, we were using NSURLConnection for pings when the rest of the loading was being 
done with NSURLSession.  To fix this, I implemented PingLoad, which is the NetworkSession equivalent
of PingHandle.

This fixes http/tests/security/contentSecurityPolicy/report-status-code-zero-when-using-https.html

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::loadPing):
(WebKit::NetworkConnectionToWebProcess::removeLoadIdentifier):
* NetworkProcess/PingLoad.h: Added.
(WebKit::PingLoad::PingLoad):
(WebKit::PingLoad::willPerformHTTPRedirection):
(WebKit::PingLoad::didReceiveChallenge):
(WebKit::PingLoad::didReceiveResponseNetworkSession):
(WebKit::PingLoad::didReceiveData):
(WebKit::PingLoad::didCompleteWithError):
(WebKit::PingLoad::didBecomeDownload):
(WebKit::PingLoad::didSendData):
(WebKit::PingLoad::wasBlocked):
(WebKit::PingLoad::cannotShowURL):
(WebKit::PingLoad::timeoutTimerFired):
(WebKit::PingLoad::~PingLoad):
* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2NetworkProcessPingLoadh">trunk/Source/WebKit2/NetworkProcess/PingLoad.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (197567 => 197568)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-04 17:58:51 UTC (rev 197567)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-04 18:01:37 UTC (rev 197568)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-03-04  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Use NetworkSession for pings
+        https://bugs.webkit.org/show_bug.cgi?id=154984
+
+        Reviewed by Antti Koivisto.
+
+        Before this patch, we were using NSURLConnection for pings when the rest of the loading was being 
+        done with NSURLSession.  To fix this, I implemented PingLoad, which is the NetworkSession equivalent
+        of PingHandle.
+
+        This fixes http/tests/security/contentSecurityPolicy/report-status-code-zero-when-using-https.html
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::loadPing):
+        (WebKit::NetworkConnectionToWebProcess::removeLoadIdentifier):
+        * NetworkProcess/PingLoad.h: Added.
+        (WebKit::PingLoad::PingLoad):
+        (WebKit::PingLoad::willPerformHTTPRedirection):
+        (WebKit::PingLoad::didReceiveChallenge):
+        (WebKit::PingLoad::didReceiveResponseNetworkSession):
+        (WebKit::PingLoad::didReceiveData):
+        (WebKit::PingLoad::didCompleteWithError):
+        (WebKit::PingLoad::didBecomeDownload):
+        (WebKit::PingLoad::didSendData):
+        (WebKit::PingLoad::wasBlocked):
+        (WebKit::PingLoad::cannotShowURL):
+        (WebKit::PingLoad::timeoutTimerFired):
+        (WebKit::PingLoad::~PingLoad):
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2016-03-04  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Inform WebKit and WebCore if a page is controlled by automation.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (197567 => 197568)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp        2016-03-04 17:58:51 UTC (rev 197567)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp        2016-03-04 18:01:37 UTC (rev 197568)
</span><span class="lines">@@ -43,6 +43,10 @@
</span><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(NETWORK_SESSION)
+#include &quot;PingLoad.h&quot;
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -130,10 +134,15 @@
</span><span class="cx"> 
</span><span class="cx"> void NetworkConnectionToWebProcess::loadPing(const NetworkResourceLoadParameters&amp; loadParameters)
</span><span class="cx"> {
</span><ins>+#if USE(NETWORK_SESSION)
+    // PingLoad manages its own lifetime, deleting itself when its purpose has been fulfilled.
+    new PingLoad(loadParameters);
+#else
</ins><span class="cx">     RefPtr&lt;NetworkingContext&gt; context = RemoteNetworkingContext::create(loadParameters.sessionID, loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect);
</span><span class="cx"> 
</span><span class="cx">     // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled.
</span><span class="cx">     new PingHandle(context.get(), loadParameters.request, loadParameters.allowStoredCredentials == AllowStoredCredentials, PingHandle::UsesAsyncCallbacks::Yes);
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkConnectionToWebProcess::removeLoadIdentifier(ResourceLoadIdentifier identifier)
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessPingLoadh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/NetworkProcess/PingLoad.h (0 => 197568)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/PingLoad.h                                (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/PingLoad.h        2016-03-04 18:01:37 UTC (rev 197568)
</span><span class="lines">@@ -0,0 +1,87 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef PingLoad_h
+#define PingLoad_h
+
+#include &quot;NetworkDataTask.h&quot;
+#include &quot;SessionTracker.h&quot;
+
+namespace WebKit {
+
+class PingLoad : public NetworkDataTaskClient {
+public:
+    PingLoad(const NetworkResourceLoadParameters&amp; parameters)
+        : m_timeoutTimer(*this, &amp;PingLoad::timeoutTimerFired)
+    {
+        if (auto* networkSession = SessionTracker::networkSession(parameters.sessionID)) {
+            m_task = NetworkDataTask::create(*networkSession, *this, parameters.request, parameters.allowStoredCredentials, parameters.contentSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect);
+            m_task-&gt;resume();
+        } else
+            ASSERT_NOT_REACHED();
+
+        // If the server never responds, this object will hang around forever.
+        // Set a very generous timeout, just in case.
+        m_timeoutTimer.startOneShot(60000);
+    }
+    
+private:
+    void willPerformHTTPRedirection(const WebCore::ResourceResponse&amp;, const WebCore::ResourceRequest&amp;, RedirectCompletionHandler completionHandler) override
+    {
+        completionHandler({ });
+        delete this;
+    }
+    void didReceiveChallenge(const WebCore::AuthenticationChallenge&amp;, ChallengeCompletionHandler completionHandler) override
+    {
+        completionHandler(AuthenticationChallengeDisposition::Cancel, { });
+        delete this;
+    }
+    void didReceiveResponseNetworkSession(const WebCore::ResourceResponse&amp;, ResponseCompletionHandler completionHandler) override
+    {
+        completionHandler(WebCore::PolicyAction::PolicyIgnore);
+        delete this;
+    }
+    void didReceiveData(RefPtr&lt;WebCore::SharedBuffer&gt;&amp;&amp;)  override { ASSERT_NOT_REACHED(); }
+    void didCompleteWithError(const WebCore::ResourceError&amp;) override { delete this; }
+    void didBecomeDownload() override { ASSERT_NOT_REACHED(); }
+    void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) override { }
+    void wasBlocked() override { delete this; }
+    void cannotShowURL() override { delete this; }
+
+    void timeoutTimerFired() { delete this; }
+    
+    virtual ~PingLoad()
+    {
+        if (m_task)
+            m_task-&gt;cancel();
+    }
+    
+    RefPtr&lt;NetworkDataTask&gt; m_task;
+    WebCore::Timer m_timeoutTimer;
+};
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (197567 => 197568)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-03-04 17:58:51 UTC (rev 197567)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-03-04 18:01:37 UTC (rev 197568)
</span><span class="lines">@@ -1024,6 +1024,7 @@
</span><span class="cx">                 5C85C7881C3F23CE0061A4FA /* PendingDownload.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */; };
</span><span class="cx">                 5CBC9B8D1C65279C00A8FDCF /* NetworkDataTaskCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */; };
</span><span class="cx">                 5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
</span><ins>+                5CE85B201C88E64B0070BFCE /* PingLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE85B1F1C88E6430070BFCE /* PingLoad.h */; };
</ins><span class="cx">                 6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
</span><span class="cx">                 659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
</span><span class="cx">                 65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -3020,6 +3021,7 @@
</span><span class="cx">                 5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PendingDownload.cpp; path = NetworkProcess/Downloads/PendingDownload.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkDataTask.h; path = NetworkProcess/NetworkDataTask.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkDataTaskCocoa.mm; path = NetworkProcess/cocoa/NetworkDataTaskCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                5CE85B1F1C88E6430070BFCE /* PingLoad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingLoad.h; path = NetworkProcess/PingLoad.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5D442A5516D5856700AC3331 /* PluginService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PluginService.entitlements; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5184,6 +5186,7 @@
</span><span class="cx">                 510CC7DA16138E0100D03ED3 /* NetworkProcess */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5CE85B1F1C88E6430070BFCE /* PingLoad.h */,
</ins><span class="cx">                                 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */,
</span><span class="cx">                                 5C1426F21C23F82D00D41183 /* CustomProtocols */,
</span><span class="cx">                                 5C1426F11C23F81700D41183 /* Downloads */,
</span><span class="lines">@@ -7122,6 +7125,7 @@
</span><span class="cx">                                 2DEAC5CF1AC368BB00A195D8 /* _WKFindOptions.h in Headers */,
</span><span class="cx">                                 2E7A944A1BBD97C300945547 /* _WKFocusedElementInfo.h in Headers */,
</span><span class="cx">                                 2E0B8A7A1BC59A590044B32D /* _WKFormDelegate.h in Headers */,
</span><ins>+                                5CE85B201C88E64B0070BFCE /* PingLoad.h in Headers */,
</ins><span class="cx">                                 37A64E5718F38F4600EB30F1 /* _WKFormInputSession.h in Headers */,
</span><span class="cx">                                 373D122318A473010066D9CC /* _WKFrameHandle.h in Headers */,
</span><span class="cx">                                 373D122718A473F60066D9CC /* _WKFrameHandleInternal.h in Headers */,
</span></span></pre>
</div>
</div>

</body>
</html>