<!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>[199669] 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/199669">199669</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-04-18 08:36:34 -0700 (Mon, 18 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/199644">r199644</a>.

Seems to have caused a 1-2% regression on warm PLT

Reverted changeset:

&quot;[WK2][iOS] Do not dlopen() QuickLook in the NetworkProcess&quot;
https://bugs.webkit.org/show_bug.cgi?id=156639
http://trac.webkit.org/changeset/199644</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcfSynchronousResourceHandleCFURLConnectionDelegatecpp">trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosQuickLookh">trunk/Source/WebCore/platform/network/ios/QuickLook.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosQuickLookmm">trunk/Source/WebCore/platform/network/ios/QuickLook.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosWebCoreURLResponseIOSmm">trunk/Source/WebCore/platform/network/ios/WebCoreURLResponseIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkmacWebCoreResourceHandleAsDelegatemm">trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadercpp">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebCore/ChangeLog        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-04-18  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Unreviewed, rolling out r199644.
+
+        Seems to have caused a 1-2% regression on warm PLT
+
+        Reverted changeset:
+
+        &quot;[WK2][iOS] Do not dlopen() QuickLook in the NetworkProcess&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=156639
+        http://trac.webkit.org/changeset/199644
+
</ins><span class="cx"> 2016-04-17  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Get rid of IDBAny
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcfSynchronousResourceHandleCFURLConnectionDelegatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebCore/platform/network/cf/SynchronousResourceHandleCFURLConnectionDelegate.cpp        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -166,10 +166,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(QUICK_LOOK)
</span><del>-    if (auto quickLookHandle = QuickLookHandle::createIfNecessary(*m_handle, this, cfResponse)) {
-        cfResponse = quickLookHandle-&gt;cfResponse();
-        m_handle-&gt;setQuickLookHandle(WTFMove(quickLookHandle));
-    }
</del><ins>+    m_handle-&gt;setQuickLookHandle(QuickLookHandle::create(m_handle, this, cfResponse));
+    if (m_handle-&gt;quickLookHandle())
+        cfResponse = m_handle-&gt;quickLookHandle()-&gt;cfResponse();
</ins><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx">     ResourceResponse resourceResponse(cfResponse);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosQuickLookh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.h (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/QuickLook.h        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.h        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -78,13 +78,14 @@
</span><span class="cx"> class QuickLookHandle {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(QuickLookHandle);
</span><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;QuickLookHandle&gt; createIfNecessary(ResourceHandle&amp;, NSURLConnection *, NSURLResponse *, id delegate);
</del><ins>+    WEBCORE_EXPORT static bool shouldCreateForMIMEType(const String&amp;);
+
+    static std::unique_ptr&lt;QuickLookHandle&gt; create(ResourceHandle*, NSURLConnection *, NSURLResponse *, id delegate);
</ins><span class="cx"> #if USE(CFNETWORK)
</span><del>-    static std::unique_ptr&lt;QuickLookHandle&gt; createIfNecessary(ResourceHandle&amp;, SynchronousResourceHandleCFURLConnectionDelegate*, CFURLResponseRef);
</del><ins>+    static std::unique_ptr&lt;QuickLookHandle&gt; create(ResourceHandle*, SynchronousResourceHandleCFURLConnectionDelegate*, CFURLResponseRef);
</ins><span class="cx"> #endif
</span><del>-
</del><span class="cx">     // FIXME: Use of ResourceLoader here is a platform violation.
</span><del>-    WEBCORE_EXPORT static std::unique_ptr&lt;QuickLookHandle&gt; createIfNecessary(ResourceLoader&amp;, NSURLResponse *);
</del><ins>+    WEBCORE_EXPORT static std::unique_ptr&lt;QuickLookHandle&gt; create(ResourceLoader&amp;, const ResourceResponse&amp;);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT ~QuickLookHandle();
</span><span class="cx"> 
</span><span class="lines">@@ -107,7 +108,6 @@
</span><span class="cx">     QLPreviewConverter *converter() const { return m_converter.get(); }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    static std::unique_ptr&lt;QuickLookHandle&gt; create(ResourceHandle&amp;, NSURLConnection *, NSURLResponse *, id delegate);
</del><span class="cx">     QuickLookHandle(NSURL *, NSURLConnection *, NSURLResponse *, id delegate);
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSURL&gt; m_firstRequestURL;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosQuickLookmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.mm (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/QuickLook.mm        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.mm        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -36,14 +36,10 @@
</span><span class="cx"> #import &quot;ResourceHandle.h&quot;
</span><span class="cx"> #import &quot;ResourceLoader.h&quot;
</span><span class="cx"> #import &quot;RuntimeApplicationChecks.h&quot;
</span><del>-#import &quot;SubresourceLoader.h&quot;
</del><span class="cx"> #import &quot;SynchronousResourceHandleCFURLConnectionDelegate.h&quot;
</span><del>-#import &quot;UTIUtilities.h&quot;
</del><span class="cx"> #import &quot;WebCoreResourceHandleAsDelegate.h&quot;
</span><del>-#import &quot;WebCoreSystemInterface.h&quot;
</del><span class="cx"> #import &quot;WebCoreURLResponseIOS.h&quot;
</span><span class="cx"> #import &lt;Foundation/Foundation.h&gt;
</span><del>-#import &lt;MobileCoreServices/MobileCoreServices.h&gt;
</del><span class="cx"> #import &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #import &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> #import &lt;wtf/Threading.h&gt;
</span><span class="lines">@@ -52,14 +48,6 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;QuickLookSoftLink.h&quot;
</span><span class="cx"> 
</span><del>-SOFT_LINK_FRAMEWORK(MobileCoreServices)
-
-SOFT_LINK(MobileCoreServices, UTTypeCreatePreferredIdentifierForTag, CFStringRef, (CFStringRef inTagClass, CFStringRef inTag, CFStringRef inConformingToUTI), (inTagClass, inTag, inConformingToUTI))
-
-SOFT_LINK_CONSTANT(MobileCoreServices, kUTTagClassFilenameExtension, CFStringRef)
-
-#define kUTTagClassFilenameExtension getkUTTagClassFilenameExtension()
-
</del><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="cx"> NSSet *WebCore::QLPreviewGetSupportedMIMETypesSet()
</span><span class="lines">@@ -108,43 +96,6 @@
</span><span class="cx">     return contentDictionary;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// We must ensure that the MIME type is correct, so that QuickLook's web plugin is called when needed.
-// We filter the basic MIME types so that we don't do unnecessary work in standard browsing situations.
-static RetainPtr&lt;CFStringRef&gt; adjustMIMETypeForQuickLook(CFURLResponseRef cfResponse)
-{
-    RetainPtr&lt;CFStringRef&gt; mimeType = CFURLResponseGetMIMEType(cfResponse);
-    if (!shouldUseQuickLookForMIMEType(mimeType.get()))
-        return mimeType;
-
-    RetainPtr&lt;CFStringRef&gt; suggestedFilename = adoptCF(CFURLResponseCopySuggestedFilename(cfResponse));
-    RetainPtr&lt;CFStringRef&gt; quickLookMIMEType = adoptCF((CFStringRef)QLTypeCopyBestMimeTypeForFileNameAndMimeType((NSString *)suggestedFilename.get(), (NSString *)mimeType.get()));
-    if (!quickLookMIMEType) {
-        auto url = CFURLResponseGetURL(cfResponse);
-        if (![(NSURL *)url isFileURL])
-            return mimeType;
-        RetainPtr&lt;CFStringRef&gt; extension = adoptCF(CFURLCopyPathExtension(url));
-        if (!extension)
-            return mimeType;
-        RetainPtr&lt;CFStringRef&gt; uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extension.get(), nullptr));
-        quickLookMIMEType = mimeTypeFromUTITree(uti.get());
-        if (!quickLookMIMEType)
-            return mimeType;
-    }
-
-    if (!mimeType || CFStringCompare(mimeType.get(), quickLookMIMEType.get(), kCFCompareCaseInsensitive) != kCFCompareEqualTo) {
-        CFURLResponseSetMIMEType(cfResponse, quickLookMIMEType.get());
-        return quickLookMIMEType;
-    }
-
-    return mimeType;
-}
-
-static bool shouldCreateForResponse(CFURLResponseRef cfResponse)
-{
-    RetainPtr&lt;CFStringRef&gt; mimeType = adjustMIMETypeForQuickLook(cfResponse);
-    return [QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)mimeType.get()];
-}
-
</del><span class="cx"> void WebCore::addQLPreviewConverterWithFileForURL(NSURL *url, id converter, NSString *fileName)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(url);
</span><span class="lines">@@ -445,35 +396,29 @@
</span><span class="cx">     LOG(Network, &quot;QuickLookHandle::QuickLookHandle() - previewFileName: %s&quot;, [m_converter previewFileName]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool shouldCreate(ResourceHandle&amp; handle, CFURLResponseRef response)
</del><ins>+std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceHandle* handle, NSURLConnection *connection, NSURLResponse *nsResponse, id delegate)
</ins><span class="cx"> {
</span><del>-    return handle.firstRequest().requester() == ResourceRequest::Requester::Main &amp;&amp; shouldCreateForResponse(response);
-}
</del><ins>+    ASSERT_ARG(handle, handle);
+    if (handle-&gt;firstRequest().requester() != ResourceRequest::Requester::Main || ![QLPreviewGetSupportedMIMETypesSet() containsObject:[nsResponse MIMEType]])
+        return nullptr;
</ins><span class="cx"> 
</span><del>-std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceHandle&amp; handle, NSURLConnection *connection, NSURLResponse *response, id delegate)
-{
-    std::unique_ptr&lt;QuickLookHandle&gt; quickLookHandle(new QuickLookHandle([handle.firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], connection, response, delegate));
-    handle.client()-&gt;didCreateQuickLookHandle(*quickLookHandle);
</del><ins>+    std::unique_ptr&lt;QuickLookHandle&gt; quickLookHandle(new QuickLookHandle([handle-&gt;firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], connection, nsResponse, delegate));
+    handle-&gt;client()-&gt;didCreateQuickLookHandle(*quickLookHandle);
</ins><span class="cx">     return quickLookHandle;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::createIfNecessary(ResourceHandle&amp; handle, NSURLConnection *connection, NSURLResponse *response, id delegate)
-{
-    if (!shouldCreate(handle, response._CFURLResponse))
-        return nullptr;
-
-    return create(handle, connection, response, delegate);
-}
-
</del><span class="cx"> #if USE(CFNETWORK)
</span><del>-std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::createIfNecessary(ResourceHandle&amp; handle, SynchronousResourceHandleCFURLConnectionDelegate* connectionDelegate, CFURLResponseRef cfResponse)
</del><ins>+std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceHandle* handle, SynchronousResourceHandleCFURLConnectionDelegate* connectionDelegate, CFURLResponseRef cfResponse)
</ins><span class="cx"> {
</span><del>-    if (!shouldCreate(handle, cfResponse))
</del><ins>+    ASSERT_ARG(handle, handle);
+    if (handle-&gt;firstRequest().requester() != ResourceRequest::Requester::Main || ![QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)CFURLResponseGetMIMEType(cfResponse)])
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    NSURLResponse *response = [NSURLResponse _responseWithCFURLResponse:cfResponse];
</del><ins>+    NSURLResponse *nsResponse = [NSURLResponse _responseWithCFURLResponse:cfResponse];
</ins><span class="cx">     WebQuickLookHandleAsDelegate *delegate = [[[WebQuickLookHandleAsDelegate alloc] initWithConnectionDelegate:connectionDelegate] autorelease];
</span><del>-    return create(handle, nil, response, delegate);
</del><ins>+    std::unique_ptr&lt;QuickLookHandle&gt; quickLookHandle(new QuickLookHandle([handle-&gt;firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, nsResponse, delegate));
+    handle-&gt;client()-&gt;didCreateQuickLookHandle(*quickLookHandle);
+    return quickLookHandle;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CFURLResponseRef QuickLookHandle::cfResponse()
</span><span class="lines">@@ -482,17 +427,17 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::createIfNecessary(ResourceLoader&amp; loader, NSURLResponse *response)
</del><ins>+bool QuickLookHandle::shouldCreateForMIMEType(const String&amp; mimeType)
</ins><span class="cx"> {
</span><del>-    bool isMainResourceLoad = loader.documentLoader()-&gt;mainResourceLoader() == &amp;loader;
-    if (!isMainResourceLoad)
-        return nullptr;
</del><ins>+    return [QLPreviewGetSupportedMIMETypesSet() containsObject:mimeType];
+}
</ins><span class="cx"> 
</span><del>-    if (!shouldCreateForResponse(response._CFURLResponse))
-        return nullptr;
</del><ins>+std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceLoader&amp; loader, const ResourceResponse&amp; response)
+{
+    ASSERT(shouldCreateForMIMEType(response.mimeType()));
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;WebResourceLoaderQuickLookDelegate&gt; delegate = adoptNS([[WebResourceLoaderQuickLookDelegate alloc] initWithResourceLoader:&amp;loader]);
</span><del>-    std::unique_ptr&lt;QuickLookHandle&gt; quickLookHandle(new QuickLookHandle([loader.originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, response, delegate.get()));
</del><ins>+    std::unique_ptr&lt;QuickLookHandle&gt; quickLookHandle(new QuickLookHandle([loader.originalRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], nil, response.nsURLResponse(), delegate.get()));
</ins><span class="cx">     [delegate setQuickLookHandle:quickLookHandle.get()];
</span><span class="cx">     loader.didCreateQuickLookHandle(*quickLookHandle);
</span><span class="cx">     return quickLookHandle;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosWebCoreURLResponseIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/WebCoreURLResponseIOS.mm (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/WebCoreURLResponseIOS.mm        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebCore/platform/network/ios/WebCoreURLResponseIOS.mm        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -28,7 +28,22 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;WebCoreURLResponseIOS.h&quot;
</span><ins>+#import &quot;UTIUtilities.h&quot;
+#import &quot;WebCoreSystemInterface.h&quot;
</ins><span class="cx"> 
</span><ins>+#import &quot;QuickLook.h&quot;
+#import &quot;QuickLookSoftLink.h&quot;
+#import &quot;SoftLinking.h&quot;
+#import &lt;MobileCoreServices/MobileCoreServices.h&gt;
+
+SOFT_LINK_FRAMEWORK(MobileCoreServices)
+
+SOFT_LINK(MobileCoreServices, UTTypeCreatePreferredIdentifierForTag, CFStringRef, (CFStringRef inTagClass, CFStringRef inTag, CFStringRef inConformingToUTI), (inTagClass, inTag, inConformingToUTI))
+
+SOFT_LINK_CONSTANT(MobileCoreServices, kUTTagClassFilenameExtension, CFStringRef)
+
+#define kUTTagClassFilenameExtension getkUTTagClassFilenameExtension()
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse)
</span><span class="lines">@@ -38,6 +53,27 @@
</span><span class="cx">     if (!updatedMIMEType)
</span><span class="cx">         updatedMIMEType = defaultMIMEType().createCFString();
</span><span class="cx"> 
</span><ins>+#if USE(QUICK_LOOK)
+    // We must ensure that the MIME type is correct, so that QuickLook's web plugin is called when needed.
+    // We filter the basic MIME types so that we don't do unnecessary work in standard browsing situations.
+    if (shouldUseQuickLookForMIMEType((NSString *)updatedMIMEType.get())) {
+        RetainPtr&lt;CFStringRef&gt; suggestedFilename = adoptCF(CFURLResponseCopySuggestedFilename(cfResponse));
+        RetainPtr&lt;CFStringRef&gt; quickLookMIMEType = adoptCF((CFStringRef)QLTypeCopyBestMimeTypeForFileNameAndMimeType((NSString *)suggestedFilename.get(), (NSString *)mimeType.get()));
+        if (!quickLookMIMEType) {
+            auto url = CFURLResponseGetURL(cfResponse);
+            if ([(NSURL *)url isFileURL]) {
+                RetainPtr&lt;CFStringRef&gt; extension = adoptCF(CFURLCopyPathExtension(url));
+                if (extension) {
+                    RetainPtr&lt;CFStringRef&gt; uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extension.get(), nullptr));
+                    quickLookMIMEType = mimeTypeFromUTITree(uti.get());
+                }
+            }
+        }
+
+        if (quickLookMIMEType)
+            updatedMIMEType = quickLookMIMEType;
+    }
+#endif // USE(QUICK_LOOK)
</ins><span class="cx">     if (!mimeType || CFStringCompare(mimeType.get(), updatedMIMEType.get(), kCFCompareCaseInsensitive) != kCFCompareEqualTo)
</span><span class="cx">         CFURLResponseSetMIMEType(cfResponse, updatedMIMEType.get());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkmacWebCoreResourceHandleAsDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsDelegate.mm        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -162,10 +162,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(QUICK_LOOK)
</span><del>-    if (auto quickLookHandle = QuickLookHandle::createIfNecessary(*m_handle, connection, r, self)) {
-        r = quickLookHandle-&gt;nsResponse();
-        m_handle-&gt;setQuickLookHandle(WTFMove(quickLookHandle));
-    }
</del><ins>+    m_handle-&gt;setQuickLookHandle(QuickLookHandle::create(m_handle, connection, r, self));
+    if (m_handle-&gt;quickLookHandle())
+        r = m_handle-&gt;quickLookHandle()-&gt;nsResponse();
</ins><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx">     ResourceResponse resourceResponse(r);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-04-18  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Unreviewed, rolling out r199644.
+
+        Seems to have caused a 1-2% regression on warm PLT
+
+        Reverted changeset:
+
+        &quot;[WK2][iOS] Do not dlopen() QuickLook in the NetworkProcess&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=156639
+        http://trac.webkit.org/changeset/199644
+
</ins><span class="cx"> 2016-04-18  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Pending API Request URL is wrong after reloading
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (199668 => 199669)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp        2016-04-18 15:33:30 UTC (rev 199668)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp        2016-04-18 15:36:34 UTC (rev 199669)
</span><span class="lines">@@ -114,12 +114,12 @@
</span><span class="cx">     // Refrain from calling didReceiveResponse if QuickLook will convert this response, since the MIME type of the
</span><span class="cx">     // converted resource isn't yet known. WebResourceLoaderQuickLookDelegate will later call didReceiveResponse upon
</span><span class="cx">     // receiving the converted data.
</span><del>-    if (auto quickLookHandle = QuickLookHandle::createIfNecessary(*m_coreLoader, response.nsURLResponse())) {
-        m_coreLoader-&gt;documentLoader()-&gt;setQuickLookHandle(WTFMove(quickLookHandle));
</del><ins>+    bool isMainLoad = m_coreLoader-&gt;documentLoader()-&gt;mainResourceLoader() == m_coreLoader;
+    if (isMainLoad &amp;&amp; QuickLookHandle::shouldCreateForMIMEType(response.mimeType())) {
+        m_coreLoader-&gt;documentLoader()-&gt;setQuickLookHandle(QuickLookHandle::create(*m_coreLoader, response));
</ins><span class="cx">         shoudCallCoreLoaderDidReceiveResponse = false;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-
</del><span class="cx">     if (shoudCallCoreLoaderDidReceiveResponse)
</span><span class="cx">         m_coreLoader-&gt;didReceiveResponse(response);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>