Move PingLoaders to the NetworkingProcess.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jul 2015 22:53:41 +0000 (22:53 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Jul 2015 22:53:41 +0000 (22:53 +0000)
<rdar://problem/18860263> and https://bugs.webkit.org/show_bug.cgi?id=146710

Reviewed by Tim Horton.

Source/WebCore:

No new tests.
There's no current solution for communicating back to a page that a ping load has reached its target.
Until we have such a solution, any attempt at a layout test will be fragile at best.

* WebCore.xcodeproj/project.pbxproj:

* loader/LoaderStrategy.cpp:
(WebCore::LoaderStrategy::createPingHandle): Default implementation is create the PingHandle directly.
* loader/LoaderStrategy.h:

PingLoader becomes a static class for now that crafts the ResourceRequest then passes it off
to the LoaderStrategy:
* loader/PingLoader.cpp:
(WebCore::PingLoader::loadImage):
(WebCore::PingLoader::sendPing):
(WebCore::PingLoader::sendViolationReport):
(WebCore::PingLoader::startPingLoad):
(WebCore::PingLoader::createPingLoader): Deleted.
(WebCore::PingLoader::PingLoader): Deleted.
(WebCore::PingLoader::~PingLoader): Deleted.
* loader/PingLoader.h:
(WebCore::PingLoader::timeoutTimerFired): Deleted.

PingHandle does what PingLoader used to - It's a basic ResourceHandleClient that simply waits
for any response/completion/failure and then deletes itself.
* platform/network/PingHandle.h: Added.
(WebCore::PingHandle::PingHandle):
(WebCore::PingHandle::usesAsyncCallbacks):
(WebCore::PingHandle::timeoutTimerFired):
(WebCore::PingHandle::~PingHandle):

Source/WebKit2:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::loadPing): Create a PingHandle and then return.
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::createPingHandle): If the Network process is enabled,
  compile the appropriate load parameters and then message to it.
  Otherwise, use the default in-process PingHandle.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186530 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/LoaderStrategy.cpp
Source/WebCore/loader/LoaderStrategy.h
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/PingLoader.h
Source/WebCore/platform/network/PingHandle.h [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h

index 35c14fa..a5ff4d9 100644 (file)
@@ -1,3 +1,41 @@
+2015-07-08  Brady Eidson  <beidson@apple.com>
+
+        Move PingLoaders to the NetworkingProcess.
+        <rdar://problem/18860263> and https://bugs.webkit.org/show_bug.cgi?id=146710
+
+        Reviewed by Tim Horton.
+
+        No new tests.
+        There's no current solution for communicating back to a page that a ping load has reached its target.
+        Until we have such a solution, any attempt at a layout test will be fragile at best.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        
+        * loader/LoaderStrategy.cpp:
+        (WebCore::LoaderStrategy::createPingHandle): Default implementation is create the PingHandle directly.
+        * loader/LoaderStrategy.h:
+
+        PingLoader becomes a static class for now that crafts the ResourceRequest then passes it off
+        to the LoaderStrategy:        
+        * loader/PingLoader.cpp:
+        (WebCore::PingLoader::loadImage):
+        (WebCore::PingLoader::sendPing):
+        (WebCore::PingLoader::sendViolationReport):
+        (WebCore::PingLoader::startPingLoad):
+        (WebCore::PingLoader::createPingLoader): Deleted.
+        (WebCore::PingLoader::PingLoader): Deleted.
+        (WebCore::PingLoader::~PingLoader): Deleted.
+        * loader/PingLoader.h:
+        (WebCore::PingLoader::timeoutTimerFired): Deleted.
+
+        PingHandle does what PingLoader used to - It's a basic ResourceHandleClient that simply waits
+        for any response/completion/failure and then deletes itself.
+        * platform/network/PingHandle.h: Added.
+        (WebCore::PingHandle::PingHandle):
+        (WebCore::PingHandle::usesAsyncCallbacks):
+        (WebCore::PingHandle::timeoutTimerFired):
+        (WebCore::PingHandle::~PingHandle):
+
 2015-07-08  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Add new sources to StyleAllInOne.cpp
index 6d4ddc9..1c85a7a 100644 (file)
                51AF503616F100F60095B2E8 /* ResourceLoaderTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51B07A441823248B00AA8D1A /* IDBPendingDeleteCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51B2417B0D931F3F00E83F5C /* LegacyWebArchiveMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */; };
+               51B454EA1B4DAE7D0085EAA6 /* PingHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B454E91B4DAE7D0085EAA6 /* PingHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51B45D201AB8D1E200117CD2 /* ContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */; };
                51B45D211AB8D1E200117CD2 /* ContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51B58FD4195A964D002990B0 /* PlatformGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E5FEF195101470086CA5E /* PlatformGamepad.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderTypes.h; sourceTree = "<group>"; };
                51B07A431823248B00AA8D1A /* IDBPendingDeleteCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBPendingDeleteCall.h; sourceTree = "<group>"; };
                51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; };
+               51B454E91B4DAE7D0085EAA6 /* PingHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PingHandle.h; sourceTree = "<group>"; };
                51B45D1E1AB8D1E200117CD2 /* ContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtension.cpp; sourceTree = "<group>"; };
                51B45D1F1AB8D1E200117CD2 /* ContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentExtension.h; sourceTree = "<group>"; };
                51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = "<group>"; };
                                E13EF3421684ECF40034C83F /* NetworkStorageSession.h */,
                                447958021643B47B001E0A7F /* ParsedContentType.cpp */,
                                447958031643B47B001E0A7F /* ParsedContentType.h */,
+                               51B454E91B4DAE7D0085EAA6 /* PingHandle.h */,
                                E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */,
                                37BAAE571980D1DD005DFE71 /* ProtectionSpace.h */,
                                514C765F0CE923A1007EF3CD /* ProtectionSpaceBase.cpp */,
                                8AA61CFD144D595B00F37350 /* WebKitCSSRegionRule.cpp */,
                                8AA61CFE144D595B00F37350 /* WebKitCSSRegionRule.h */,
                                8AD0A55614C87425000D83C5 /* WebKitCSSRegionRule.idl */,
-                               6C6CCAAE19DC42B90043D5DB /* WebKitCSSResourceValue.cpp */,
-                               6C6CCAAF19DC42B90043D5DB /* WebKitCSSResourceValue.h */,
                                BC9ADD7F0CC4092200098C4C /* WebKitCSSTransformValue.cpp */,
                                BC9ADD220CC4032600098C4C /* WebKitCSSTransformValue.h */,
                                31611E540E1C4D4A00F6A579 /* WebKitCSSTransformValue.idl */,
                                FDF7E9C413AC21DB00A51EAC /* JSAudioBufferCallback.h in Headers */,
                                FDA15EA012B03EE1003A583A /* JSAudioBufferSourceNode.h in Headers */,
                                FDA15EA612B03EE1003A583A /* JSAudioContext.h in Headers */,
+                               51B454EA1B4DAE7D0085EAA6 /* PingHandle.h in Headers */,
                                FDA15EA812B03EE1003A583A /* JSAudioDestinationNode.h in Headers */,
                                FDA15EAE12B03EE1003A583A /* JSAudioListener.h in Headers */,
                                FDA15EB012B03EE1003A583A /* JSAudioNode.h in Headers */,
                                93309DF8099E64920056E581 /* markup.h in Headers */,
                                9728C3141268E4390041E89B /* MarkupAccumulator.h in Headers */,
                                00C60E3F13D76D7E0092A275 /* MarkupTokenizerInlines.h in Headers */,
-                               6C568CB119DAFEA000430CA2 /* MaskImageOperation.h in Headers */,
                                FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */,
                                44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */,
                                FABE72F71059C1EB00D999DD /* MathMLInlineContainerElement.h in Headers */,
                                0F580CFF0F12DE9B0051D689 /* RenderLayerBacking.h in Headers */,
                                0F580CFD0F12DE9B0051D689 /* RenderLayerCompositor.h in Headers */,
                                50D10D9A1545F5760096D288 /* RenderLayerFilterInfo.h in Headers */,
-                               6CBFE4A519EBF2D400CA2F9D /* RenderLayerMaskImageInfo.h in Headers */,
                                3C244FEAA375AC633F88BE6F /* RenderLayerModelObject.h in Headers */,
                                0BE030A20F3112FB003C1A46 /* RenderLineBoxList.h in Headers */,
                                BCEA4864097D93020094C9E4 /* RenderLineBreak.h in Headers */,
                                3106037014327D2E00ABF4BA /* WebKitCSSFilterValue.h in Headers */,
                                498391590F1E776900C23782 /* WebKitCSSMatrix.h in Headers */,
                                8AA61D00144D595B00F37350 /* WebKitCSSRegionRule.h in Headers */,
-                               6C6CCAB119DC42B90043D5DB /* WebKitCSSResourceValue.h in Headers */,
                                BC9ADD230CC4032600098C4C /* WebKitCSSTransformValue.h in Headers */,
                                3FFFF9A9159D9A550020BBD5 /* WebKitCSSViewportRule.h in Headers */,
                                7C48A6D1191C9D6500026674 /* WebKitNamespace.h in Headers */,
                                1A8F6BC50DB55CDC001DB794 /* ManifestParser.cpp in Sources */,
                                93309DF7099E64920056E581 /* markup.cpp in Sources */,
                                9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
-                               6C568CB019DAFEA000430CA2 /* MaskImageOperation.cpp in Sources */,
                                FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */,
                                FABE72FD1059C21100D999DD /* MathMLElementFactory.cpp in Sources */,
                                FABE72F61059C1EB00D999DD /* MathMLInlineContainerElement.cpp in Sources */,
                                3106036F14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp in Sources */,
                                498391580F1E776900C23782 /* WebKitCSSMatrix.cpp in Sources */,
                                8AA61CFF144D595B00F37350 /* WebKitCSSRegionRule.cpp in Sources */,
-                               6C6CCAB019DC42B90043D5DB /* WebKitCSSResourceValue.cpp in Sources */,
                                BC9ADD800CC4092200098C4C /* WebKitCSSTransformValue.cpp in Sources */,
                                3FFFF9A8159D9A550020BBD5 /* WebKitCSSViewportRule.cpp in Sources */,
                                1A1414B513A0F0500019996C /* WebKitFontFamilyNames.cpp in Sources */,
index 899fd52..4bb89c8 100644 (file)
@@ -27,6 +27,7 @@
 #include "LoaderStrategy.h"
 
 #include "BlobRegistryImpl.h"
+#include "PingHandle.h"
 #include "ResourceHandle.h"
 #include "ResourceLoadScheduler.h"
 
@@ -47,4 +48,10 @@ BlobRegistry* LoaderStrategy::createBlobRegistry()
     return new BlobRegistryImpl;
 }
 
+void LoaderStrategy::createPingHandle(NetworkingContext* networkingContext, ResourceRequest& request, bool shouldUseCredentialStorage)
+{
+    // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled.
+    new PingHandle(networkingContext, request, shouldUseCredentialStorage, PingHandle::UsesAsyncCallbacks::No);
+}
+
 } // namespace WebCore
index 4b7e1fa..e1653a8 100644 (file)
@@ -32,6 +32,7 @@
 namespace WebCore {
 
 class BlobRegistry;
+class Frame;
 class NetworkingContext;
 class ResourceError;
 class ResourceLoadScheduler;
@@ -46,6 +47,8 @@ public:
 
     virtual BlobRegistry* createBlobRegistry();
 
+    virtual void createPingHandle(NetworkingContext*, ResourceRequest&, bool shouldUseCredentialStorage);
+
 protected:
     virtual ~LoaderStrategy()
     {
index 04a68b1..589c841 100644 (file)
@@ -39,7 +39,9 @@
 #include "FrameLoaderClient.h"
 #include "HTTPHeaderNames.h"
 #include "InspectorInstrumentation.h"
+#include "LoaderStrategy.h"
 #include "Page.h"
+#include "PlatformStrategies.h"
 #include "ProgressTracker.h"
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
@@ -64,7 +66,7 @@ void PingLoader::loadImage(Frame& frame, const URL& url)
         request.setHTTPReferrer(referrer);
     frame.loader().addExtraFieldsToSubresourceRequest(request);
 
-    createPingLoader(frame, request);
+    startPingLoad(frame, request);
 }
 
 // http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing
@@ -90,7 +92,7 @@ void PingLoader::sendPing(Frame& frame, const URL& pingURL, const URL& destinati
         }
     }
 
-    createPingLoader(frame, request);
+    startPingLoad(frame, request);
 }
 
 void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, PassRefPtr<FormData> report)
@@ -105,17 +107,10 @@ void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, PassRef
     if (!referrer.isEmpty())
         request.setHTTPReferrer(referrer);
 
-    createPingLoader(frame, request);
+    startPingLoad(frame, request);
 }
 
-void PingLoader::createPingLoader(Frame& frame, ResourceRequest& request)
-{
-    // No need to free the PingLoader object or manage it via a smart pointer - it will kill itself as soon as it receives a response.
-    new PingLoader(frame, request);
-}
-
-PingLoader::PingLoader(Frame& frame, ResourceRequest& request)
-    : m_timeout(*this, &PingLoader::timeoutTimerFired)
+void PingLoader::startPingLoad(Frame& frame, ResourceRequest& request)
 {
     unsigned long identifier = frame.page()->progress().createUniqueIdentifier();
     // FIXME: Why activeDocumentLoader? I would have expected documentLoader().
@@ -123,20 +118,11 @@ PingLoader::PingLoader(Frame& frame, ResourceRequest& request)
     // Document in the Frame, but the activeDocumentLoader will be associated
     // with the provisional DocumentLoader if there is a provisional
     // DocumentLoader.
-    m_shouldUseCredentialStorage = frame.loader().client().shouldUseCredentialStorage(frame.loader().activeDocumentLoader(), identifier);
-    m_handle = ResourceHandle::create(frame.loader().networkingContext(), request, this, false, false);
+    bool shouldUseCredentialStorage = frame.loader().client().shouldUseCredentialStorage(frame.loader().activeDocumentLoader(), identifier);
 
     InspectorInstrumentation::continueAfterPingLoader(frame, identifier, frame.loader().activeDocumentLoader(), request, ResourceResponse());
 
-    // If the server never responds, FrameLoader won't be able to cancel this load and
-    // we'll sit here waiting forever. Set a very generous timeout, just in case.
-    m_timeout.startOneShot(60000);
-}
-
-PingLoader::~PingLoader()
-{
-    if (m_handle)
-        m_handle->cancel();
+    platformStrategies()->loaderStrategy()->createPingHandle(frame.loader().networkingContext(), request, shouldUseCredentialStorage);
 }
 
 }
index 515d97d..045de12 100644 (file)
 #ifndef PingLoader_h
 #define PingLoader_h
 
-#include "ResourceHandleClient.h"
-#include "Timer.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
+#include <wtf/PassRefPtr.h>
 
 namespace WebCore {
 
 class FormData;
 class Frame;
 class URL;
-class ResourceError;
-class ResourceHandle;
-class ResourceResponse;
+class ResourceRequest;
 
-// This class triggers asynchronous loads independent of Frame staying alive (i.e., auditing pingbacks).
-// Since nothing depends on resources loaded through this class, we just want
-// to allow the load to live long enough to ensure the message was actually sent.
-// Therefore, as soon as a callback is received from the ResourceHandle, this class 
-// will cancel the load and delete itself.
-class PingLoader : private ResourceHandleClient {
-    WTF_MAKE_NONCOPYABLE(PingLoader); WTF_MAKE_FAST_ALLOCATED;
+class PingLoader {
 public:
     static void loadImage(Frame&, const URL&);
     static void sendPing(Frame&, const URL& pingURL, const URL& destinationURL);
     static void sendViolationReport(Frame&, const URL& reportURL, PassRefPtr<FormData> report);
 
-    virtual ~PingLoader();
-
 private:
-    static void createPingLoader(Frame&, ResourceRequest&);
-    PingLoader(Frame&, ResourceRequest&);
-
-    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override { delete this; }
-    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int) override { delete this; }
-    virtual void didFinishLoading(ResourceHandle*, double) override { delete this; }
-    virtual void didFail(ResourceHandle*, const ResourceError&) override { delete this; }
-    virtual bool shouldUseCredentialStorage(ResourceHandle*)  override { return m_shouldUseCredentialStorage; }
-    void timeoutTimerFired() { delete this; }
-
-    RefPtr<ResourceHandle> m_handle;
-    Timer m_timeout;
-    bool m_shouldUseCredentialStorage;
+    static void startPingLoad(Frame&, ResourceRequest&);
 };
 
 }
diff --git a/Source/WebCore/platform/network/PingHandle.h b/Source/WebCore/platform/network/PingHandle.h
new file mode 100644 (file)
index 0000000..c2d00aa
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2015 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. ``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
+ * 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 PingHandle_h
+#define PingHandle_h
+
+#include "ResourceHandle.h"
+#include "ResourceHandleClient.h"
+#include "Timer.h"
+
+namespace WebCore {
+
+// This class triggers asynchronous loads independent of the networking context staying alive (i.e., auditing pingbacks).
+// The object just needs to live long enough to ensure the message was actually sent.
+// As soon as any callback is received from the ResourceHandle, this class will cancel the load and delete itself.
+
+class PingHandle : private ResourceHandleClient {
+    WTF_MAKE_NONCOPYABLE(PingHandle); WTF_MAKE_FAST_ALLOCATED;
+public:
+    enum class UsesAsyncCallbacks {
+        Yes,
+        No,
+    };
+    
+    PingHandle(NetworkingContext* networkingContext, const ResourceRequest& request, bool shouldUseCredentialStorage, UsesAsyncCallbacks useAsyncCallbacks)
+        : m_timeoutTimer(*this, &PingHandle::timeoutTimerFired)
+        , m_shouldUseCredentialStorage(shouldUseCredentialStorage)
+        , m_usesAsyncCallbacks(useAsyncCallbacks)
+    {
+        m_handle = ResourceHandle::create(networkingContext, request, this, false, false);
+
+        // If the server never responds, this object will hang around forever.
+        // Set a very generous timeout, just in case.
+        m_timeoutTimer.startOneShot(60000);
+    }
+
+private:
+    virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override { delete this; }
+    virtual void didReceiveData(ResourceHandle*, const char*, unsigned, int) override { delete this; }
+    virtual void didFinishLoading(ResourceHandle*, double) override { delete this; }
+    virtual void didFail(ResourceHandle*, const ResourceError&) override { delete this; }
+    virtual bool shouldUseCredentialStorage(ResourceHandle*)  override { return m_shouldUseCredentialStorage; }
+    virtual bool usesAsyncCallbacks() override { return m_usesAsyncCallbacks == UsesAsyncCallbacks::Yes; }
+    void timeoutTimerFired() { delete this; }
+
+    virtual ~PingHandle()
+    {
+        if (m_handle)
+            m_handle->cancel();
+    }
+
+    RefPtr<ResourceHandle> m_handle;
+    Timer m_timeoutTimer;
+    bool m_shouldUseCredentialStorage;
+    UsesAsyncCallbacks m_usesAsyncCallbacks;
+};
+
+} // namespace WebCore
+
+#endif // PingHandle_h
index f64a790..ab6a450 100644 (file)
@@ -1,3 +1,21 @@
+2015-07-08  Brady Eidson  <beidson@apple.com>
+
+        Move PingLoaders to the NetworkingProcess.
+        <rdar://problem/18860263> and https://bugs.webkit.org/show_bug.cgi?id=146710
+
+        Reviewed by Tim Horton.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::loadPing): Create a PingHandle and then return.
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::createPingHandle): If the Network process is enabled,
+          compile the appropriate load parameters and then message to it.
+          Otherwise, use the default in-process PingHandle.
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2015-07-08  Beth Dakin  <bdakin@apple.com>
 
         Only support image previews for clients that implement commitPreviewedImageWithURL 
index 54de3c4..65ba2e7 100644 (file)
@@ -36,6 +36,7 @@
 #include "NetworkResourceLoaderMessages.h"
 #include "RemoteNetworkingContext.h"
 #include "SessionTracker.h"
+#include <WebCore/PingHandle.h>
 #include <WebCore/PlatformCookieJar.h>
 #include <WebCore/ResourceLoaderOptions.h>
 #include <WebCore/ResourceRequest.h>
@@ -126,6 +127,14 @@ void NetworkConnectionToWebProcess::performSynchronousLoad(const NetworkResource
     loader->start();
 }
 
+void NetworkConnectionToWebProcess::loadPing(const NetworkResourceLoadParameters& loadParameters)
+{
+    RefPtr<NetworkingContext> context = RemoteNetworkingContext::create(loadParameters.sessionID, loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect);
+
+    // PingHandle manages its own lifetime, deleting itself when its purpose has been fulfilled.
+    new PingHandle(context.get(), loadParameters.request, loadParameters.allowStoredCredentials == AllowStoredCredentials, PingHandle::UsesAsyncCallbacks::Yes);
+}
+
 void NetworkConnectionToWebProcess::removeLoadIdentifier(ResourceLoadIdentifier identifier)
 {
     RefPtr<NetworkResourceLoader> loader = m_networkResourceLoaders.get(identifier);
index 32a3105..822de58 100644 (file)
@@ -72,6 +72,7 @@ private:
     
     void scheduleResourceLoad(const NetworkResourceLoadParameters&);
     void performSynchronousLoad(const NetworkResourceLoadParameters&, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>);
+    void loadPing(const NetworkResourceLoadParameters&);
 
     void removeLoadIdentifier(ResourceLoadIdentifier);
     void setDefersLoading(ResourceLoadIdentifier, bool);
index 03b3dd4..4c0a7ad 100644 (file)
@@ -26,6 +26,7 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver {
 
     ScheduleResourceLoad(WebKit::NetworkResourceLoadParameters resourceLoadParameters)
     PerformSynchronousLoad(WebKit::NetworkResourceLoadParameters resourceLoadParameters) -> (WebCore::ResourceError error, WebCore::ResourceResponse response, Vector<char> data) Delayed
+    LoadPing(WebKit::NetworkResourceLoadParameters resourceLoadParameters)
     RemoveLoadIdentifier(uint64_t resourceLoadIdentifier)
     SetDefersLoading(uint64_t resourceLoadIdentifier, bool defers)
 
index 0413930..ae4b657 100644 (file)
@@ -55,6 +55,7 @@
 #include <WebCore/PageGroup.h>
 #include <WebCore/PlatformCookieJar.h>
 #include <WebCore/PlatformPasteboard.h>
+#include <WebCore/ProgressTracker.h>
 #include <WebCore/ResourceError.h>
 #include <WebCore/SessionID.h>
 #include <WebCore/StorageNamespace.h>
@@ -248,6 +249,28 @@ void WebPlatformStrategies::loadResourceSynchronously(NetworkingContext* context
     }
 }
 
+void WebPlatformStrategies::createPingHandle(NetworkingContext* networkingContext, ResourceRequest& request, bool shouldUseCredentialStorage)
+{
+    auto& webProcess = WebProcess::singleton();
+    if (!webProcess.usesNetworkProcess()) {
+        LoaderStrategy::createPingHandle(networkingContext, request, shouldUseCredentialStorage);
+        return;
+    }
+
+    WebFrameNetworkingContext* webContext = static_cast<WebFrameNetworkingContext*>(networkingContext);
+    WebFrameLoaderClient* webFrameLoaderClient = webContext->webFrameLoaderClient();
+    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
+    WebPage* webPage = webFrame ? webFrame->page() : nullptr;
+    
+    NetworkResourceLoadParameters loadParameters;
+    loadParameters.request = request;
+    loadParameters.sessionID = webPage ? webPage->sessionID() : SessionID::defaultSessionID();
+    loadParameters.allowStoredCredentials = shouldUseCredentialStorage ? AllowStoredCredentials : DoNotAllowStoredCredentials;
+    loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = networkingContext->shouldClearReferrerOnHTTPSToHTTPRedirect();
+
+    webProcess.networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::LoadPing(loadParameters), 0);
+}
+
 BlobRegistry* WebPlatformStrategies::createBlobRegistry()
 {
     if (!WebProcess::singleton().usesNetworkProcess())
index 3b2fcb1..c5841aa 100644 (file)
@@ -63,6 +63,7 @@ private:
     virtual WebCore::ResourceLoadScheduler* resourceLoadScheduler() override;
     virtual void loadResourceSynchronously(WebCore::NetworkingContext*, unsigned long resourceLoadIdentifier, const WebCore::ResourceRequest&, WebCore::StoredCredentials, WebCore::ClientCredentialPolicy, WebCore::ResourceError&, WebCore::ResourceResponse&, Vector<char>& data) override;
     virtual WebCore::BlobRegistry* createBlobRegistry() override;
+    virtual void createPingHandle(WebCore::NetworkingContext*, WebCore::ResourceRequest&, bool shouldUseCredentialStorage) override;
 #endif
 
     // WebCore::PluginStrategy