Diff
Modified: trunk/Source/WebCore/ChangeLog (210479 => 210480)
--- trunk/Source/WebCore/ChangeLog 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/ChangeLog 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,3 +1,74 @@
+2017-01-07 Andy Estes <[email protected]>
+
+ [QuickLook] Consolidate usage of QuickLookHandle into SubresourceLoader
+ https://bugs.webkit.org/show_bug.cgi?id=166713
+
+ Reviewed by Alex Christensen.
+
+ QuickLook conversion was originally implemented by intercepting document loads at the
+ ResourceHandle level, with separate paths for NSURLConnection and CFURLConnection handles.
+ When QuickLook was ported to WebKit2, a third path was added in WebResourceLoader.
+
+ This change removes these three separate paths and implements a single conversion path in
+ SubresourceLoader, where QuickLook can intercept document loads regardless of the networking
+ API being used.
+
+ No change in behavior. Covered by existing tests.
+
+ * loader/ResourceLoader.h: Removed override from didCreateQuickLookHandle() since this
+ function is no longer declared in ResourceHandleClient.
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::shouldCreateQuickLookHandleForResponse): Added a helper
+ function to check if a QuickLookHandle should be created for a response.
+ (WebCore::SubresourceLoader::didReceiveResponse): Created a QuickLookHandle if necessary
+ and stored it in the DocumentLoader.
+ (WebCore::SubresourceLoader::didReceiveData): If there is a QuickLookHandle, call
+ QuickLookHandle::didReceiveBuffer(), and return early if QuickLook is converting.
+ (WebCore::SubresourceLoader::didReceiveBuffer): Ditto for QuickLookHandle::didReceiveBuffer().
+ (WebCore::SubresourceLoader::didFinishLoading): Ditto for QuickLookHandle::didFinishLoading().
+ (WebCore::SubresourceLoader::didFail): If there is a QuickLookHandle, call QuickLookHandle::didFail().
+ * loader/SubresourceLoader.h: Declared shouldCreateQuickLookHandleForResponse().
+ * loader/ios/QuickLook.h: Removed declarations used by the ResourceHandles and declared new
+ functions used by SubresourceLoader.
+ * loader/ios/QuickLook.mm:
+ (WebCore::QuickLookHandle::QuickLookHandle): Removed the NSURLConnection * parameter, since
+ we’d now always pass nil.
+ (WebCore::QuickLookHandle::create): Removed create() functions used by ResourceHandles.
+ (WebCore::QuickLookHandle::didReceiveData): Added. Copies the data into an NSData, wraps it
+ in an NSArray, and passes it to didReceiveDataArray().
+ (WebCore::QuickLookHandle::didReceiveBuffer): Added. Creates a NSArray of NSData from the
+ SharedBuffer and passes it to didReceiveDataArray().
+ (-[WebQuickLookHandleAsDelegate initWithConnectionDelegate:]): Deleted.
+ (-[WebQuickLookHandleAsDelegate connection:didReceiveDataArray:]): Deleted.
+ (-[WebQuickLookHandleAsDelegate connection:didReceiveData:lengthReceived:]): Deleted.
+ (-[WebQuickLookHandleAsDelegate connectionDidFinishLoading:]): Deleted.
+ (-[WebQuickLookHandleAsDelegate connection:didFailWithError:]): Deleted.
+ (-[WebQuickLookHandleAsDelegate detachHandle]): Deleted.
+ (WebCore::QuickLookHandle::cfResponse): Deleted.
+ (WebCore::QuickLookHandle::didReceiveDataArray): Passed dataArray to m_converter and m_client.
+ * platform/SharedBuffer.h: Const-qualified createNSDataArray().
+ * platform/cocoa/SharedBufferCocoa.mm:
+ (WebCore::SharedBuffer::createNSDataArray): Ditto.
+ * platform/network/ResourceHandle.cpp: Stopped including QuickLook.h.
+ * platform/network/ResourceHandle.h: Removed m_quickLook.
+ (WebCore::ResourceHandle::quickLookHandle): Deleted.
+ * platform/network/ResourceHandleClient.h:
+ (WebCore::ResourceHandleClient::didCreateQuickLookHandle): Deleted.
+ * platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp:
+ (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveResponse): Removed QuickLook code.
+ (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveData): Ditto.
+ (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didFinishLoading): Ditto.
+ (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didFail): Ditto.
+ (WebCore::SynchronousResourceHandleCFURLConnectionDelegate::didReceiveDataArray): Ditto.
+ * platform/network/mac/ResourceHandleMac.mm:
+ (WebCore::ResourceHandle::setQuickLookHandle): Deleted.
+ * platform/network/mac/WebCoreResourceHandleAsDelegate.mm:
+ (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]): Removed QuickLook code.
+ (-[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:]): Ditto.
+ (-[WebCoreResourceHandleAsDelegate connection:didReceiveData:lengthReceived:]): Ditto.
+ (-[WebCoreResourceHandleAsDelegate connectionDidFinishLoading:]): Ditto.
+ (-[WebCoreResourceHandleAsDelegate connection:didFailWithError:]): Ditto.
+
2017-01-06 Daniel Bates <[email protected]>
Ensure navigation only allowed for documents not in the page cache
Modified: trunk/Source/WebCore/loader/ResourceLoader.h (210479 => 210480)
--- trunk/Source/WebCore/loader/ResourceLoader.h 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/loader/ResourceLoader.h 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -50,12 +50,9 @@
class DocumentLoader;
class Frame;
class FrameLoader;
+class QuickLookHandle;
class URL;
-#if USE(QUICK_LOOK)
-class QuickLookHandle;
-#endif
-
class ResourceLoader : public RefCounted<ResourceLoader>, protected ResourceHandleClient {
public:
virtual ~ResourceLoader() = 0;
@@ -119,7 +116,7 @@
virtual void receivedCancellation(const AuthenticationChallenge&);
#if USE(QUICK_LOOK)
- void didCreateQuickLookHandle(QuickLookHandle&) override;
+ void didCreateQuickLookHandle(QuickLookHandle&);
#endif
bool isQuickLookResource() { return m_isQuickLookResource; }
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (210479 => 210480)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2007, 2009, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -57,6 +57,10 @@
#include "ResourceLoadInfo.h"
#endif
+#if USE(QUICK_LOOK)
+#include "QuickLook.h"
+#endif
+
namespace WebCore {
DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, subresourceLoaderCounter, ("SubresourceLoader"));
@@ -247,11 +251,31 @@
m_resource->didSendData(bytesSent, totalBytesToBeSent);
}
+#if USE(QUICK_LOOK)
+bool SubresourceLoader::shouldCreateQuickLookHandleForResponse(const ResourceResponse& response) const
+{
+ if (m_resource->type() != CachedResource::MainResource)
+ return false;
+
+ if (m_documentLoader->quickLookHandle())
+ return false;
+
+ return QuickLookHandle::shouldCreateForMIMEType(response.mimeType());
+}
+#endif
+
void SubresourceLoader::didReceiveResponse(const ResourceResponse& response)
{
ASSERT(!response.isNull());
ASSERT(m_state == Initialized);
+#if USE(QUICK_LOOK)
+ if (shouldCreateQuickLookHandleForResponse(response)) {
+ m_documentLoader->setQuickLookHandle(QuickLookHandle::create(*this, response));
+ return;
+ }
+#endif
+
// We want redirect responses to be processed through willSendRequestInternal. The only exception is redirection with no Location headers.
ASSERT(response.httpStatusCode() < 300 || response.httpStatusCode() >= 400 || response.httpStatusCode() == 304 || !response.httpHeaderField(HTTPHeaderName::Location));
@@ -325,11 +349,25 @@
void SubresourceLoader::didReceiveData(const char* data, unsigned length, long long encodedDataLength, DataPayloadType dataPayloadType)
{
+#if USE(QUICK_LOOK)
+ if (auto quickLookHandle = m_documentLoader->quickLookHandle()) {
+ if (quickLookHandle->didReceiveData(data, length))
+ return;
+ }
+#endif
+
didReceiveDataOrBuffer(data, length, nullptr, encodedDataLength, dataPayloadType);
}
void SubresourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, long long encodedDataLength, DataPayloadType dataPayloadType)
{
+#if USE(QUICK_LOOK)
+ if (auto quickLookHandle = m_documentLoader->quickLookHandle()) {
+ if (quickLookHandle->didReceiveBuffer(buffer.get()))
+ return;
+ }
+#endif
+
didReceiveDataOrBuffer(nullptr, 0, WTFMove(buffer), encodedDataLength, dataPayloadType);
}
@@ -468,6 +506,13 @@
void SubresourceLoader::didFinishLoading(double finishTime)
{
+#if USE(QUICK_LOOK)
+ if (auto quickLookHandle = m_documentLoader->quickLookHandle()) {
+ if (quickLookHandle->didFinishLoading())
+ return;
+ }
+#endif
+
if (m_state != Initialized)
return;
ASSERT(!reachedTerminalState());
@@ -510,6 +555,11 @@
void SubresourceLoader::didFail(const ResourceError& error)
{
+#if USE(QUICK_LOOK)
+ if (auto quickLookHandle = m_documentLoader->quickLookHandle())
+ quickLookHandle->didFail();
+#endif
+
if (m_state != Initialized)
return;
ASSERT(!reachedTerminalState());
Modified: trunk/Source/WebCore/loader/SubresourceLoader.h (210479 => 210480)
--- trunk/Source/WebCore/loader/SubresourceLoader.h 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/loader/SubresourceLoader.h 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -101,6 +101,10 @@
void notifyDone();
+#if USE(QUICK_LOOK)
+ bool shouldCreateQuickLookHandleForResponse(const ResourceResponse&) const;
+#endif
+
enum SubresourceLoaderState {
Uninitialized,
Initialized,
Modified: trunk/Source/WebCore/loader/ios/QuickLook.h (210479 => 210480)
--- trunk/Source/WebCore/loader/ios/QuickLook.h 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/loader/ios/QuickLook.h 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,6 +33,7 @@
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
+OBJC_CLASS NSArray;
OBJC_CLASS NSData;
OBJC_CLASS NSDictionary;
OBJC_CLASS NSFileHandle;
@@ -39,7 +40,6 @@
OBJC_CLASS NSSet;
OBJC_CLASS NSString;
OBJC_CLASS NSURL;
-OBJC_CLASS NSURLConnection;
OBJC_CLASS NSURLRequest;
OBJC_CLASS NSURLResponse;
OBJC_CLASS QLPreviewConverter;
@@ -46,10 +46,9 @@
namespace WebCore {
-class ResourceHandle;
class ResourceLoader;
class ResourceResponse;
-class SynchronousResourceHandleCFURLConnectionDelegate;
+class SharedBuffer;
class URL;
WEBCORE_EXPORT NSSet *QLPreviewGetSupportedMIMETypesSet();
@@ -74,26 +73,16 @@
class QuickLookHandle {
WTF_MAKE_NONCOPYABLE(QuickLookHandle);
public:
- WEBCORE_EXPORT static bool shouldCreateForMIMEType(const String&);
+ static bool shouldCreateForMIMEType(const String&);
+ static std::unique_ptr<QuickLookHandle> create(ResourceLoader&, const ResourceResponse&);
+ ~QuickLookHandle();
- static std::unique_ptr<QuickLookHandle> create(ResourceHandle*, NSURLConnection *, NSURLResponse *, id delegate);
-#if USE(CFURLCONNECTION)
- static std::unique_ptr<QuickLookHandle> create(ResourceHandle*, SynchronousResourceHandleCFURLConnectionDelegate*, CFURLResponseRef);
-#endif
- // FIXME: Use of ResourceLoader here is a platform violation.
- WEBCORE_EXPORT static std::unique_ptr<QuickLookHandle> create(ResourceLoader&, const ResourceResponse&);
+ bool didReceiveData(const char* data, unsigned length);
+ bool didReceiveBuffer(const SharedBuffer&);
+ bool didFinishLoading();
+ void didFail();
- WEBCORE_EXPORT ~QuickLookHandle();
-
- WEBCORE_EXPORT bool didReceiveDataArray(CFArrayRef);
- WEBCORE_EXPORT bool didReceiveData(CFDataRef);
- WEBCORE_EXPORT bool didFinishLoading();
- WEBCORE_EXPORT void didFail();
-
WEBCORE_EXPORT NSURLResponse *nsResponse();
-#if USE(CFURLCONNECTION)
- CFURLResponseRef cfResponse();
-#endif
void setClient(PassRefPtr<QuickLookHandleClient> client) { m_client = client; }
@@ -104,8 +93,10 @@
QLPreviewConverter *converter() const { return m_converter.get(); }
private:
- QuickLookHandle(NSURL *, NSURLConnection *, NSURLResponse *, id delegate);
+ QuickLookHandle(NSURL *, NSURLResponse *, id delegate);
+ void didReceiveDataArray(NSArray *);
+
RetainPtr<NSURL> m_firstRequestURL;
RetainPtr<QLPreviewConverter> m_converter;
RetainPtr<id> m_delegate;
Modified: trunk/Source/WebCore/loader/ios/QuickLook.mm (210479 => 210480)
--- trunk/Source/WebCore/loader/ios/QuickLook.mm 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/loader/ios/QuickLook.mm 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,21 +28,15 @@
#if USE(QUICK_LOOK)
-#import "DocumentLoader.h"
#import "FileSystemIOS.h"
#import "Logging.h"
#import "NSFileManagerSPI.h"
#import "ResourceError.h"
-#import "ResourceHandle.h"
#import "ResourceLoader.h"
-#import "RuntimeApplicationChecks.h"
-#import "SynchronousResourceHandleCFURLConnectionDelegate.h"
+#import "SharedBuffer.h"
#import "WebCoreResourceHandleAsDelegate.h"
-#import "WebCoreURLResponseIOS.h"
#import <Foundation/Foundation.h>
#import <wtf/NeverDestroyed.h>
-#import <wtf/StdLibExtras.h>
-#import <wtf/Threading.h>
#import <wtf/Vector.h>
#import <wtf/text/WTFString.h>
@@ -185,81 +179,6 @@
return previewProtocol.get().data();
}
-#if USE(CFURLCONNECTION)
-// The way QuickLook works is we pass it an NSURLConnectionDelegate callback object at creation
-// time. Then we pass it all the data as we receive it. Once we've downloaded the full URL,
-// QuickLook turns around and send us, through this delegate, the HTML version of the file which we
-// pass on to WebCore. The flag m_finishedLoadingDataIntoConverter in QuickLookHandle decides
-// whether to pass the data to QuickLook or WebCore.
-//
-// This works fine when using NS APIs, but when using CFNetwork, we don't have a NSURLConnectionDelegate.
-// So we create WebQuickLookHandleAsDelegate as an intermediate delegate object and pass it to
-// QLPreviewConverter. The proxy delegate then forwards the messages on to the CFNetwork code.
-@interface WebQuickLookHandleAsDelegate : NSObject <NSURLConnectionDelegate, WebCoreResourceLoaderDelegate> {
- RefPtr<SynchronousResourceHandleCFURLConnectionDelegate> m_connectionDelegate;
-}
-
-- (id)initWithConnectionDelegate:(SynchronousResourceHandleCFURLConnectionDelegate*)connectionDelegate;
-@end
-
-@implementation WebQuickLookHandleAsDelegate
-- (id)initWithConnectionDelegate:(SynchronousResourceHandleCFURLConnectionDelegate*)connectionDelegate
-{
- self = [super init];
- if (!self)
- return nil;
- m_connectionDelegate = connectionDelegate;
- return self;
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveDataArray:(NSArray *)dataArray
-{
- UNUSED_PARAM(connection);
- if (!m_connectionDelegate)
- return;
- LOG(Network, "WebQuickLookHandleAsDelegate::didReceiveDataArray()");
- m_connectionDelegate->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
-{
- UNUSED_PARAM(connection);
- if (!m_connectionDelegate)
- return;
- LOG(Network, "WebQuickLookHandleAsDelegate::didReceiveData() - data length = %ld", (long)[data length]);
-
- // 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;
- m_connectionDelegate->didReceiveData(reinterpret_cast<CFDataRef>(data), static_cast<int>(lengthReceived));
-}
-
-- (void)connectionDidFinishLoading:(NSURLConnection *)connection
-{
- UNUSED_PARAM(connection);
- if (!m_connectionDelegate)
- return;
- LOG(Network, "WebQuickLookHandleAsDelegate::didFinishLoading()");
- m_connectionDelegate->didFinishLoading();
-}
-
-- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
-{
- UNUSED_PARAM(connection);
- if (!m_connectionDelegate)
- return;
- LOG(Network, "WebQuickLookHandleAsDelegate::didFail()");
- m_connectionDelegate->didFail(reinterpret_cast<CFErrorRef>(error));
-}
-
-- (void)detachHandle
-{
- m_connectionDelegate = nullptr;
-}
-@end
-#endif
-
@interface WebResourceLoaderQuickLookDelegate : NSObject <NSURLConnectionDelegate, WebCoreResourceLoaderDelegate> {
RefPtr<ResourceLoader> _resourceLoader;
BOOL _hasSentDidReceiveResponse;
@@ -392,9 +311,9 @@
return &emptyClient.get();
}
-QuickLookHandle::QuickLookHandle(NSURL *firstRequestURL, NSURLConnection *connection, NSURLResponse *nsResponse, id delegate)
+QuickLookHandle::QuickLookHandle(NSURL *firstRequestURL, NSURLResponse *nsResponse, id delegate)
: m_firstRequestURL(firstRequestURL)
- , m_converter(adoptNS([allocQLPreviewConverterInstance() initWithConnection:connection delegate:delegate response:nsResponse options:nil]))
+ , m_converter(adoptNS([allocQLPreviewConverterInstance() initWithConnection:nil delegate:delegate response:nsResponse options:nil]))
, m_delegate(delegate)
, m_finishedLoadingDataIntoConverter(false)
, m_nsResponse([m_converter previewResponse])
@@ -403,37 +322,6 @@
LOG(Network, "QuickLookHandle::QuickLookHandle() - previewFileName: %s", [m_converter previewFileName]);
}
-std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceHandle* handle, NSURLConnection *connection, NSURLResponse *nsResponse, id delegate)
-{
- ASSERT_ARG(handle, handle);
- if (handle->firstRequest().requester() != ResourceRequest::Requester::Main || ![QLPreviewGetSupportedMIMETypesSet() containsObject:[nsResponse MIMEType]])
- return nullptr;
-
- std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([handle->firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], connection, nsResponse, delegate));
- handle->client()->didCreateQuickLookHandle(*quickLookHandle);
- return quickLookHandle;
-}
-
-#if USE(CFURLCONNECTION)
-std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceHandle* handle, SynchronousResourceHandleCFURLConnectionDelegate* connectionDelegate, CFURLResponseRef cfResponse)
-{
- ASSERT_ARG(handle, handle);
- if (handle->firstRequest().requester() != ResourceRequest::Requester::Main || ![QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)CFURLResponseGetMIMEType(cfResponse)])
- return nullptr;
-
- NSURLResponse *nsResponse = [NSURLResponse _responseWithCFURLResponse:cfResponse];
- WebQuickLookHandleAsDelegate *delegate = [[[WebQuickLookHandleAsDelegate alloc] initWithConnectionDelegate:connectionDelegate] autorelease];
- std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([handle->firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, nsResponse, delegate));
- handle->client()->didCreateQuickLookHandle(*quickLookHandle);
- return quickLookHandle;
-}
-
-CFURLResponseRef QuickLookHandle::cfResponse()
-{
- return [m_nsResponse _CFURLResponse];
-}
-#endif
-
bool QuickLookHandle::shouldCreateForMIMEType(const String& mimeType)
{
return [QLPreviewGetSupportedMIMETypesSet() containsObject:mimeType];
@@ -444,7 +332,7 @@
ASSERT(shouldCreateForMIMEType(response.mimeType()));
RetainPtr<WebResourceLoaderQuickLookDelegate> delegate = adoptNS([[WebResourceLoaderQuickLookDelegate alloc] initWithResourceLoader:&loader]);
- std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([loader.originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, response.nsURLResponse(), delegate.get()));
+ std::unique_ptr<QuickLookHandle> quickLookHandle(new QuickLookHandle([loader.originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], response.nsURLResponse(), delegate.get()));
[delegate setQuickLookHandle:quickLookHandle.get()];
loader.didCreateQuickLookHandle(*quickLookHandle);
return quickLookHandle;
@@ -455,25 +343,32 @@
return m_nsResponse.get();
}
-bool QuickLookHandle::didReceiveDataArray(CFArrayRef cfDataArray)
+bool QuickLookHandle::didReceiveData(const char* data, unsigned length)
{
if (m_finishedLoadingDataIntoConverter)
return false;
- LOG(Network, "QuickLookHandle::didReceiveDataArray()");
- [m_converter appendDataArray:(NSArray *)cfDataArray];
- m_client->didReceiveDataArray(cfDataArray);
+ didReceiveDataArray(@[ [NSData dataWithBytes:data length:length] ]);
return true;
}
-bool QuickLookHandle::didReceiveData(CFDataRef cfData)
+bool QuickLookHandle::didReceiveBuffer(const SharedBuffer& buffer)
{
if (m_finishedLoadingDataIntoConverter)
return false;
-
- return didReceiveDataArray(adoptCF(CFArrayCreate(kCFAllocatorDefault, (const void**)&cfData, 1, &kCFTypeArrayCallBacks)).get());
+
+ didReceiveDataArray(buffer.createNSDataArray().get());
+ return true;
}
+void QuickLookHandle::didReceiveDataArray(NSArray *dataArray)
+{
+ ASSERT(!m_finishedLoadingDataIntoConverter);
+ LOG(Network, "QuickLookHandle::didReceiveDataArray()");
+ [m_converter appendDataArray:dataArray];
+ m_client->didReceiveDataArray((CFArrayRef)dataArray);
+}
+
bool QuickLookHandle::didFinishLoading()
{
if (m_finishedLoadingDataIntoConverter)
Modified: trunk/Source/WebCore/platform/SharedBuffer.h (210479 => 210480)
--- trunk/Source/WebCore/platform/SharedBuffer.h 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/SharedBuffer.h 2017-01-07 21:00:30 UTC (rev 210480)
@@ -65,7 +65,7 @@
#if USE(FOUNDATION)
WEBCORE_EXPORT RetainPtr<NSData> createNSData();
- WEBCORE_EXPORT RetainPtr<NSArray> createNSDataArray();
+ WEBCORE_EXPORT RetainPtr<NSArray> createNSDataArray() const;
WEBCORE_EXPORT static Ref<SharedBuffer> wrapNSData(NSData *);
#endif
#if USE(CF)
Modified: trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm (210479 => 210480)
--- trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm 2017-01-07 21:00:30 UTC (rev 210480)
@@ -123,7 +123,7 @@
return nullptr;
}
-RetainPtr<NSArray> SharedBuffer::createNSDataArray()
+RetainPtr<NSArray> SharedBuffer::createNSDataArray() const
{
if (auto platformData = (NSData *)m_cfData.get())
return @[ platformData ];
Modified: trunk/Source/WebCore/platform/network/ResourceHandle.cpp (210479 => 210480)
--- trunk/Source/WebCore/platform/network/ResourceHandle.cpp 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.cpp 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,10 +38,6 @@
#include <wtf/text/AtomicStringHash.h>
#include <wtf/text/CString.h>
-#if USE(QUICK_LOOK)
-#include "QuickLook.h"
-#endif
-
namespace WebCore {
static bool shouldForceContentSniffing;
Modified: trunk/Source/WebCore/platform/network/ResourceHandle.h (210479 => 210480)
--- trunk/Source/WebCore/platform/network/ResourceHandle.h 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/network/ResourceHandle.h 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2011, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -147,11 +147,6 @@
static void setClientCertificate(const String& host, CFDataRef);
#endif
-#if USE(QUICK_LOOK)
- QuickLookHandle* quickLookHandle() { return m_quickLook.get(); }
- void setQuickLookHandle(std::unique_ptr<QuickLookHandle>);
-#endif
-
#if PLATFORM(WIN) && USE(CURL)
static void setHostAllowsAnyHTTPSCertificate(const String&);
static void setClientCertificateInfo(const String&, const String&, const String&);
@@ -280,10 +275,6 @@
friend class ResourceHandleInternal;
std::unique_ptr<ResourceHandleInternal> d;
-
-#if USE(QUICK_LOOK)
- std::unique_ptr<QuickLookHandle> m_quickLook;
-#endif
};
}
Modified: trunk/Source/WebCore/platform/network/ResourceHandleClient.h (210479 => 210480)
--- trunk/Source/WebCore/platform/network/ResourceHandleClient.h 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/network/ResourceHandleClient.h 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2006 Apple Inc. All rights reserved.
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -53,10 +52,6 @@
class ResourceResponse;
class SharedBuffer;
-#if USE(QUICK_LOOK)
- class QuickLookHandle;
-#endif
-
enum CacheStoragePolicy {
StorageAllowed,
StorageAllowedInMemoryOnly,
@@ -131,10 +126,6 @@
#elif PLATFORM(COCOA)
virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse *response) { return response; }
#endif
-
-#if USE(QUICK_LOOK)
- virtual void didCreateQuickLookHandle(QuickLookHandle&) { }
-#endif
};
}
Modified: trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp (210479 => 210480)
--- trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -167,15 +167,6 @@
}
#endif
-#if USE(QUICK_LOOK)
- bool isQuickLookPreview = false;
- m_handle->setQuickLookHandle(QuickLookHandle::create(m_handle, this, cfResponse));
- if (m_handle->quickLookHandle()) {
- cfResponse = m_handle->quickLookHandle()->cfResponse();
- isQuickLookPreview = true;
- }
-#endif
-
ResourceResponse resourceResponse(cfResponse);
#if PLATFORM(COCOA) && ENABLE(WEB_TIMING)
ResourceHandle::getConnectionTimingData(connection, resourceResponse.networkLoadTiming());
@@ -183,10 +174,6 @@
UNUSED_PARAM(connection);
#endif
-#if USE(QUICK_LOOK)
- resourceResponse.setIsQuickLook(isQuickLookPreview);
-#endif
-
m_handle->client()->didReceiveResponse(m_handle, WTFMove(resourceResponse));
}
@@ -194,11 +181,6 @@
{
LOG(Network, "CFNet - SynchronousResourceHandleCFURLConnectionDelegate::didReceiveData(handle=%p, bytes=%ld) (%s)", m_handle, CFDataGetLength(data), m_handle->firstRequest().url().string().utf8().data());
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle() && m_handle->quickLookHandle()->didReceiveData(data))
- return;
-#endif
-
if (ResourceHandleClient* client = m_handle->client())
client->didReceiveBuffer(m_handle, SharedBuffer::wrapCFData(data), originalLength);
}
@@ -207,11 +189,6 @@
{
LOG(Network, "CFNet - SynchronousResourceHandleCFURLConnectionDelegate::didFinishLoading(handle=%p) (%s)", m_handle, m_handle->firstRequest().url().string().utf8().data());
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle() && m_handle->quickLookHandle()->didFinishLoading())
- return;
-#endif
-
if (ResourceHandleClient* client = m_handle->client())
client->didFinishLoading(m_handle, 0);
}
@@ -220,11 +197,6 @@
{
LOG(Network, "CFNet - SynchronousResourceHandleCFURLConnectionDelegate::didFail(handle=%p, error = %p) (%s)", m_handle, error, m_handle->firstRequest().url().string().utf8().data());
-#if USE(QUICK_LOOK)
- if (QuickLookHandle* quickLookHandle = m_handle->quickLookHandle())
- quickLookHandle->didFail();
-#endif
-
if (ResourceHandleClient* client = m_handle->client())
client->didFail(m_handle, ResourceError(error));
}
@@ -306,11 +278,6 @@
LOG(Network, "CFNet - SynchronousResourceHandleCFURLConnectionDelegate::didReceiveDataArray(handle=%p, arrayLength=%ld) (%s)", m_handle, CFArrayGetCount(dataArray), m_handle->firstRequest().url().string().utf8().data());
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle() && m_handle->quickLookHandle()->didReceiveDataArray(dataArray))
- return;
-#endif
-
if (ResourceHandleClient* client = m_handle->client())
client->didReceiveBuffer(m_handle, SharedBuffer::wrapCFDataArray(dataArray), -1);
}
Modified: trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm (210479 => 210480)
--- trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -77,10 +77,6 @@
@end
#endif
-#if USE(QUICK_LOOK)
-#import "QuickLook.h"
-#endif
-
using namespace WebCore;
@interface NSURLConnection ()
@@ -752,12 +748,5 @@
#endif // ENABLE(WEB_TIMING)
-#if USE(QUICK_LOOK)
-void ResourceHandle::setQuickLookHandle(std::unique_ptr<QuickLookHandle> handle)
-{
- m_quickLook = WTFMove(handle);
-}
-#endif
-
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm (210479 => 210480)
--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -39,10 +39,6 @@
#import "SharedBuffer.h"
#import "WebCoreURLResponse.h"
-#if USE(QUICK_LOOK)
-#import "QuickLook.h"
-#endif
-
using namespace WebCore;
@implementation WebCoreResourceHandleAsDelegate
@@ -146,20 +142,8 @@
[response _setMIMEType:@"text/html"];
#endif
-#if USE(QUICK_LOOK)
- bool isQuickLookPreview = false;
- m_handle->setQuickLookHandle(QuickLookHandle::create(m_handle, connection, response, self));
- if (m_handle->quickLookHandle()) {
- response = m_handle->quickLookHandle()->nsResponse();
- isQuickLookPreview = true;
- }
-#endif
-
ResourceResponse resourceResponse(response);
resourceResponse.setSource(ResourceResponse::Source::Network);
-#if USE(QUICK_LOOK)
- resourceResponse.setIsQuickLook(isQuickLookPreview);
-#endif
#if ENABLE(WEB_TIMING)
ResourceHandle::getConnectionTimingData(connection, resourceResponse.networkLoadTiming());
#else
@@ -181,11 +165,6 @@
if (!m_handle || !m_handle->client())
return;
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle() && m_handle->quickLookHandle()->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray)))
- return;
-#endif
-
m_handle->client()->didReceiveBuffer(m_handle, SharedBuffer::wrapCFDataArray(reinterpret_cast<CFArrayRef>(dataArray)), -1);
// The call to didReceiveData above can cancel a load, and if so, the delegate (self) could have been deallocated by this point.
}
@@ -209,11 +188,6 @@
// However, with today's computers and networking speeds, this won't happen in practice.
// Could be an issue with a giant local file.
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle() && m_handle->quickLookHandle()->didReceiveData(reinterpret_cast<CFDataRef>(data)))
- return;
-#endif
-
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=19793
// -1 means we do not provide any data about transfer size to inspector so it would use
// Content-Length headers or content size to show transfer size.
@@ -241,11 +215,6 @@
if (!m_handle || !m_handle->client())
return;
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle() && m_handle->quickLookHandle()->didFinishLoading())
- return;
-#endif
-
m_handle->client()->didFinishLoading(m_handle, 0);
}
@@ -258,11 +227,6 @@
if (!m_handle || !m_handle->client())
return;
-#if USE(QUICK_LOOK)
- if (m_handle->quickLookHandle())
- m_handle->quickLookHandle()->didFail();
-#endif
-
m_handle->client()->didFail(m_handle, error);
}
Modified: trunk/Source/WebKit2/ChangeLog (210479 => 210480)
--- trunk/Source/WebKit2/ChangeLog 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebKit2/ChangeLog 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,3 +1,17 @@
+2017-01-07 Andy Estes <[email protected]>
+
+ [QuickLook] Consolidate usage of QuickLookHandle into SubresourceLoader
+ https://bugs.webkit.org/show_bug.cgi?id=166713
+
+ Reviewed by Alex Christensen.
+
+ * WebProcess/Network/WebResourceLoader.cpp:
+ (WebKit::WebResourceLoader::didReceiveResponse): Removed QuickLook code.
+ (WebKit::WebResourceLoader::didReceiveData): Ditto.
+ (WebKit::WebResourceLoader::didFinishResourceLoad): Ditto.
+ (WebKit::WebResourceLoader::didFailResourceLoad): Ditto.
+ (WebKit::WebResourceLoader::didReceiveResource): Ditto.
+
2017-01-06 Daniel Bates <[email protected]>
Attempt to fix the EFL build following <http://trac.webkit.org/changeset/210461>
Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (210479 => 210480)
--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2017-01-07 18:51:46 UTC (rev 210479)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2017-01-07 21:00:30 UTC (rev 210480)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -44,10 +44,6 @@
#include <WebCore/ResourceLoader.h>
#include <WebCore/SubresourceLoader.h>
-#if USE(QUICK_LOOK)
-#include <WebCore/QuickLook.h>
-#endif
-
using namespace WebCore;
#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - WebResourceLoader::" fmt, this, ##__VA_ARGS__)
@@ -117,19 +113,7 @@
if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(m_coreLoader.get(), response))
return;
- bool shoudCallCoreLoaderDidReceiveResponse = true;
-#if USE(QUICK_LOOK)
- // 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.
- bool isMainLoad = m_coreLoader->documentLoader()->mainResourceLoader() == m_coreLoader;
- if (isMainLoad && QuickLookHandle::shouldCreateForMIMEType(response.mimeType())) {
- m_coreLoader->documentLoader()->setQuickLookHandle(QuickLookHandle::create(*m_coreLoader, response));
- shoudCallCoreLoaderDidReceiveResponse = false;
- }
-#endif
- if (shoudCallCoreLoaderDidReceiveResponse)
- m_coreLoader->didReceiveResponse(response);
+ m_coreLoader->didReceiveResponse(response);
// If m_coreLoader becomes null as a result of the didReceiveResponse callback, we can't use the send function().
if (!m_coreLoader)
@@ -148,12 +132,6 @@
m_hasReceivedData = true;
}
-#if USE(QUICK_LOOK)
- if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
- if (quickLookHandle->didReceiveData(adoptCF(CFDataCreate(kCFAllocatorDefault, data.data(), data.size())).get()))
- return;
- }
-#endif
m_coreLoader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, DataPayloadBytes);
}
@@ -162,12 +140,6 @@
LOG(Network, "(WebProcess) WebResourceLoader::didFinishResourceLoad for '%s'", m_coreLoader->url().string().latin1().data());
RELEASE_LOG_IF_ALLOWED("didFinishResourceLoad: (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_trackingParameters.pageID, m_trackingParameters.frameID, m_trackingParameters.resourceID);
-#if USE(QUICK_LOOK)
- if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
- if (quickLookHandle->didFinishLoading())
- return;
- }
-#endif
m_coreLoader->didFinishLoading(finishTime);
}
@@ -176,10 +148,6 @@
LOG(Network, "(WebProcess) WebResourceLoader::didFailResourceLoad for '%s'", m_coreLoader->url().string().latin1().data());
RELEASE_LOG_IF_ALLOWED("didFailResourceLoad: (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_trackingParameters.pageID, m_trackingParameters.frameID, m_trackingParameters.resourceID);
-#if USE(QUICK_LOOK)
- if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle())
- quickLookHandle->didFail();
-#endif
if (m_coreLoader->documentLoader()->applicationCacheHost()->maybeLoadFallbackForError(m_coreLoader.get(), error))
return;
m_coreLoader->didFail(error);
@@ -193,18 +161,6 @@
RefPtr<SharedBuffer> buffer = handle.tryWrapInSharedBuffer();
-#if USE(QUICK_LOOK)
- if (QuickLookHandle* quickLookHandle = m_coreLoader->documentLoader()->quickLookHandle()) {
- if (buffer) {
- if (quickLookHandle->didReceiveData(buffer->existingCFData())) {
- quickLookHandle->didFinishLoading();
- return;
- }
- } else
- quickLookHandle->didFail();
- }
-#endif
-
if (!buffer) {
LOG_ERROR("Unable to create buffer from ShareableResource sent from the network process.");
RELEASE_LOG_IF_ALLOWED("didReceiveResource: Unable to create SharedBuffer (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_trackingParameters.pageID, m_trackingParameters.frameID, m_trackingParameters.resourceID);