[iOS] Stop creating a WKWebResourceQuickLookDelegate for every WebResourceLoader
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Apr 2014 22:28:29 +0000 (22:28 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Apr 2014 22:28:29 +0000 (22:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132215

Reviewed by Dan Bernstein.

Source/WebCore:
* WebCore.exp.in: Moved QuickLook symbols to the USE(QUICK_LOOK) stanza.
* platform/network/ios/QuickLook.h: Changed one of the create() overloads to no longer take a delegate argument.
* platform/network/ios/QuickLook.mm: Moved WKWebResourceQuickLookDelegate to here and renamed to WebResourceLoaderQuickLookDelegate.
(WebCore::QuickLookHandle::create): Created a WebResourceLoaderQuickLookDelegate only if QuickLook can handle the response.

Source/WebKit2:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo): Called QuickLookHandle::create() directly.
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/ios/WebResourceLoaderIOS.mm: Removed.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/network/ios/QuickLook.h
Source/WebCore/platform/network/ios/QuickLook.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
Source/WebKit2/WebProcess/Network/WebResourceLoader.h
Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm [deleted file]

index 7552234..3a81bfb 100644 (file)
@@ -1,3 +1,15 @@
+2014-04-25  Andy Estes  <aestes@apple.com>
+
+        [iOS] Stop creating a WKWebResourceQuickLookDelegate for every WebResourceLoader
+        https://bugs.webkit.org/show_bug.cgi?id=132215
+
+        Reviewed by Dan Bernstein.
+
+        * WebCore.exp.in: Moved QuickLook symbols to the USE(QUICK_LOOK) stanza.
+        * platform/network/ios/QuickLook.h: Changed one of the create() overloads to no longer take a delegate argument.
+        * platform/network/ios/QuickLook.mm: Moved WKWebResourceQuickLookDelegate to here and renamed to WebResourceLoaderQuickLookDelegate.
+        (WebCore::QuickLookHandle::create): Created a WebResourceLoaderQuickLookDelegate only if QuickLook can handle the response.
+
 2014-04-27  Sam Weinig  <sam@webkit.org>
 
         [iOS WebKit2] Add support for text autosizing
index 36ff70e..b5d5ddd 100644 (file)
@@ -2508,12 +2508,6 @@ __ZN7WebCore15GraphicsContext23setIsAcceleratedContextEb
 __ZN7WebCore15GraphicsContextC1EP9CGContextb
 __ZN7WebCore15LegacyTileCache14drainLayerPoolEv
 __ZN7WebCore15LegacyTileCache20setLayerPoolCapacityEj
-__ZN7WebCore15QuickLookHandle10nsResponseEv
-__ZN7WebCore15QuickLookHandle14didReceiveDataEPK8__CFData
-__ZN7WebCore15QuickLookHandle16didFinishLoadingEv
-__ZN7WebCore15QuickLookHandle6createEPNS_14ResourceLoaderEP13NSURLResponseP11objc_object
-__ZN7WebCore15QuickLookHandle7didFailEv
-__ZN7WebCore15QuickLookHandleD1Ev
 __ZN7WebCore15ResourceRequest41updateFromDelegatePreservingOldPropertiesERKS0_
 __ZN7WebCore15StringTruncator12leftTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotERfbf
 __ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotERfbf
@@ -3225,6 +3219,12 @@ _wkIsPublicSuffix
 #endif
 
 #if USE(QUICK_LOOK)
+__ZN7WebCore15QuickLookHandle10nsResponseEv
+__ZN7WebCore15QuickLookHandle14didReceiveDataEPK8__CFData
+__ZN7WebCore15QuickLookHandle16didFinishLoadingEv
+__ZN7WebCore15QuickLookHandle6createEPNS_14ResourceLoaderEP13NSURLResponse
+__ZN7WebCore15QuickLookHandle7didFailEv
+__ZN7WebCore15QuickLookHandleD1Ev
 __ZN7WebCore27qlPreviewConverterUTIForURLEP5NSURL
 __ZN7WebCore30removeQLPreviewConverterForURLEP5NSURL
 __ZN7WebCore31createTemporaryFileForQuickLookEP8NSString
index 6bbd142..57405c6 100644 (file)
@@ -86,7 +86,7 @@ public:
 #if USE(CFNETWORK)
     static std::unique_ptr<QuickLookHandle> create(ResourceHandle*, SynchronousResourceHandleCFURLConnectionDelegate*, CFURLResponseRef);
 #endif
-    static std::unique_ptr<QuickLookHandle> create(ResourceLoader*, NSURLResponse *, id delegate);
+    static std::unique_ptr<QuickLookHandle> create(ResourceLoader*, NSURLResponse *);
     ~QuickLookHandle();
 
     bool didReceiveDataArray(CFArrayRef);
index 22a91b3..218d68e 100644 (file)
@@ -30,6 +30,7 @@
 
 #import "FileSystemIOS.h"
 #import "Logging.h"
+#import "ResourceError.h"
 #import "ResourceHandle.h"
 #import "ResourceLoader.h"
 #import "RuntimeApplicationChecksIOS.h"
@@ -319,6 +320,69 @@ const char* WebCore::QLPreviewProtocol()
 @end
 #endif
 
+@interface WebResourceLoaderQuickLookDelegate : NSObject <NSURLConnectionDelegate> {
+    RefPtr<ResourceLoader> _resourceLoader;
+}
+@end
+
+@implementation WebResourceLoaderQuickLookDelegate
+
+- (id)initWithResourceLoader:(PassRefPtr<ResourceLoader>)resourceLoader
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _resourceLoader = resourceLoader;
+    return self;
+}
+
+#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+- (void)connection:(NSURLConnection *)connection didReceiveDataArray:(NSArray *)dataArray
+{
+    UNUSED_PARAM(connection);
+    if (!_resourceLoader)
+        return;
+    _resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
+}
+#endif
+
+- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
+{
+    UNUSED_PARAM(connection);
+    if (!_resourceLoader)
+        return;
+    
+    // QuickLook code sends us a nil data at times. The check below is the same as the one in
+    // ResourceHandleMac.cpp added for a different bug.
+    if (![data length])
+        return;
+    _resourceLoader->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes);
+}
+
+- (void)connectionDidFinishLoading:(NSURLConnection *)connection
+{
+    UNUSED_PARAM(connection);
+    if (!_resourceLoader)
+        return;
+    
+    _resourceLoader->didFinishLoading(0);
+}
+
+- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
+{
+    UNUSED_PARAM(connection);
+    
+    _resourceLoader->didFail(ResourceError(error));
+}
+
+- (void)clearHandle
+{
+    _resourceLoader = nullptr;
+}
+
+@end
+
 namespace WebCore {
 
 NSString *createTemporaryFileForQuickLook(NSString *fileName)
@@ -387,13 +451,14 @@ CFURLResponseRef QuickLookHandle::cfResponse()
 }
 #endif
 
-std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceLoader* loader, NSURLResponse *response, id delegate)
+std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceLoader* loader, NSURLResponse *response)
 {
     ASSERT_ARG(loader, loader);
     if (!loader->request().isMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[response MIMEType]])
         return nullptr;
 
-    std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([loader->originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, response, delegate));
+    RetainPtr<WebResourceLoaderQuickLookDelegate> delegate = adoptNS([[WebResourceLoaderQuickLookDelegate alloc] initWithResourceLoader:loader]);
+    std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([loader->originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, response, delegate.get()));
     loader->didCreateQuickLookHandle(*quickLookHandle);
     return std::move(quickLookHandle);
 }
index 342c860..3d69821 100644 (file)
@@ -1,3 +1,16 @@
+2014-04-25  Andy Estes  <aestes@apple.com>
+
+        [iOS] Stop creating a WKWebResourceQuickLookDelegate for every WebResourceLoader
+        https://bugs.webkit.org/show_bug.cgi?id=132215
+
+        Reviewed by Dan Bernstein.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/Network/WebResourceLoader.cpp:
+        (WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo): Called QuickLookHandle::create() directly.
+        * WebProcess/Network/WebResourceLoader.h:
+        * WebProcess/ios/WebResourceLoaderIOS.mm: Removed.
+
 2014-04-27  Sam Weinig  <sam@webkit.org>
 
         [iOS WebKit2] Add support for text autosizing
index e935788..238c2ed 100644 (file)
                1F7506B71859165A00EC0FF7 /* WKWebProcessPlugInHitTestResultInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F01816E1858DC1600F92884 /* WKWebProcessPlugInHitTestResultInternal.h */; };
                1F7506B81859165D00EC0FF7 /* WKWebProcessPlugInFrameInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F01816B1858DC1500F92884 /* WKWebProcessPlugInFrameInternal.h */; };
                1F7D36C118DA513F00D9D659 /* APIDownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */; };
-               1F8724B718D7632B0076D4B4 /* WebResourceLoaderIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F8724B318D7631D0076D4B4 /* WebResourceLoaderIOS.mm */; };
                1FB00AC7185F76460019142E /* WKWebProcessPlugInPageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FB00AC4185F76460019142E /* WKWebProcessPlugInPageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1FB00AC8185F76460019142E /* WKWebProcessPlugInPageGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FB00AC5185F76460019142E /* WKWebProcessPlugInPageGroup.mm */; };
                1FB00AC9185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */; };
                1F604BA61889FA7400EE0395 /* WKRenderingProgressEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRenderingProgressEvents.h; sourceTree = "<group>"; };
                1F604BA71889FA7400EE0395 /* WKRenderingProgressEventsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRenderingProgressEventsInternal.h; sourceTree = "<group>"; };
                1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIDownloadClient.h; sourceTree = "<group>"; };
-               1F8724B318D7631D0076D4B4 /* WebResourceLoaderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebResourceLoaderIOS.mm; path = ios/WebResourceLoaderIOS.mm; sourceTree = "<group>"; };
                1FB00AC4185F76460019142E /* WKWebProcessPlugInPageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInPageGroup.h; sourceTree = "<group>"; };
                1FB00AC5185F76460019142E /* WKWebProcessPlugInPageGroup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInPageGroup.mm; sourceTree = "<group>"; };
                1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInPageGroupInternal.h; sourceTree = "<group>"; };
                        path = Cocoa;
                        sourceTree = "<group>";
                };
-               1F8724B218D763040076D4B4 /* ios */ = {
-                       isa = PBXGroup;
-                       children = (
-                               1F8724B318D7631D0076D4B4 /* WebResourceLoaderIOS.mm */,
-                       );
-                       name = ios;
-                       sourceTree = "<group>";
-               };
                2989A40E167D1813004F96D2 /* CustomProtocols */ = {
                        isa = PBXGroup;
                        children = (
                5105B0D2162F7A5E00E27709 /* Network */ = {
                        isa = PBXGroup;
                        children = (
-                               1F8724B218D763040076D4B4 /* ios */,
                                5105B0D4162F7A7A00E27709 /* NetworkProcessConnection.cpp */,
                                5105B0D5162F7A7A00E27709 /* NetworkProcessConnection.h */,
                                51FB0902163A3B1C00EC324A /* NetworkProcessConnection.messages.in */,
                                37948403150C350600E52CE9 /* WebRenderLayer.cpp in Sources */,
                                2D28F3E61885CCC1004B9EAE /* WebEditorClientIOS.mm in Sources */,
                                3760881E150413E900FC82C7 /* WebRenderObject.cpp in Sources */,
-                               1F8724B718D7632B0076D4B4 /* WebResourceLoaderIOS.mm in Sources */,
                                51217464164C21370037A5C1 /* WebResourceBuffer.cpp in Sources */,
                                3336762F130C9998006C9DE2 /* WebResourceCacheManager.cpp in Sources */,
                                33F9D5B91312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp in Sources */,
index 92e2cb2..f8e42b0 100644 (file)
@@ -108,7 +108,7 @@ void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResp
     ResourceResponse responseCopy(response);
 
 #if USE(QUICK_LOOK)
-    setUpQuickLookHandleIfNeeded(response);
+    m_quickLookHandle = QuickLookHandle::create(resourceLoader(), response.nsURLResponse());
     if (m_quickLookHandle)
         responseCopy = ResourceResponse(m_quickLookHandle->nsResponse());
 #endif
index 60167ef..eb5ab75 100644 (file)
@@ -94,8 +94,6 @@ private:
 #endif
 
 #if USE(QUICK_LOOK)
-    void setUpQuickLookHandleIfNeeded(const WebCore::ResourceResponse&);
-
     std::unique_ptr<WebCore::QuickLookHandle> m_quickLookHandle;
 #endif
 
diff --git a/Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm b/Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm
deleted file mode 100644 (file)
index 51ad572..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2014 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 "WebResourceLoader.h"
-
-#if ENABLE(NETWORK_PROCESS)
-#include "DataReference.h"
-#include <WebCore/ResourceError.h>
-#include <WebCore/ResourceLoader.h>
-
-using namespace WebCore;
-
-#if USE(QUICK_LOOK)
-
-@interface WKWebResourceQuickLookDelegate : NSObject <NSURLConnectionDelegate> {
-    RefPtr<WebKit::WebResourceLoader> _webResourceLoader;
-}
-@end
-
-@implementation WKWebResourceQuickLookDelegate
-
-- (id)initWithWebResourceLoader:(PassRefPtr<WebKit::WebResourceLoader>)loader
-{
-    self = [super init];
-    if (!self)
-        return nil;
-
-    _webResourceLoader = loader;
-    return self;
-}
-
-#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
-- (void)connection:(NSURLConnection *)connection didReceiveDataArray:(NSArray *)dataArray
-{
-    UNUSED_PARAM(connection);
-    if (!_webResourceLoader)
-        return;
-    _webResourceLoader->resourceLoader()->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
-}
-#endif
-
-- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
-{
-    UNUSED_PARAM(connection);
-    if (!_webResourceLoader)
-        return;
-
-    // QuickLook code sends us a nil data at times. The check below is the same as the one in
-    // ResourceHandleMac.cpp added for a different bug.
-    if (![data length])
-        return;
-    _webResourceLoader->resourceLoader()->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes);
-}
-
-- (void)connectionDidFinishLoading:(NSURLConnection *)connection
-{
-    UNUSED_PARAM(connection);
-    if (!_webResourceLoader)
-        return;
-
-    _webResourceLoader->resourceLoader()->didFinishLoading(0);
-}
-
-- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
-{
-    UNUSED_PARAM(connection);
-
-    _webResourceLoader->resourceLoader()->didFail(ResourceError(error));
-}
-
-- (void)clearHandle
-{
-    _webResourceLoader = nullptr;
-}
-
-@end
-
-namespace WebKit {
-
-void WebResourceLoader::setUpQuickLookHandleIfNeeded(const ResourceResponse& response)
-{
-    RetainPtr<WKWebResourceQuickLookDelegate> delegate = adoptNS([[WKWebResourceQuickLookDelegate alloc] initWithWebResourceLoader:this]);
-    m_quickLookHandle = QuickLookHandle::create(resourceLoader(), response.nsURLResponse(), delegate.get());
-}
-
-} // namespace WebKit
-
-#endif
-
-#endif // ENABLE(NETWORK_PROCESS)