Reviewed by David Kilzer.
authorpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2011 04:54:54 +0000 (04:54 +0000)
committerpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jul 2011 04:54:54 +0000 (04:54 +0000)
Add NSURLRequest wrapper in ResourceRequest when USE(CFNETWORK) is enabled
https://bugs.webkit.org/show_bug.cgi?id=63276

When USE(CFNETWORK) is enabled on Mac, keep an NSURLRequest object along with the
CFURLRequestRef so that WebKit can continue using the NSURLRequest.

No new tests because no change in functionality and option is not enabled on Mac.

* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::updateNSURLRequest):
(WebCore::ResourceRequest::ResourceRequest):
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::findCFURLRequestSetContentDispositionEncodingFallbackArrayFunction):
(WebCore::findCFURLRequestCopyContentDispositionEncodingFallbackArrayFunction):
(WebCore::ResourceRequest::doUpdatePlatformRequest):
(WebCore::ResourceRequest::applyWebArchiveHackForMail):
* platform/network/mac/ResourceRequestMac.mm:
(WebCore::ResourceRequest::nsURLRequest):
(WebCore::ResourceRequest::ResourceRequest):
(WebCore::ResourceRequest::updateNSURLRequest):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/ResourceRequest.h
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebCore/platform/network/mac/ResourceRequestMac.mm

index d85accb..b23e1fc 100644 (file)
@@ -1,3 +1,28 @@
+2011-06-23  Pratik Solanki  <psolanki@apple.com>
+
+        Reviewed by David Kilzer.
+
+        Add NSURLRequest wrapper in ResourceRequest when USE(CFNETWORK) is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=63276
+
+        When USE(CFNETWORK) is enabled on Mac, keep an NSURLRequest object along with the
+        CFURLRequestRef so that WebKit can continue using the NSURLRequest.
+
+        No new tests because no change in functionality and option is not enabled on Mac.
+
+        * platform/network/cf/ResourceRequest.h:
+        (WebCore::ResourceRequest::updateNSURLRequest):
+        (WebCore::ResourceRequest::ResourceRequest):
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::findCFURLRequestSetContentDispositionEncodingFallbackArrayFunction):
+        (WebCore::findCFURLRequestCopyContentDispositionEncodingFallbackArrayFunction):
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        (WebCore::ResourceRequest::applyWebArchiveHackForMail):
+        * platform/network/mac/ResourceRequestMac.mm:
+        (WebCore::ResourceRequest::nsURLRequest):
+        (WebCore::ResourceRequest::ResourceRequest):
+        (WebCore::ResourceRequest::updateNSURLRequest):
+
 2011-07-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         positionForPoint is broken when a block is positioned relatively inside the parent
index 830797a..47b155b 100644 (file)
 #include <wtf/RetainPtr.h>
 #if USE(CFNETWORK)
 typedef const struct _CFURLRequest* CFURLRequestRef;
-#else
+#endif
+
 #ifdef __OBJC__
 @class NSURLRequest;
 #else
 class NSURLRequest;
 #endif
-#endif
 
 #if USE(CFURLSTORAGESESSIONS) && (defined(BUILDING_ON_SNOW_LEOPARD) || defined(BUILDING_ON_LEOPARD))
 typedef struct __CFURLStorageSession* CFURLStorageSessionRef;
@@ -72,18 +72,32 @@ namespace WebCore {
         }
         
 #if USE(CFNETWORK)
+#if PLATFORM(MAC)
+        ResourceRequest(NSURLRequest *);
+        void updateNSURLRequest();
+#endif
+
         ResourceRequest(CFURLRequestRef cfRequest)
             : ResourceRequestBase()
-            , m_cfRequest(cfRequest) { }
+            , m_cfRequest(cfRequest)
+        {
+#if PLATFORM(MAC)
+            updateNSURLRequest();
+#endif
+        }
+
 
         CFURLRequestRef cfURLRequest() const;
 #else
-        ResourceRequest(NSURLRequestnsRequest)
+        ResourceRequest(NSURLRequest *nsRequest)
             : ResourceRequestBase()
             , m_nsRequest(nsRequest) { }
 
+#endif
+
+#if PLATFORM(MAC)
         void applyWebArchiveHackForMail();
-        NSURLRequestnsURLRequest() const;
+        NSURLRequest *nsURLRequest() const;
 #endif
 
 #if USE(CFURLSTORAGESESSIONS)
@@ -108,7 +122,8 @@ namespace WebCore {
 
 #if USE(CFNETWORK)
         RetainPtr<CFURLRequestRef> m_cfRequest;
-#else
+#endif
+#if PLATFORM(MAC)
         RetainPtr<NSURLRequest> m_nsRequest;
 #endif
 
index e930e8f..cf129b1 100644 (file)
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
 
+#if USE(CFNETWORK)
+#include "FormDataStreamCFNet.h"
+#include <CFNetwork/CFURLRequestPriv.h>
+#endif
+
 #if PLATFORM(MAC)
 #include "ResourceLoadPriority.h"
 #include "WebCoreSystemInterface.h"
+#include <dlfcn.h>
 #endif
 
-#if USE(CFNETWORK)
-#include "FormDataStreamCFNet.h"
-#include <CFNetwork/CFURLRequestPriv.h>
+#if PLATFORM(WIN)
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #endif
 
@@ -49,6 +53,7 @@ bool ResourceRequest::s_httpPipeliningEnabled = false;
 typedef void (*CFURLRequestSetContentDispositionEncodingFallbackArrayFunction)(CFMutableURLRequestRef, CFArrayRef);
 typedef CFArrayRef (*CFURLRequestCopyContentDispositionEncodingFallbackArrayFunction)(CFURLRequestRef);
 
+#if PLATFORM(WIN)
 static HMODULE findCFNetworkModule()
 {
 #ifndef DEBUG_ALL
@@ -67,6 +72,17 @@ static CFURLRequestCopyContentDispositionEncodingFallbackArrayFunction findCFURL
 {
     return reinterpret_cast<CFURLRequestCopyContentDispositionEncodingFallbackArrayFunction>(GetProcAddress(findCFNetworkModule(), "_CFURLRequestCopyContentDispositionEncodingFallbackArray"));
 }
+#elif PLATFORM(MAC)
+static CFURLRequestSetContentDispositionEncodingFallbackArrayFunction findCFURLRequestSetContentDispositionEncodingFallbackArrayFunction()
+{
+    return reinterpret_cast<CFURLRequestSetContentDispositionEncodingFallbackArrayFunction>(dlsym(RTLD_DEFAULT, "_CFURLRequestSetContentDispositionEncodingFallbackArray"));
+}
+
+static CFURLRequestCopyContentDispositionEncodingFallbackArrayFunction findCFURLRequestCopyContentDispositionEncodingFallbackArrayFunction()
+{
+    return reinterpret_cast<CFURLRequestCopyContentDispositionEncodingFallbackArrayFunction>(dlsym(RTLD_DEFAULT, "_CFURLRequestCopyContentDispositionEncodingFallbackArray"));
+}
+#endif
 
 static void setContentDispositionEncodingFallbackArray(CFMutableURLRequestRef request, CFArrayRef fallbackArray)
 {
@@ -159,6 +175,9 @@ void ResourceRequest::doUpdatePlatformRequest()
     }
 
     m_cfRequest.adoptCF(cfRequest);
+#if PLATFORM(MAC)
+    updateNSURLRequest();
+#endif
 }
 
 void ResourceRequest::doUpdateResourceRequest()
@@ -218,6 +237,14 @@ void ResourceRequest::setStorageSession(CFURLStorageSessionRef storageSession)
 
 #endif
 
+#if PLATFORM(MAC)
+void ResourceRequest::applyWebArchiveHackForMail()
+{
+    // Hack because Mail checks for this property to detect data / archive loads
+    _CFURLRequestSetProtocolProperty(cfURLRequest(), CFSTR("WebDataRequest"), CFSTR(""));
+}
+#endif
+
 #endif // USE(CFNETWORK)
 
 bool ResourceRequest::httpPipeliningEnabled()
index 85c7f7c..21899b0 100644 (file)
 #import "config.h"
 #import "ResourceRequest.h"
 
-#if !USE(CFNETWORK)
-
-#import "WebCoreSystemInterface.h"
-
 #import "FormDataStreamMac.h"
 #import "ResourceRequestCFNet.h"
 #import "RuntimeApplicationChecks.h"
@@ -42,6 +38,7 @@
 - (NSArray *)contentDispositionEncodingFallbackArray;
 + (void)setDefaultTimeoutInterval:(NSTimeInterval)seconds;
 - (CFURLRequestRef)_CFURLRequest;
+- (id)_initWithCFURLRequest:(CFURLRequestRef)request;
 @end
 
 @interface NSMutableURLRequest (WebMutableNSURLRequestDetails)
 
 namespace WebCore {
 
-NSURLRequestResourceRequest::nsURLRequest() const
+NSURLRequest *ResourceRequest::nsURLRequest() const
 { 
     updatePlatformRequest();
     
     return [[m_nsRequest.get() retain] autorelease]; 
 }
 
+#if USE(CFNETWORK)
+
+ResourceRequest::ResourceRequest(NSURLRequest *nsRequest)
+    : ResourceRequestBase()
+    , m_cfRequest([nsRequest _CFURLRequest])
+    , m_nsRequest(nsRequest)
+{
+}
+
+void ResourceRequest::updateNSURLRequest()
+{
+    if (m_cfRequest)
+        m_nsRequest.adoptNS([[NSURLRequest alloc] _initWithCFURLRequest:m_cfRequest.get()]);
+}
+
+#else
+
 void ResourceRequest::doUpdateResourceRequest()
 {
     m_url = [m_nsRequest.get() URL];
@@ -177,6 +191,8 @@ void ResourceRequest::setStorageSession(CFURLStorageSessionRef storageSession)
 
 #endif
     
+#endif // USE(CFNETWORK)
+
 static bool initQuickLookResourceCachingQuirks()
 {
     if (applicationIsSafari())
@@ -204,4 +220,3 @@ bool ResourceRequest::useQuickLookResourceCachingQuirks()
 
 } // namespace WebCore
 
-#endif // !USE(CFNETWORK)