Title: [167200] trunk/Source/WebCore
Revision
167200
Author
psola...@apple.com
Date
2014-04-13 12:20:11 -0700 (Sun, 13 Apr 2014)

Log Message

Move early return out of dispatch_async() block so we can return from willSendRequest quickly
https://bugs.webkit.org/show_bug.cgi?id=131478
<rdar://problem/16575535>

Reviewed by Alexey Proskuryakov.

Do a quick check to see if we need to synthesize the redirect response on the dispatch queue
and return from willSendRequest callback quickly instead of always doing an effectively synchronous
call to the main thread. We can't call synthesizeRedirectResponseIfNecessary on the dispatch
queue since that accesses the ResourceRequest.

No new tests because no change in functionality.

* platform/network/cf/ResourceHandleCFURLConnectionDelegate.h:
* platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::setupRequest): Save the
request scheme to use later for early return from willSendRequest.
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (167199 => 167200)


--- trunk/Source/WebCore/ChangeLog	2014-04-13 18:01:54 UTC (rev 167199)
+++ trunk/Source/WebCore/ChangeLog	2014-04-13 19:20:11 UTC (rev 167200)
@@ -1,3 +1,24 @@
+2014-04-10  Pratik Solanki  <psola...@apple.com>
+
+        Move early return out of dispatch_async() block so we can return from willSendRequest quickly
+        https://bugs.webkit.org/show_bug.cgi?id=131478
+        <rdar://problem/16575535>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Do a quick check to see if we need to synthesize the redirect response on the dispatch queue
+        and return from willSendRequest callback quickly instead of always doing an effectively synchronous
+        call to the main thread. We can't call synthesizeRedirectResponseIfNecessary on the dispatch
+        queue since that accesses the ResourceRequest.
+
+        No new tests because no change in functionality.
+
+        * platform/network/cf/ResourceHandleCFURLConnectionDelegate.h:
+        * platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
+        (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::setupRequest): Save the
+        request scheme to use later for early return from willSendRequest.
+        (WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest):
+
 2014-04-08  Oliver Hunt  <oli...@apple.com>
 
         Rewrite Function.bind as a builtin

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.h (167199 => 167200)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.h	2014-04-13 18:01:54 UTC (rev 167199)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegate.h	2014-04-13 19:20:11 UTC (rev 167200)
@@ -94,6 +94,7 @@
 
 protected:
     ResourceHandle* m_handle;
+    RetainPtr<CFStringRef> m_originalScheme;
 };
 
 } // namespace WebCore.

Modified: trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp (167199 => 167200)


--- trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp	2014-04-13 18:01:54 UTC (rev 167199)
+++ trunk/Source/WebCore/platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp	2014-04-13 19:20:11 UTC (rev 167200)
@@ -62,8 +62,12 @@
     return !!m_handle;
 }
 
-void ResourceHandleCFURLConnectionDelegateWithOperationQueue::setupRequest(CFMutableURLRequestRef)
+void ResourceHandleCFURLConnectionDelegateWithOperationQueue::setupRequest(CFMutableURLRequestRef request)
 {
+    CFURLRef requestURL = CFURLRequestGetURL(request);
+    if (!requestURL)
+        return;
+    m_originalScheme = adoptCF(CFURLCopyScheme(requestURL));
 }
 
 void ResourceHandleCFURLConnectionDelegateWithOperationQueue::setupConnectionScheduling(CFURLConnectionRef connection)
@@ -73,6 +77,15 @@
 
 CFURLRequestRef ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest(CFURLRequestRef cfRequest, CFURLResponseRef originalRedirectResponse)
 {
+    // If the protocols of the new request and the current request match, this is not an HSTS redirect and we don't need to synthesize a redirect response.
+    if (!originalRedirectResponse) {
+        RetainPtr<CFStringRef> newScheme = adoptCF(CFURLCopyScheme(CFURLRequestGetURL(cfRequest)));
+        if (CFStringCompare(newScheme.get(), m_originalScheme.get(), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            CFRetain(cfRequest);
+            return cfRequest;
+        }
+    }
+
     RefPtr<ResourceHandleCFURLConnectionDelegateWithOperationQueue> protector(this);
 
     dispatch_async(dispatch_get_main_queue(), ^{
@@ -84,10 +97,7 @@
         LOG(Network, "CFNet - ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest(handle=%p) (%s)", m_handle, m_handle->firstRequest().url().string().utf8().data());
 
         RetainPtr<CFURLResponseRef> redirectResponse = synthesizeRedirectResponseIfNecessary(cfRequest, originalRedirectResponse);
-        if (!redirectResponse) {
-            m_handle->continueWillSendRequest(cfRequest);
-            return;
-        }
+        ASSERT(redirectResponse);
 
         ResourceRequest request = createResourceRequest(cfRequest, redirectResponse.get());
         m_handle->willSendRequest(request, redirectResponse.get());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to