[iOS] Subresources referenced in converted QuickLook documents sometimes fail to...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Aug 2014 00:16:36 +0000 (00:16 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Aug 2014 00:16:36 +0000 (00:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135676

Reviewed by David Kilzer.

Source/WebCore:

* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setQuickLookHandle):
(WebCore::DocumentLoader::quickLookHandle):

Source/WebKit2:

QuickLookHandle needs to stay alive in order for its NSURLProtocol to service subresource loads originating
from the converted HTML document. Some of these loads happen dynamically after the main resource finishes
loading, so we cannot tie the lifetime of the QuickLookHandle to that of the main resource's ResourceLoader.
Instead, give ownership of the QuickLookHandle to DocumentLoader.

* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo): Stored the created QuickLookHandle in DocumentLoader.
(WebKit::WebResourceLoader::didReceiveData): Accessed DocumentLoader's QuickLookHandle.
(WebKit::WebResourceLoader::didFinishResourceLoad): Ditto.
(WebKit::WebResourceLoader::didFailResourceLoad): Ditto.
(WebKit::WebResourceLoader::didReceiveResource): Ditto.
* WebProcess/Network/WebResourceLoader.h: Removed m_quickLookHandle.

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

Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
Source/WebKit2/WebProcess/Network/WebResourceLoader.h

index c1c4820..067efa0 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-06  Andy Estes  <aestes@apple.com>
+
+        [iOS] Subresources referenced in converted QuickLook documents sometimes fail to load
+        https://bugs.webkit.org/show_bug.cgi?id=135676
+
+        Reviewed by David Kilzer.
+
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::setQuickLookHandle):
+        (WebCore::DocumentLoader::quickLookHandle):
+
 2014-08-06  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r168119): Album flipping animation doesn’t work
index 95abd7c..4e2a710 100644 (file)
 #include <wtf/RunLoopTimer.h>
 #endif
 
+#if USE(QUICK_LOOK)
+#include "QuickLook.h"
+#endif
+
 namespace WebCore {
 
     class ApplicationCacheHost;
@@ -259,6 +263,11 @@ namespace WebCore {
         // The URL of the document resulting from this DocumentLoader.
         URL documentURL() const;
 
+#if USE(QUICK_LOOK)
+        void setQuickLookHandle(std::unique_ptr<QuickLookHandle> quickLookHandle) { m_quickLookHandle = WTF::move(quickLookHandle); }
+        QuickLookHandle* quickLookHandle() const { return m_quickLookHandle.get(); }
+#endif
+
     protected:
         DocumentLoader(const ResourceRequest&, const SubstituteData&);
 
@@ -412,6 +421,10 @@ namespace WebCore {
 #if ENABLE(CONTENT_FILTERING)
         std::unique_ptr<ContentFilter> m_contentFilter;
 #endif
+
+#if USE(QUICK_LOOK)
+        std::unique_ptr<QuickLookHandle> m_quickLookHandle;
+#endif
     };
 
     inline void DocumentLoader::recordMemoryCacheLoadForFutureClientNotification(const ResourceRequest& request)
index c1ceada..cfd7ef4 100644 (file)
@@ -1,3 +1,23 @@
+2014-08-06  Andy Estes  <aestes@apple.com>
+
+        [iOS] Subresources referenced in converted QuickLook documents sometimes fail to load
+        https://bugs.webkit.org/show_bug.cgi?id=135676
+
+        Reviewed by David Kilzer.
+
+        QuickLookHandle needs to stay alive in order for its NSURLProtocol to service subresource loads originating
+        from the converted HTML document. Some of these loads happen dynamically after the main resource finishes
+        loading, so we cannot tie the lifetime of the QuickLookHandle to that of the main resource's ResourceLoader.
+        Instead, give ownership of the QuickLookHandle to DocumentLoader.
+
+        * WebProcess/Network/WebResourceLoader.cpp:
+        (WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo): Stored the created QuickLookHandle in DocumentLoader.
+        (WebKit::WebResourceLoader::didReceiveData): Accessed DocumentLoader's QuickLookHandle.
+        (WebKit::WebResourceLoader::didFinishResourceLoad): Ditto.
+        (WebKit::WebResourceLoader::didFailResourceLoad): Ditto.
+        (WebKit::WebResourceLoader::didReceiveResource): Ditto.
+        * WebProcess/Network/WebResourceLoader.h: Removed m_quickLookHandle.
+
 2014-08-06  Filip Pizlo  <fpizlo@apple.com>
 
         Merge r171389, r171495, r171508, r171510, r171605, r171606, r171611, r171614, r171763 from ftlopt.
index 6eb4684..c106e81 100644 (file)
@@ -125,8 +125,8 @@ void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResp
     // Refrain from calling didReceiveResponse if QuickLook will convert this response, since the MIME type of the
     // converted resource isn't yet known. WebResourceLoaderQuickLookDelegate will later call didReceiveResponse upon
     // receiving the converted data.
-    m_quickLookHandle = QuickLookHandle::create(resourceLoader(), responseCopy.nsURLResponse());
-    if (!m_quickLookHandle)
+    m_coreLoader->documentLoader()->setQuickLookHandle(QuickLookHandle::create(resourceLoader(), responseCopy.nsURLResponse()));
+    if (!m_coreLoader->documentLoader()->quickLookHandle())
 #endif
         m_coreLoader->didReceiveResponse(responseCopy);
 
@@ -143,8 +143,8 @@ void WebResourceLoader::didReceiveData(const IPC::DataReference& data, int64_t e
     LOG(Network, "(WebProcess) WebResourceLoader::didReceiveData of size %i for '%s'", (int)data.size(), m_coreLoader->url().string().utf8().data());
 
 #if USE(QUICK_LOOK)
-    if (m_quickLookHandle) {
-        if (m_quickLookHandle->didReceiveData(adoptCF(CFDataCreate(kCFAllocatorDefault, data.data(), data.size())).get()))
+    if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
+        if (quickLookHandle->didReceiveData(adoptCF(CFDataCreate(kCFAllocatorDefault, data.data(), data.size())).get()))
             return;
     }
 #endif
@@ -156,8 +156,10 @@ void WebResourceLoader::didFinishResourceLoad(double finishTime)
     LOG(Network, "(WebProcess) WebResourceLoader::didFinishResourceLoad for '%s'", m_coreLoader->url().string().utf8().data());
 
 #if USE(QUICK_LOOK)
-    if (m_quickLookHandle && m_quickLookHandle->didFinishLoading())
-        return;
+    if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
+        if (quickLookHandle->didFinishLoading())
+            return;
+    }
 #endif
     m_coreLoader->didFinishLoading(finishTime);
 }
@@ -167,8 +169,8 @@ void WebResourceLoader::didFailResourceLoad(const ResourceError& error)
     LOG(Network, "(WebProcess) WebResourceLoader::didFailResourceLoad for '%s'", m_coreLoader->url().string().utf8().data());
     
 #if USE(QUICK_LOOK)
-    if (m_quickLookHandle)
-        m_quickLookHandle->didFail();
+    if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle())
+        quickLookHandle->didFail();
 #endif
     if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForError(m_coreLoader.get(), error))
         return;
@@ -181,15 +183,15 @@ void WebResourceLoader::didReceiveResource(const ShareableResource::Handle& hand
     LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResource for '%s'", m_coreLoader->url().string().utf8().data());
 
 #if USE(QUICK_LOOK)
-    if (m_quickLookHandle) {
+    if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
         RetainPtr<CFDataRef> cfBuffer = handle.tryWrapInCFData();
         if (cfBuffer) {
-            if (m_quickLookHandle->didReceiveData(cfBuffer.get())) {
-                m_quickLookHandle->didFinishLoading();
+            if (quickLookHandle->didReceiveData(cfBuffer.get())) {
+                quickLookHandle->didFinishLoading();
                 return;
             }
         } else
-            m_quickLookHandle->didFail();
+            quickLookHandle->didFail();
     }
 #endif
 
index 4bf0db9..cbe583d 100644 (file)
@@ -92,10 +92,6 @@ private:
     void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&);
 #endif
 
-#if USE(QUICK_LOOK)
-    std::unique_ptr<WebCore::QuickLookHandle> m_quickLookHandle;
-#endif
-
     RefPtr<WebCore::ResourceLoader> m_coreLoader;
 };