[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

japhet at chromium.org japhet at chromium.org
Wed Dec 22 12:29:09 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit bc2130210d78f903dd97eac4009f1594ee815256
Author: japhet at chromium.org <japhet at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 24 17:26:13 2010 +0000

    2010-08-24  Nate Chapin  <japhet at chromium.org>
    
            Reviewed by David Levin.
    
            Allow image loads triggered from unload handlers to run entirely
            independently of any other loads or navigations.
    
            https://bugs.webkit.org/show_bug.cgi?id=30457
    
            Test: http/tests/navigation/image-load-in-unload-handler.html
    
            * Android.mk:
            * CMakeLists.txt:
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * loader/DocLoader.cpp:
            (WebCore::DocLoader::requestImage): Use PingLoader for image
                loads in unload handlers.
            * loader/FrameLoader.h:
            (WebCore::FrameLoader::pageDismissalEventBeingDispatched):
            * loader/PingLoader.cpp: Added.
            (WebCore::PingLoader::loadImage): Set the appropriate
                headers for an image load in unload handler (since we're
                not using SubresourceLoader, we need to do this manually here).
            (WebCore::PingLoader::PingLoader):
            * loader/PingLoader.h: Added.
            (WebCore::PingLoader::~PingLoader):
            (WebCore::PingLoader::didReceiveResponse):
            (WebCore::PingLoader::didReceiveData):
            (WebCore::PingLoader::didFinishLoading):
            (WebCore::PingLoader::didFail):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65910 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7841be5..7787f56 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-24  Nate Chapin  <japhet at chromium.org>
+
+        Reviewed by David Levin.
+
+        Test for https://bugs.webkit.org/show_bug.cgi?id=30457.
+
+        * http/tests/navigation/image-load-in-unload-handler-expected.txt: Added.
+        * http/tests/navigation/image-load-in-unload-handler.html: Added.
+        * http/tests/navigation/resources/check-ping.php: Added.
+        * http/tests/navigation/resources/delete-ping.php: Added.
+        * http/tests/navigation/resources/save-ping.php: Added.
+
 2010-08-24  Pavel Feldman  <pfeldman at chromium.org>
 
         Not reviewed: fix new inspector test expectation.
diff --git a/LayoutTests/fast/loader/unload-form-about-blank-expected.txt b/LayoutTests/http/tests/navigation/image-load-in-unload-handler-expected.txt
similarity index 100%
copy from LayoutTests/fast/loader/unload-form-about-blank-expected.txt
copy to LayoutTests/http/tests/navigation/image-load-in-unload-handler-expected.txt
diff --git a/LayoutTests/http/tests/navigation/image-load-in-unload-handler.html b/LayoutTests/http/tests/navigation/image-load-in-unload-handler.html
new file mode 100644
index 0000000..cebd258
--- /dev/null
+++ b/LayoutTests/http/tests/navigation/image-load-in-unload-handler.html
@@ -0,0 +1,35 @@
+<html><head>
+<title>Image load in unload handler</title>
+<script>
+
+var testCalled = false;
+
+function test() {
+    if (!testCalled) {
+        if (window.layoutTestController) {
+            layoutTestController.dumpAsText();
+            layoutTestController.waitUntilDone();
+        }
+        testCalled = true;
+        return;
+    }
+    location.assign("resources/check-ping.php");
+}
+
+function ping() {
+    var img = new Image(1, 1);
+    img.src = "resources/save-ping.php";
+}
+
+</script>
+</head>
+<body onload="test();" onunload="ping();">
+<img src="resources/delete-ping.php" onload="test();" onerror="test();"></img>
+Test case for https://bugs.webkit.org/show_bug.cgi?id=30457. Previously, if an image<br>
+load was trigger from an unload handler, we would kill it almost immediately due to the<br>
+navigation stopping all loaders. These loads now happen entirely in the background and detached<br>
+from the DOM, so they're invisible to the normal resource load callback infrastructure. We generate a<br>
+timestamp, then in the unload handler, we load an 'image' (actually a php script) that takes the<br>
+timestamp as a parameter and saves it to a file.  The destination page is a php script that checks for<br>
+the existence of that file and passes the test if the file contains the expected timestamp.<br>
+</body></html>
diff --git a/LayoutTests/http/tests/navigation/resources/check-ping.php b/LayoutTests/http/tests/navigation/resources/check-ping.php
new file mode 100644
index 0000000..a9b5979
--- /dev/null
+++ b/LayoutTests/http/tests/navigation/resources/check-ping.php
@@ -0,0 +1,18 @@
+<?php
+if (!file_exists("ping.txt")) {
+    $page = $_SERVER['PHP_SELF'];
+    // This refresh header is unfortunate, but if the file doesn't
+    // exist when this php script starts running, it won't notice
+    // its creation even if we sleep and check again.
+    header("Refresh: 1; url=$page");
+    return;
+}
+
+unlink("ping.txt");
+
+echo "PASS\n";
+echo "<script>\n";
+echo "if (window.layoutTestController)\n";
+echo "    layoutTestController.notifyDone();\n";
+echo "</script>";
+?>
diff --git a/LayoutTests/http/tests/navigation/resources/delete-ping.php b/LayoutTests/http/tests/navigation/resources/delete-ping.php
new file mode 100644
index 0000000..c3a0fdc
--- /dev/null
+++ b/LayoutTests/http/tests/navigation/resources/delete-ping.php
@@ -0,0 +1,3 @@
+<?php
+unlink("ping.txt");
+?>
diff --git a/LayoutTests/http/tests/navigation/resources/save-ping.php b/LayoutTests/http/tests/navigation/resources/save-ping.php
new file mode 100644
index 0000000..9446d47
--- /dev/null
+++ b/LayoutTests/http/tests/navigation/resources/save-ping.php
@@ -0,0 +1,4 @@
+<?php
+$pingFile = fopen("ping.txt", 'w');
+fclose($pingFile);
+?>
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index 19dbed0..8494346 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -326,6 +326,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
 	loader/MediaDocument.cpp \
 	loader/NavigationAction.cpp \
 	loader/NetscapePlugInStreamLoader.cpp \
+	loader/PingLoader.cpp \
 	loader/PlaceholderDocument.cpp \
 	loader/PluginDocument.cpp \
 	loader/PolicyCallback.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 33baf13..a9fd3a7 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1111,6 +1111,7 @@ SET(WebCore_SOURCES
     loader/MediaDocument.cpp
     loader/NavigationAction.cpp
     loader/NetscapePlugInStreamLoader.cpp
+    loader/PingLoader.cpp
     loader/PlaceholderDocument.cpp
     loader/PluginDocument.cpp
     loader/PolicyCallback.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index dc12588..c722fad 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2010-08-24  Nate Chapin  <japhet at chromium.org>
+
+        Reviewed by David Levin.
+
+        Allow image loads triggered from unload handlers to run entirely
+        independently of any other loads or navigations.
+
+        https://bugs.webkit.org/show_bug.cgi?id=30457
+
+        Test: http/tests/navigation/image-load-in-unload-handler.html
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/DocLoader.cpp:
+        (WebCore::DocLoader::requestImage): Use PingLoader for image
+            loads in unload handlers.
+        * loader/FrameLoader.h:
+        (WebCore::FrameLoader::pageDismissalEventBeingDispatched):
+        * loader/PingLoader.cpp: Added.
+        (WebCore::PingLoader::loadImage): Set the appropriate
+            headers for an image load in unload handler (since we're
+            not using SubresourceLoader, we need to do this manually here).
+        (WebCore::PingLoader::PingLoader):
+        * loader/PingLoader.h: Added.
+        (WebCore::PingLoader::~PingLoader):
+        (WebCore::PingLoader::didReceiveResponse):
+        (WebCore::PingLoader::didReceiveData):
+        (WebCore::PingLoader::didFinishLoading):
+        (WebCore::PingLoader::didFail):
+
 2010-08-24  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 6b7d31d..2f05367 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1710,6 +1710,8 @@ webcore_sources += \
 	WebCore/loader/NavigationAction.h \
 	WebCore/loader/NetscapePlugInStreamLoader.cpp \
 	WebCore/loader/NetscapePlugInStreamLoader.h \
+	WebCore/loader/PingLoader.cpp \
+	WebCore/loader/PingLoader.h \
 	WebCore/loader/PlaceholderDocument.cpp \
 	WebCore/loader/PlaceholderDocument.h \
 	WebCore/loader/PluginDocument.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index d24b5c8..9fd8ce6 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1895,6 +1895,8 @@
             'loader/NavigationAction.h',
             'loader/NetscapePlugInStreamLoader.cpp',
             'loader/NetscapePlugInStreamLoader.h',
+            'loader/PingLoader.cpp',
+            'loader/PingLoader.h',
             'loader/PlaceholderDocument.cpp',
             'loader/PlaceholderDocument.h',
             'loader/PluginDocument.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index ffc679a..7b5a69a 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -802,6 +802,7 @@ SOURCES += \
     loader/MediaDocument.cpp \
     loader/NavigationAction.cpp \
     loader/NetscapePlugInStreamLoader.cpp \
+    loader/PingLoader.cpp \
     loader/PlaceholderDocument.cpp \
     loader/PluginDocument.cpp \
     loader/PolicyCallback.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 0799750..e53ed03 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -23653,6 +23653,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\loader\PingLoader.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\loader\PingLoader.h"
+				>
+			</File>
+			<File
 				RelativePath="..\loader\PlaceholderDocument.cpp"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index c27a8b5..e978db8 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -5133,6 +5133,8 @@
 		D086FE9909D53AAB005BC74D /* UnlinkCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D086FE9709D53AAB005BC74D /* UnlinkCommand.cpp */; };
 		D0B0556809C6700100307E43 /* CreateLinkCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = D0B0556609C6700100307E43 /* CreateLinkCommand.h */; };
 		D0B0556909C6700100307E43 /* CreateLinkCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */; };
+		D0FF2A5D11F8C45A007E74E0 /* PingLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */; };
+		D0FF2A5E11F8C45A007E74E0 /* PingLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */; };
 		D23CA55D0AB0EAAE005108A5 /* JSRangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA55C0AB0EAAE005108A5 /* JSRangeException.h */; };
 		D23CA55F0AB0EAB6005108A5 /* JSRangeException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */; };
 		D23CA56C0AB0EB8D005108A5 /* RangeException.h in Headers */ = {isa = PBXBuildFile; fileRef = D23CA56B0AB0EB8D005108A5 /* RangeException.h */; };
@@ -10955,6 +10957,8 @@
 		D086FE9709D53AAB005BC74D /* UnlinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkCommand.cpp; sourceTree = "<group>"; };
 		D0B0556609C6700100307E43 /* CreateLinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateLinkCommand.h; sourceTree = "<group>"; };
 		D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreateLinkCommand.cpp; sourceTree = "<group>"; };
+		D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PingLoader.cpp; sourceTree = "<group>"; };
+		D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PingLoader.h; sourceTree = "<group>"; };
 		D23CA5480AB0E983005108A5 /* RangeException.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = RangeException.idl; sourceTree = "<group>"; };
 		D23CA55C0AB0EAAE005108A5 /* JSRangeException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSRangeException.h; sourceTree = "<group>"; };
 		D23CA55E0AB0EAB6005108A5 /* JSRangeException.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSRangeException.cpp; sourceTree = "<group>"; };
@@ -16492,6 +16496,8 @@
 				93CCF0260AF6C52900018E89 /* NavigationAction.h */,
 				93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */,
 				656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */,
+				D0FF2A5B11F8C45A007E74E0 /* PingLoader.cpp */,
+				D0FF2A5C11F8C45A007E74E0 /* PingLoader.h */,
 				377C4CDE1014E9F600B9AE42 /* PlaceholderDocument.cpp */,
 				377C4CDD1014E9F600B9AE42 /* PlaceholderDocument.h */,
 				1AC694C50A3B1676003F5049 /* PluginDocument.cpp */,
@@ -20324,6 +20330,7 @@
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
 				CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
+				D0FF2A5E11F8C45A007E74E0 /* PingLoader.h in Headers */,
 				C50B561712119D23008B46E0 /* GroupSettings.h in Headers */,
 				BCA979171215D055005C485C /* ImageBufferData.h in Headers */,
 				490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */,
@@ -22788,6 +22795,7 @@
 				93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
+				D0FF2A5D11F8C45A007E74E0 /* PingLoader.cpp in Sources */,
 				C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */,
 				490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
 				899ABC261215E4A300F9F219 /* DirectoryEntry.cpp in Sources */,
diff --git a/WebCore/loader/DocLoader.cpp b/WebCore/loader/DocLoader.cpp
index 2f75ff9..bc102d1 100644
--- a/WebCore/loader/DocLoader.cpp
+++ b/WebCore/loader/DocLoader.cpp
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "DocLoader.h"
 
+#include "loader.h"
 #include "Cache.h"
 #include "CachedCSSStyleSheet.h"
 #include "CachedFont.h"
@@ -40,7 +41,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
-#include "loader.h"
+#include "PingLoader.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
 #include <wtf/text/CString.h>
@@ -125,6 +126,13 @@ CachedImage* DocLoader::requestImage(const String& url)
         Settings* settings = f->settings();
         if (!f->loader()->client()->allowImages(!settings || settings->areImagesEnabled()))
             return 0;
+
+        if (f->loader()->pageDismissalEventBeingDispatched()) {
+            KURL completeURL = m_doc->completeURL(url);
+            if (completeURL.isValid() && canRequest(CachedResource::ImageResource, completeURL))
+                PingLoader::loadImage(f, completeURL);
+            return 0;
+        }
     }
     CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, url, String()));
     if (autoLoadImages() && resource && resource->stillNeedsLoad()) {
diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h
index 2686e34..5adcf41 100644
--- a/WebCore/loader/FrameLoader.h
+++ b/WebCore/loader/FrameLoader.h
@@ -329,6 +329,8 @@ public:
     
     void started();
 
+    bool pageDismissalEventBeingDispatched() const { return m_pageDismissalEventBeingDispatched; }
+
 private:
     bool canCachePageContainingThisFrame();
 #ifndef NDEBUG
diff --git a/WebCore/loader/PingLoader.cpp b/WebCore/loader/PingLoader.cpp
new file mode 100644
index 0000000..7e727a1
--- /dev/null
+++ b/WebCore/loader/PingLoader.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER 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.
+ *
+ */
+
+#include "config.h"
+#include "PingLoader.h"
+
+#include "Frame.h"
+#include "ResourceHandle.h"
+#include "SecurityOrigin.h"
+#include <wtf/OwnPtr.h>
+
+namespace WebCore {
+
+void PingLoader::loadImage(Frame* frame, const KURL& url)
+{
+    if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canLoad(url, String(), frame->document())) {
+        FrameLoader::reportLocalLoadFailed(frame, url);
+        return;
+    }
+
+    ResourceRequest request(url);
+    request.setTargetType(ResourceRequest::TargetIsImage);
+    request.setHTTPHeaderField("Cache-Control", "max-age=0");
+    if (!SecurityOrigin::shouldHideReferrer(request.url(), frame->loader()->outgoingReferrer()))
+        request.setHTTPReferrer(frame->loader()->outgoingReferrer());
+    frame->loader()->addExtraFieldsToSubresourceRequest(request);
+    OwnPtr<PingLoader> pingLoader(new PingLoader(frame, request));
+    
+    // Leak the ping loader, since it will kill itself as soon as it receives a response.
+    PingLoader* leakedPingLoader = pingLoader.leakPtr();
+    UNUSED_PARAM(leakedPingLoader);
+}
+
+PingLoader::PingLoader(Frame* frame, const ResourceRequest& request)
+{
+    m_handle = ResourceHandle::create(request, this, frame, false, false);
+}
+
+PingLoader::~PingLoader()
+{
+    m_handle->cancel();
+}
+
+}
diff --git a/WebCore/loader/PingLoader.h b/WebCore/loader/PingLoader.h
new file mode 100644
index 0000000..1d8a2d8
--- /dev/null
+++ b/WebCore/loader/PingLoader.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER 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 PingLoader_h
+#define PingLoader_h
+
+#include "ResourceHandleClient.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+class KURL;
+class ResourceError;
+class ResourceHandle;
+class ResourceResponse;
+
+// 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, public Noncopyable {
+public:
+    static void loadImage(Frame*, const KURL& url);
+
+    ~PingLoader();
+
+private:
+    PingLoader(Frame*, const ResourceRequest&);
+
+    void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { delete this; }
+    void didReceiveData(ResourceHandle*, const char*, int) { delete this; }
+    void didFinishLoading(ResourceHandle*) { delete this; }
+    void didFail(ResourceHandle*, const ResourceError&) { delete this; }
+
+    RefPtr<ResourceHandle> m_handle;
+};
+
+}
+
+#endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list