<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210789] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210789">210789</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2017-01-16 14:14:27 -0800 (Mon, 16 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[QuickLook] Do some cleanup in QuickLookHandle
https://bugs.webkit.org/show_bug.cgi?id=166864
Reviewed by Darin Adler.
Source/WebCore:
* loader/ios/QuickLook.h: Stopped including QuickLookHandleClient.h and forward-declared
instead; changed setClient() to take a Ref<QuickLookHandleClient>&&; renamed nsResponse() to
previewResponse(); changed QuickLookHandle() to take a ResourceLoader& and const
ResourceResponse&; gave m_delegate a stronger type; removed unused m_quicklookFileHandle;
initialized m_finishedLoadingDataIntoConverter to false.
(WebCore::QuickLookHandle::firstRequestURL): Stopped exporting.
(WebCore::QuickLookHandle::setClient): Moved definition out-of-line.
* loader/ios/QuickLook.mm: Renamed WebResourceLoaderQuickLookDelegate to
WebPreviewConverterDelegate and stopped conforming to NSURLConnectionDelegate and
WebCoreResourceLoaderDelegate; removed @property quickLookHandle and initialized
_quickLookHandle in the initializer instead.
(-[WebPreviewConverter initWithResourceLoader:quickLookHandle:]): Changed to take references
to resourceLoader and quickLookHandle.
(-[WebPreviewConverter _sendDidReceiveResponseIfNecessary]): Stoped checking for a nil
_quickLookHandle, since it is never nil.
(-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): Deleted.
QLPreviewConverter never calls this method.
(-[WebPreviewConverter connection:didReceiveData:lengthReceived:]): Stopped checking for a
nil _resourceLoader, since it is never nil.
(-[WebPreviewConverter connectionDidFinishLoading:]): Ditto.
(-[WebPreviewConverter connection:didFailWithError:]): Ditto.
(WebCore::emptyClient): Changed to return a reference.
(WebCore::QuickLookHandle::QuickLookHandle): Moved creation of the delegate,
firstRequestURL, and response to here from QuickLookHandle::create(). Called
ResourceLoader::didCreateQuickLookHandle() here instead of in QuickLookHandle::create().
(WebCore::QuickLookHandle::create): Used std::make_unique to create the QuickLookHandle.
(WebCore::QuickLookHandle::didFinishLoading): Set m_finishedLoadingDataIntoConverter to true
instead of YES.
(WebCore::QuickLookHandle::setClient): Moved the client rvalue reference into m_client.
(WebCore::QuickLookHandle::~QuickLookHandle): Stopped clearing m_converter and calling
-detachHandle.
(WebCore::QuickLookHandle::previewRequestURL): Used dot syntax.
(WebCore::QuickLookHandle::previewResponse): Renamed from nsResponse().
Source/WebKit/mac:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::didCreateQuickLookHandle): Changed to pass a
Ref<QuickLookHandleClient>&& to QuickLookHandle::setClient().</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderiosQuickLookh">trunk/Source/WebCore/loader/ios/QuickLook.h</a></li>
<li><a href="#trunkSourceWebCoreloaderiosQuickLookmm">trunk/Source/WebCore/loader/ios/QuickLook.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210788 => 210789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-16 21:11:53 UTC (rev 210788)
+++ trunk/Source/WebCore/ChangeLog        2017-01-16 22:14:27 UTC (rev 210789)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2017-01-16 Andy Estes <aestes@apple.com>
+
+ [QuickLook] Do some cleanup in QuickLookHandle
+ https://bugs.webkit.org/show_bug.cgi?id=166864
+
+ Reviewed by Darin Adler.
+
+ * loader/ios/QuickLook.h: Stopped including QuickLookHandleClient.h and forward-declared
+ instead; changed setClient() to take a Ref<QuickLookHandleClient>&&; renamed nsResponse() to
+ previewResponse(); changed QuickLookHandle() to take a ResourceLoader& and const
+ ResourceResponse&; gave m_delegate a stronger type; removed unused m_quicklookFileHandle;
+ initialized m_finishedLoadingDataIntoConverter to false.
+ (WebCore::QuickLookHandle::firstRequestURL): Stopped exporting.
+ (WebCore::QuickLookHandle::setClient): Moved definition out-of-line.
+ * loader/ios/QuickLook.mm: Renamed WebResourceLoaderQuickLookDelegate to
+ WebPreviewConverterDelegate and stopped conforming to NSURLConnectionDelegate and
+ WebCoreResourceLoaderDelegate; removed @property quickLookHandle and initialized
+ _quickLookHandle in the initializer instead.
+ (-[WebPreviewConverter initWithResourceLoader:quickLookHandle:]): Changed to take references
+ to resourceLoader and quickLookHandle.
+ (-[WebPreviewConverter _sendDidReceiveResponseIfNecessary]): Stoped checking for a nil
+ _quickLookHandle, since it is never nil.
+ (-[WebResourceLoaderQuickLookDelegate connection:didReceiveDataArray:]): Deleted.
+ QLPreviewConverter never calls this method.
+ (-[WebPreviewConverter connection:didReceiveData:lengthReceived:]): Stopped checking for a
+ nil _resourceLoader, since it is never nil.
+ (-[WebPreviewConverter connectionDidFinishLoading:]): Ditto.
+ (-[WebPreviewConverter connection:didFailWithError:]): Ditto.
+ (WebCore::emptyClient): Changed to return a reference.
+ (WebCore::QuickLookHandle::QuickLookHandle): Moved creation of the delegate,
+ firstRequestURL, and response to here from QuickLookHandle::create(). Called
+ ResourceLoader::didCreateQuickLookHandle() here instead of in QuickLookHandle::create().
+ (WebCore::QuickLookHandle::create): Used std::make_unique to create the QuickLookHandle.
+ (WebCore::QuickLookHandle::didFinishLoading): Set m_finishedLoadingDataIntoConverter to true
+ instead of YES.
+ (WebCore::QuickLookHandle::setClient): Moved the client rvalue reference into m_client.
+ (WebCore::QuickLookHandle::~QuickLookHandle): Stopped clearing m_converter and calling
+ -detachHandle.
+ (WebCore::QuickLookHandle::previewRequestURL): Used dot syntax.
+ (WebCore::QuickLookHandle::previewResponse): Renamed from nsResponse().
+
</ins><span class="cx"> 2017-01-16 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove CSSPropertyNames.in from the project. It's not used any more,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderiosQuickLookh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ios/QuickLook.h (210788 => 210789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ios/QuickLook.h        2017-01-16 21:11:53 UTC (rev 210788)
+++ trunk/Source/WebCore/loader/ios/QuickLook.h        2017-01-16 22:14:27 UTC (rev 210789)
</span><span class="lines">@@ -27,16 +27,14 @@
</span><span class="cx">
</span><span class="cx"> #if USE(QUICK_LOOK)
</span><span class="cx">
</span><del>-#include "QuickLookHandleClient.h"
</del><span class="cx"> #include <objc/objc.h>
</span><span class="cx"> #include <wtf/Forward.h>
</span><del>-#include <wtf/RefPtr.h>
</del><ins>+#include <wtf/Ref.h>
</ins><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx">
</span><span class="cx"> OBJC_CLASS NSArray;
</span><span class="cx"> OBJC_CLASS NSData;
</span><span class="cx"> OBJC_CLASS NSDictionary;
</span><del>-OBJC_CLASS NSFileHandle;
</del><span class="cx"> OBJC_CLASS NSSet;
</span><span class="cx"> OBJC_CLASS NSString;
</span><span class="cx"> OBJC_CLASS NSURL;
</span><span class="lines">@@ -43,9 +41,11 @@
</span><span class="cx"> OBJC_CLASS NSURLRequest;
</span><span class="cx"> OBJC_CLASS NSURLResponse;
</span><span class="cx"> OBJC_CLASS QLPreviewConverter;
</span><ins>+OBJC_CLASS WebPreviewConverterDelegate;
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class QuickLookHandleClient;
</ins><span class="cx"> class ResourceLoader;
</span><span class="cx"> class ResourceResponse;
</span><span class="cx"> class SharedBuffer;
</span><span class="lines">@@ -82,28 +82,27 @@
</span><span class="cx"> bool didFinishLoading();
</span><span class="cx"> void didFail();
</span><span class="cx">
</span><del>- WEBCORE_EXPORT NSURLResponse *nsResponse();
</del><ins>+ WEBCORE_EXPORT void setClient(Ref<QuickLookHandleClient>&&);
</ins><span class="cx">
</span><del>- void setClient(PassRefPtr<QuickLookHandleClient> client) { m_client = client; }
-
</del><span class="cx"> WEBCORE_EXPORT String previewFileName() const;
</span><span class="cx"> WEBCORE_EXPORT String previewUTI() const;
</span><ins>+ WEBCORE_EXPORT NSURL *previewRequestURL() const;
+ NSURLResponse *previewResponse() const;
</ins><span class="cx"> NSURL *firstRequestURL() const { return m_firstRequestURL.get(); }
</span><del>- WEBCORE_EXPORT NSURL *previewRequestURL() const;
</del><span class="cx"> QLPreviewConverter *converter() const { return m_converter.get(); }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- QuickLookHandle(NSURL *, NSURLResponse *, id delegate);
</del><ins>+ friend std::unique_ptr<QuickLookHandle> std::make_unique<QuickLookHandle>(ResourceLoader&, const ResourceResponse&);
+ QuickLookHandle(ResourceLoader&, const ResourceResponse&);
</ins><span class="cx">
</span><span class="cx"> void didReceiveDataArray(NSArray *);
</span><span class="cx">
</span><span class="cx"> RetainPtr<NSURL> m_firstRequestURL;
</span><ins>+ RetainPtr<WebPreviewConverterDelegate> m_delegate;
</ins><span class="cx"> RetainPtr<QLPreviewConverter> m_converter;
</span><del>- RetainPtr<id> m_delegate;
- bool m_finishedLoadingDataIntoConverter;
- RetainPtr<NSFileHandle *> m_quicklookFileHandle;
- RetainPtr<NSURLResponse> m_nsResponse;
- RefPtr<QuickLookHandleClient> m_client;
</del><ins>+ RetainPtr<NSURLResponse> m_previewResponse;
+ Ref<QuickLookHandleClient> m_client;
+ bool m_finishedLoadingDataIntoConverter { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderiosQuickLookmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ios/QuickLook.mm (210788 => 210789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ios/QuickLook.mm        2017-01-16 21:11:53 UTC (rev 210788)
+++ trunk/Source/WebCore/loader/ios/QuickLook.mm        2017-01-16 22:14:27 UTC (rev 210789)
</span><span class="lines">@@ -31,11 +31,10 @@
</span><span class="cx"> #import "FileSystemIOS.h"
</span><span class="cx"> #import "Logging.h"
</span><span class="cx"> #import "NSFileManagerSPI.h"
</span><ins>+#import "QuickLookHandleClient.h"
</ins><span class="cx"> #import "ResourceError.h"
</span><span class="cx"> #import "ResourceLoader.h"
</span><span class="cx"> #import "SharedBuffer.h"
</span><del>-#import "WebCoreResourceHandleAsDelegate.h"
-#import <Foundation/Foundation.h>
</del><span class="cx"> #import <wtf/NeverDestroyed.h>
</span><span class="cx"> #import <wtf/Vector.h>
</span><span class="cx"> #import <wtf/text/WTFString.h>
</span><span class="lines">@@ -179,41 +178,42 @@
</span><span class="cx"> return previewProtocol.get().data();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-@interface WebResourceLoaderQuickLookDelegate : NSObject <NSURLConnectionDelegate, WebCoreResourceLoaderDelegate> {
</del><ins>+@interface WebPreviewConverterDelegate : NSObject {
</ins><span class="cx"> RefPtr<ResourceLoader> _resourceLoader;
</span><ins>+ QuickLookHandle* _quickLookHandle;
</ins><span class="cx"> BOOL _hasSentDidReceiveResponse;
</span><span class="cx"> BOOL _hasFailed;
</span><span class="cx"> }
</span><del>-@property (nonatomic) QuickLookHandle* quickLookHandle;
</del><span class="cx"> @end
</span><span class="cx">
</span><del>-@implementation WebResourceLoaderQuickLookDelegate
</del><ins>+@implementation WebPreviewConverterDelegate
</ins><span class="cx">
</span><del>-- (id)initWithResourceLoader:(PassRefPtr<ResourceLoader>)resourceLoader
</del><ins>+- (id)initWithResourceLoader:(ResourceLoader&)resourceLoader quickLookHandle:(QuickLookHandle&)quickLookHandle
</ins><span class="cx"> {
</span><span class="cx"> self = [super init];
</span><span class="cx"> if (!self)
</span><span class="cx"> return nil;
</span><span class="cx">
</span><del>- _resourceLoader = resourceLoader;
</del><ins>+ _resourceLoader = &resourceLoader;
+ _quickLookHandle = &quickLookHandle;
</ins><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)_sendDidReceiveResponseIfNecessary
</span><span class="cx"> {
</span><del>- if (_hasSentDidReceiveResponse || _hasFailed || !_quickLookHandle)
</del><ins>+ if (_hasSentDidReceiveResponse || _hasFailed)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // QuickLook might fail to convert a document without calling connection:didFailWithError: (see <rdar://problem/17927972>).
</span><span class="cx"> // A nil MIME type is an indication of such a failure, so stop loading the resource and ignore subsequent delegate messages.
</span><del>- NSURLResponse *nsResponse = _quickLookHandle->nsResponse();
- if (![nsResponse MIMEType]) {
</del><ins>+ NSURLResponse *previewResponse = _quickLookHandle->previewResponse();
+ if (!previewResponse.MIMEType) {
</ins><span class="cx"> _hasFailed = YES;
</span><span class="cx"> _resourceLoader->didFail(_resourceLoader->cannotShowURLError());
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- ResourceResponse response(nsResponse);
</del><ins>+ ResourceResponse response { previewResponse };
</ins><span class="cx"> response.setIsQuickLook(true);
</span><span class="cx">
</span><span class="cx"> _hasSentDidReceiveResponse = YES;
</span><span class="lines">@@ -220,28 +220,9 @@
</span><span class="cx"> _resourceLoader->didReceiveResponse(response);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
-- (void)connection:(NSURLConnection *)connection didReceiveDataArray:(NSArray *)dataArray
-{
- UNUSED_PARAM(connection);
- if (!_resourceLoader)
- return;
-
- [self _sendDidReceiveResponseIfNecessary];
- if (_hasFailed)
- return;
-
- if (_resourceLoader)
- _resourceLoader->didReceiveDataArray(reinterpret_cast<CFArrayRef>(dataArray));
-}
-#endif
-
</del><span class="cx"> - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(connection);
</span><del>- if (!_resourceLoader)
- return;
-
</del><span class="cx"> [self _sendDidReceiveResponseIfNecessary];
</span><span class="cx"> if (_hasFailed)
</span><span class="cx"> return;
</span><span class="lines">@@ -248,17 +229,14 @@
</span><span class="cx">
</span><span class="cx"> // QuickLook code sends us a nil data at times. The check below is the same as the one in
</span><span class="cx"> // ResourceHandleMac.cpp added for a different bug.
</span><del>- if (![data length])
- return;
-
- if (_resourceLoader)
- _resourceLoader->didReceiveData(reinterpret_cast<const char*>([data bytes]), [data length], lengthReceived, DataPayloadBytes);
</del><ins>+ if (auto dataLength = data.length)
+ _resourceLoader->didReceiveData(reinterpret_cast<const char*>(data.bytes), dataLength, lengthReceived, DataPayloadBytes);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)connectionDidFinishLoading:(NSURLConnection *)connection
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(connection);
</span><del>- if (!_resourceLoader || _hasFailed)
</del><ins>+ if (_hasFailed)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> ASSERT(_hasSentDidReceiveResponse);
</span><span class="lines">@@ -268,21 +246,11 @@
</span><span class="cx"> - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(connection);
</span><del>-
</del><span class="cx"> [self _sendDidReceiveResponseIfNecessary];
</span><del>- if (_hasFailed)
- return;
-
- if (_resourceLoader)
- _resourceLoader->didFail(ResourceError(error));
</del><ins>+ if (!_hasFailed)
+ _resourceLoader->didFail(error);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)detachHandle
-{
- _resourceLoader = nullptr;
- _quickLookHandle = nullptr;
-}
-
</del><span class="cx"> @end
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -305,21 +273,21 @@
</span><span class="cx"> return success ? uniqueContentPath : nil;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline QuickLookHandleClient* emptyClient()
</del><ins>+static inline QuickLookHandleClient& emptyClient()
</ins><span class="cx"> {
</span><del>- static NeverDestroyed<QuickLookHandleClient> emptyClient;
- return &emptyClient.get();
</del><ins>+ static auto& emptyClient = adoptRef(*new QuickLookHandleClient()).leakRef();
+ return emptyClient;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-QuickLookHandle::QuickLookHandle(NSURL *firstRequestURL, NSURLResponse *nsResponse, id delegate)
- : m_firstRequestURL(firstRequestURL)
- , m_converter(adoptNS([allocQLPreviewConverterInstance() initWithConnection:nil delegate:delegate response:nsResponse options:nil]))
- , m_delegate(delegate)
- , m_finishedLoadingDataIntoConverter(false)
- , m_nsResponse([m_converter previewResponse])
- , m_client(emptyClient())
</del><ins>+QuickLookHandle::QuickLookHandle(ResourceLoader& loader, const ResourceResponse& response)
+ : m_firstRequestURL { loader.originalRequest().nsURLRequest(DoNotUpdateHTTPBody).URL }
+ , m_delegate { adoptNS([[WebPreviewConverterDelegate alloc] initWithResourceLoader:loader quickLookHandle:*this]) }
+ , m_converter { adoptNS([allocQLPreviewConverterInstance() initWithConnection:nil delegate:m_delegate.get() response:response.nsURLResponse() options:nil]) }
+ , m_previewResponse { [m_converter previewResponse] }
+ , m_client { emptyClient() }
</ins><span class="cx"> {
</span><span class="cx"> LOG(Network, "QuickLookHandle::QuickLookHandle() - previewFileName: %s", [m_converter previewFileName]);
</span><ins>+ loader.didCreateQuickLookHandle(*this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool QuickLookHandle::shouldCreateForMIMEType(const String& mimeType)
</span><span class="lines">@@ -330,19 +298,9 @@
</span><span class="cx"> std::unique_ptr<QuickLookHandle> QuickLookHandle::create(ResourceLoader& loader, const ResourceResponse& response)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(shouldCreateForMIMEType(response.mimeType()));
</span><del>-
- RetainPtr<WebResourceLoaderQuickLookDelegate> delegate = adoptNS([[WebResourceLoaderQuickLookDelegate alloc] initWithResourceLoader:&loader]);
- 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;
</del><ins>+ return std::make_unique<QuickLookHandle>(loader, response);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-NSURLResponse *QuickLookHandle::nsResponse()
-{
- return m_nsResponse.get();
-}
-
</del><span class="cx"> bool QuickLookHandle::didReceiveData(const char* data, unsigned length)
</span><span class="cx"> {
</span><span class="cx"> if (m_finishedLoadingDataIntoConverter)
</span><span class="lines">@@ -375,7 +333,7 @@
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> LOG(Network, "QuickLookHandle::didFinishLoading()");
</span><del>- m_finishedLoadingDataIntoConverter = YES;
</del><ins>+ m_finishedLoadingDataIntoConverter = true;
</ins><span class="cx"> [m_converter finishedAppendingData];
</span><span class="cx"> m_client->didFinishLoading();
</span><span class="cx"> return true;
</span><span class="lines">@@ -389,12 +347,14 @@
</span><span class="cx"> m_converter = nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void QuickLookHandle::setClient(Ref<QuickLookHandleClient>&& client)
+{
+ m_client = WTFMove(client);
+}
+
</ins><span class="cx"> QuickLookHandle::~QuickLookHandle()
</span><span class="cx"> {
</span><span class="cx"> LOG(Network, "QuickLookHandle::~QuickLookHandle()");
</span><del>- m_converter = nullptr;
-
- [m_delegate detachHandle];
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String QuickLookHandle::previewFileName() const
</span><span class="lines">@@ -409,9 +369,14 @@
</span><span class="cx">
</span><span class="cx"> NSURL *QuickLookHandle::previewRequestURL() const
</span><span class="cx"> {
</span><del>- return [[m_converter previewRequest] URL];
</del><ins>+ return [m_converter previewRequest].URL;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+NSURLResponse *QuickLookHandle::previewResponse() const
+{
+ return m_previewResponse.get();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif // USE(QUICK_LOOK)
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (210788 => 210789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-01-16 21:11:53 UTC (rev 210788)
+++ trunk/Source/WebKit/mac/ChangeLog        2017-01-16 22:14:27 UTC (rev 210789)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-01-16 Andy Estes <aestes@apple.com>
+
+ [QuickLook] Do some cleanup in QuickLookHandle
+ https://bugs.webkit.org/show_bug.cgi?id=166864
+
+ Reviewed by Darin Adler.
+
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::didCreateQuickLookHandle): Changed to pass a
+ Ref<QuickLookHandleClient>&& to QuickLookHandle::setClient().
+
</ins><span class="cx"> 2017-01-15 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> De-duplicate more (nearly) identical code in Editor(Mac|IOS).mm
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (210788 => 210789)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2017-01-16 21:11:53 UTC (rev 210788)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2017-01-16 22:14:27 UTC (rev 210789)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx"> #import <WebCore/FileSystemIOS.h>
</span><span class="cx"> #import <WebCore/NSFileManagerSPI.h>
</span><span class="cx"> #import <WebCore/QuickLook.h>
</span><ins>+#import <WebCore/QuickLookHandleClient.h>
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if HAVE(APP_LINKS)
</span><span class="lines">@@ -2283,7 +2284,7 @@
</span><span class="cx"> removeQLPreviewConverterForURL(m_firstRequestURL.get());
</span><span class="cx"> }
</span><span class="cx"> };
</span><del>- handle.setClient(adoptRef(new QuickLookDocumentWriter(handle)));
</del><ins>+ handle.setClient(adoptRef(*new QuickLookDocumentWriter(handle)));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>