<http://webkit.org/b/53192> Add experimental support for HTTP pipelining in CFNetwork
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 04:57:01 +0000 (04:57 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 04:57:01 +0000 (04:57 +0000)
<rdar://problem/8821760>

Reviewed by Antti Koivisto.

Source/WebCore:

This adds support for HTTP pipelining in CFNetwork, but does not
enable it.  To enable it post-SnowLeopard, use this command:

    defaults write BUNDLE.ID WebKitEnableHTTPPipelining -bool YES

Once enabled, it is possible to force the same load priority
(high) to be sent to CFNetwork to allow WebCore to handle the
scheduling:

    defaults write BUNDLE.ID WebKitForceHTTPPipeliningPriorityHigh -bool YES

* WebCore.exp.in: Export _wkGetHTTPPipeliningPriority and
_wkSetHTTPPipeliningPriority.

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight):
Copy the priority to preflightRequest.

* loader/ResourceLoadScheduler.cpp:
(WebCore::ResourceLoadScheduler::scheduleLoad): Refactored code
at the end of the method to use an early return.

* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::load): Set the priority on the
ResourceRequest object based on the priority of the
CachedResourceRequest before calling
ResourceLoadScheduler::scheduleSubresourceLoad().

* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::startLoading): Create a ResourceRequest
object and set its priority to ResourceLoadPriorityLow before
passing it to ResourceLoadScheduler::scheduleSubresourceLoad().

* platform/mac/WebCoreSystemInterface.h:
(wkGetHTTPPipeliningPriority): Added.
(wkSetHTTPPipeliningPriority): Added.
* platform/mac/WebCoreSystemInterface.mm:
(wkGetHTTPPipeliningPriority): Added.
(wkSetHTTPPipeliningPriority): Added.

* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::adopt): Set m_priority when
adopting a CrossThreadResourceRequestData.
(WebCore::ResourceRequestBase::copyData): Set m_priority when
creating a CrossThreadResourceRequestData.
(WebCore::ResourceRequestBase::priority): Added.
(WebCore::ResourceRequestBase::setPriority): Added.
(WebCore::equalIgnoringHeaderFields): Priorities must match when
comparing two ResourceRequest objects.

* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::ResourceRequestBase): Set default
priority of new objects to ResourceLoadPriorityLow.
(WebCore::ResourceRequestBase::priority): Added declaration.
(WebCore::ResourceRequestBase::setPriority): Added declaration.
(WebCore::isHTTPPipeliningEnabled): Added.
(WebCore::shouldUseHTTPPipeliningPriority): Added.

* platform/network/cf/ResourceRequestCFNet.cpp: Updated so that
Mac OS X and Windows share code.
(WebCore::initializeMaximumHTTPConnectionCountPerHost): Always
set the HTTP connection count per host, but return an
'unlimited' value when using HTTP pipelining.  This method used
to be defined in ResourceRequestMac.mm for Mac OS X.
(WebCore::readBooleanPreference): Added.  Helper method for
reading boolean user defaults.
(WebCore::isHTTPPipeliningEnabled): Returns value of user
default key WebKitEnableHTTPPipelining, or false if not set.
(WebCore::shouldUseHTTPPipeliningPriority): Returns value of
user default key WebKitForceHTTPPipeliningPriorityHigh, or false
if not set.
* platform/network/cf/ResourceRequestCFNet.h: Updated so that
Mac OS X and Windows share code.  Fixed indentation.
(WebCore::mapHTTPPipeliningPriorityToResourceLoadPriority): Added.
(WebCore::mapResourceLoadPriorityToHTTPPipeliningPriority): Added.

* platform/network/mac/ResourceRequestMac.mm:
(WebCore::ResourceRequest::doUpdatePlatformRequest): Update
HTTP pipelining priority on NSMutableFURLRequest object.
(WebCore::ResourceRequest::doUpdateResourceRequest): Update
m_priority from the NSURLRequest object.
(WebCore::initializeMaximumHTTPConnectionCountPerHost): Removed.
Code is now shared with Windows in ResourceRequestCFNet.cpp.

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Added initialization for
GetHTTPPipeliningPriority and SetHTTPPipeliningPriority.

Source/WebKit2:

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Added initialization for
GetHTTPPipeliningPriority and SetHTTPPipeliningPriority.

WebKitLibraries:

* WebKitSystemInterface.h:
    New methods added for HTTP pipelining support.
(WKGetHTTPPipeliningPriority): Added.
(WKSetHTTPPipeliningPriority): Added.
    Unrelated methods added after updating the header.
(WKMakeScrollbarPainter): Added.
(WKScrollbarPainterPaint): Added.
* libWebKitSystemInterfaceLeopard.a: Updated.
* libWebKitSystemInterfaceSnowLeopard.a: Updated.

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

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/ResourceLoadScheduler.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/icon/IconLoader.cpp
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebCore/platform/network/cf/ResourceRequestCFNet.h
Source/WebCore/platform/network/mac/ResourceRequestMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a

index 94b2d34..3af0be6 100644 (file)
@@ -1,3 +1,94 @@
+2011-01-26  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/53192> Add experimental support for HTTP pipelining in CFNetwork
+        <rdar://problem/8821760>
+
+        Reviewed by Antti Koivisto.
+
+        This adds support for HTTP pipelining in CFNetwork, but does not
+        enable it.  To enable it post-SnowLeopard, use this command:
+
+            defaults write BUNDLE.ID WebKitEnableHTTPPipelining -bool YES
+
+        Once enabled, it is possible to force the same load priority
+        (high) to be sent to CFNetwork to allow WebCore to handle the
+        scheduling:
+
+            defaults write BUNDLE.ID WebKitForceHTTPPipeliningPriorityHigh -bool YES
+
+        * WebCore.exp.in: Export _wkGetHTTPPipeliningPriority and
+        _wkSetHTTPPipeliningPriority.
+
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight):
+        Copy the priority to preflightRequest.
+
+        * loader/ResourceLoadScheduler.cpp:
+        (WebCore::ResourceLoadScheduler::scheduleLoad): Refactored code
+        at the end of the method to use an early return.
+
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::load): Set the priority on the
+        ResourceRequest object based on the priority of the
+        CachedResourceRequest before calling
+        ResourceLoadScheduler::scheduleSubresourceLoad().
+
+        * loader/icon/IconLoader.cpp:
+        (WebCore::IconLoader::startLoading): Create a ResourceRequest
+        object and set its priority to ResourceLoadPriorityLow before
+        passing it to ResourceLoadScheduler::scheduleSubresourceLoad().
+
+        * platform/mac/WebCoreSystemInterface.h:
+        (wkGetHTTPPipeliningPriority): Added.
+        (wkSetHTTPPipeliningPriority): Added.
+        * platform/mac/WebCoreSystemInterface.mm:
+        (wkGetHTTPPipeliningPriority): Added.
+        (wkSetHTTPPipeliningPriority): Added.
+
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::adopt): Set m_priority when
+        adopting a CrossThreadResourceRequestData.
+        (WebCore::ResourceRequestBase::copyData): Set m_priority when
+        creating a CrossThreadResourceRequestData.
+        (WebCore::ResourceRequestBase::priority): Added.
+        (WebCore::ResourceRequestBase::setPriority): Added.
+        (WebCore::equalIgnoringHeaderFields): Priorities must match when
+        comparing two ResourceRequest objects.
+
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::ResourceRequestBase): Set default
+        priority of new objects to ResourceLoadPriorityLow.
+        (WebCore::ResourceRequestBase::priority): Added declaration.
+        (WebCore::ResourceRequestBase::setPriority): Added declaration.
+        (WebCore::isHTTPPipeliningEnabled): Added.
+        (WebCore::shouldUseHTTPPipeliningPriority): Added.
+
+        * platform/network/cf/ResourceRequestCFNet.cpp: Updated so that
+        Mac OS X and Windows share code.
+        (WebCore::initializeMaximumHTTPConnectionCountPerHost): Always
+        set the HTTP connection count per host, but return an
+        'unlimited' value when using HTTP pipelining.  This method used
+        to be defined in ResourceRequestMac.mm for Mac OS X.
+        (WebCore::readBooleanPreference): Added.  Helper method for
+        reading boolean user defaults.
+        (WebCore::isHTTPPipeliningEnabled): Returns value of user
+        default key WebKitEnableHTTPPipelining, or false if not set.
+        (WebCore::shouldUseHTTPPipeliningPriority): Returns value of
+        user default key WebKitForceHTTPPipeliningPriorityHigh, or false
+        if not set.
+        * platform/network/cf/ResourceRequestCFNet.h: Updated so that
+        Mac OS X and Windows share code.  Fixed indentation.
+        (WebCore::mapHTTPPipeliningPriorityToResourceLoadPriority): Added.
+        (WebCore::mapResourceLoadPriorityToHTTPPipeliningPriority): Added.
+
+        * platform/network/mac/ResourceRequestMac.mm:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest): Update
+        HTTP pipelining priority on NSMutableFURLRequest object.
+        (WebCore::ResourceRequest::doUpdateResourceRequest): Update
+        m_priority from the NSURLRequest object.
+        (WebCore::initializeMaximumHTTPConnectionCountPerHost): Removed.
+        Code is now shared with Windows in ResourceRequestCFNet.cpp.
+
 2011-01-26  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin Adler.
index a4a2628..a4bdaa8 100644 (file)
@@ -1248,6 +1248,7 @@ _wkGetFontInLanguageForCharacter
 _wkGetFontInLanguageForRange
 _wkGetGlyphTransformedAdvances
 _wkGetGlyphsForCharacters
+_wkGetHTTPPipeliningPriority
 _wkGetHyphenationLocationBeforeIndex
 _wkGetMIMETypeForExtension
 _wkGetNSURLResponseCalculatedExpiration
@@ -1278,6 +1279,7 @@ _wkSetCONNECTProxyAuthorizationForStream
 _wkSetCONNECTProxyForStream
 _wkSetCookieStoragePrivateBrowsingEnabled
 _wkSetDragImage
+_wkSetHTTPPipeliningPriority
 _wkSetNSURLConnectionDefersCallbacks
 _wkSetNSURLRequestShouldContentSniff
 _wkSetPatternBaseCTM
index dee5001..d0f7f48 100644 (file)
@@ -144,6 +144,8 @@ void DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight(const R
         preflightRequest.setHTTPHeaderField("Access-Control-Request-Headers", String::adopt(headerBuffer));
     }
 
+    preflightRequest.setPriority(request.priority());
+
     loadRequest(preflightRequest, DoSecurityCheck);
 }
 
index 8cf2c18..dbb6914 100644 (file)
@@ -90,7 +90,7 @@ PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Fra
         scheduleLoad(loader.get(), priority);
     return loader;
 }
-    
+
 PassRefPtr<NetscapePlugInStreamLoader> ResourceLoadScheduler::schedulePluginStreamLoad(Frame* frame, NetscapePlugInStreamLoaderClient* client, const ResourceRequest& request)
 {
     PassRefPtr<NetscapePlugInStreamLoader> loader = NetscapePlugInStreamLoader::create(frame, client, request);
@@ -120,11 +120,12 @@ void ResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, Resourc
     if (priority > ResourceLoadPriorityLow || !resourceLoader->url().protocolInHTTPFamily() || (priority == ResourceLoadPriorityLow && !hadRequests)) {
         // Try to request important resources immediately.
         servePendingRequests(host, priority);
-    } else {
-        // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones.
-        InspectorInstrumentation::didScheduleResourceRequest(resourceLoader->frameLoader() ? resourceLoader->frameLoader()->frame()->document() : 0, resourceLoader->url());
-        scheduleServePendingRequests();
+        return;
     }
+
+    // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones.
+    InspectorInstrumentation::didScheduleResourceRequest(resourceLoader->frameLoader() ? resourceLoader->frameLoader()->frame()->document() : 0, resourceLoader->url());
+    scheduleServePendingRequests();
 }
 
 void ResourceLoadScheduler::remove(ResourceLoader* resourceLoader)
index d5e1adf..1d2f706 100644 (file)
@@ -113,6 +113,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
 #endif
 
     ResourceLoadPriority priority = resource->loadPriority();
+    resourceRequest.setPriority(priority);
 
     RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(),
         request.get(), resourceRequest, priority, securityCheck, sendResourceLoadCallbacks);
index 24562d0..bb738e8 100644 (file)
@@ -69,7 +69,10 @@ void IconLoader::startLoading()
     // SubresourceLoader::create returns.
     m_loadIsInProgress = true;
 
-    RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_frame, this, m_frame->loader()->iconURL());
+    ResourceRequest resourceRequest(m_frame->loader()->iconURL());
+    resourceRequest.setPriority(ResourceLoadPriorityLow);
+
+    RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_frame, this, resourceRequest);
     if (!loader)
         LOG_ERROR("Failed to start load for icon at url %s", m_frame->loader()->iconURL().string().ascii().data());
 
index 4e5f9ce..fdd38dc 100644 (file)
@@ -147,6 +147,8 @@ extern void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream);
 extern void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error);
 extern void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream);
 extern unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
+extern int (*wkGetHTTPPipeliningPriority)(NSURLRequest *);
+extern void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority);
 extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL);
index 08a5023..e281767 100644 (file)
@@ -89,6 +89,8 @@ void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
 void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
 id (*wkCreateNSURLConnectionDelegateProxy)(void);
 unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
+int (*wkGetHTTPPipeliningPriority)(NSURLRequest *);
+void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority);
 void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
 CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL);
index ae8316a..ba58461 100644 (file)
@@ -45,6 +45,7 @@ PassOwnPtr<ResourceRequest> ResourceRequestBase::adopt(PassOwnPtr<CrossThreadRes
     request->setTimeoutInterval(data->m_timeoutInterval);
     request->setFirstPartyForCookies(data->m_firstPartyForCookies);
     request->setHTTPMethod(data->m_httpMethod);
+    request->setPriority(data->m_priority);
     request->setTargetType(data->m_targetType);
 
     request->updateResourceRequest();
@@ -78,6 +79,7 @@ PassOwnPtr<CrossThreadResourceRequestData> ResourceRequestBase::copyData() const
     data->m_firstPartyForCookies = firstPartyForCookies().copy();
     data->m_httpMethod = httpMethod().crossThreadString();
     data->m_httpHeaders = httpHeaderFields().copyData();
+    data->m_priority = priority();
     data->m_targetType = m_targetType;
 
     data->m_responseContentDispositionEncodingFallbackArray.reserveInitialCapacity(m_responseContentDispositionEncodingFallbackArray.size());
@@ -314,6 +316,23 @@ void ResourceRequestBase::setAllowCookies(bool allowCookies)
         m_platformRequestUpdated = false;
 }
 
+ResourceLoadPriority ResourceRequestBase::priority() const
+{
+    updateResourceRequest();
+
+    return m_priority;
+}
+
+void ResourceRequestBase::setPriority(ResourceLoadPriority priority)
+{
+    updateResourceRequest();
+
+    m_priority = priority;
+
+    if (url().protocolInHTTPFamily())
+        m_platformRequestUpdated = false;
+}
+
 void ResourceRequestBase::addHTTPHeaderField(const AtomicString& name, const String& value) 
 {
     updateResourceRequest();
@@ -352,6 +371,9 @@ bool equalIgnoringHeaderFields(const ResourceRequestBase& a, const ResourceReque
     if (a.allowCookies() != b.allowCookies())
         return false;
     
+    if (a.priority() != b.priority())
+        return false;
+
     FormData* formDataA = a.httpBody();
     FormData* formDataB = b.httpBody();
     
index dce33db..9cc9148 100644 (file)
@@ -29,8 +29,9 @@
 #define ResourceRequestBase_h
 
 #include "FormData.h"
-#include "KURL.h"
 #include "HTTPHeaderMap.h"
+#include "KURL.h"
+#include "ResourceLoadPriority.h"
 
 #include <wtf/OwnPtr.h>
 
@@ -128,6 +129,9 @@ namespace WebCore {
         bool allowCookies() const;
         void setAllowCookies(bool allowCookies);
 
+        ResourceLoadPriority priority() const;
+        void setPriority(ResourceLoadPriority);
+
         bool isConditional() const;
 
         // Whether the associated ResourceHandleClient needs to be notified of
@@ -157,6 +161,7 @@ namespace WebCore {
             , m_reportUploadProgress(false)
             , m_reportLoadTiming(false)
             , m_reportRawHeaders(false)
+            , m_priority(ResourceLoadPriorityLow)
             , m_targetType(TargetIsSubresource)
         {
         }
@@ -172,6 +177,7 @@ namespace WebCore {
             , m_reportUploadProgress(false)
             , m_reportLoadTiming(false)
             , m_reportRawHeaders(false)
+            , m_priority(ResourceLoadPriorityLow)
             , m_targetType(TargetIsSubresource)
         {
         }
@@ -197,6 +203,7 @@ namespace WebCore {
         bool m_reportUploadProgress;
         bool m_reportLoadTiming;
         bool m_reportRawHeaders;
+        ResourceLoadPriority m_priority;
         TargetType m_targetType;
 
     private:
@@ -223,11 +230,20 @@ namespace WebCore {
         Vector<String> m_responseContentDispositionEncodingFallbackArray;
         RefPtr<FormData> m_httpBody;
         bool m_allowCookies;
+        ResourceLoadPriority m_priority;
         ResourceRequestBase::TargetType m_targetType;
     };
     
     unsigned initializeMaximumHTTPConnectionCountPerHost();
 
+#if PLATFORM(CF)
+    bool isHTTPPipeliningEnabled();
+    bool shouldForceHTTPPipeliningPriorityHigh();
+#else
+    inline bool isHTTPPipeliningEnabled() { return false; }
+    inline bool shouldForceHTTPPipeliningPriorityHigh() { return false; }
+#endif
+
 } // namespace WebCore
 
 #endif // ResourceRequestBase_h
index 410a649..7a1dfd5 100644 (file)
 #include "config.h"
 #include "ResourceRequestCFNet.h"
 
-#if USE(CFNETWORK)
-
-#include "FormDataStreamCFNet.h"
 #include "ResourceRequest.h"
 
+#if PLATFORM(MAC)
+#include "WebCoreSystemInterface.h"
+#endif
+
+#if USE(CFNETWORK)
+#include "FormDataStreamCFNet.h"
 #include <CFNetwork/CFURLRequestPriv.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
 
 namespace WebCore {
 
+#if USE(CFNETWORK)
+
 typedef void (*CFURLRequestSetContentDispositionEncodingFallbackArrayFunction)(CFMutableURLRequestRef, CFArrayRef);
 typedef CFArrayRef (*CFURLRequestCopyContentDispositionEncodingFallbackArrayFunction)(CFURLRequestRef);
 
@@ -189,12 +195,43 @@ void ResourceRequest::doUpdateResourceRequest()
     m_httpBody = httpBodyFromRequest(m_cfRequest.get());
 }
 
+#endif // USE(CFNETWORK)
+
 unsigned initializeMaximumHTTPConnectionCountPerHost()
 {
     static const unsigned preferredConnectionCount = 6;
-    return wkInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount);
+    static const unsigned unlimitedConnectionCount = 10000;
+
+    // Always set the connection count per host, even when pipelining.
+    unsigned maximumHTTPConnectionCountPerHost = wkInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount);
+
+#if PLATFORM(MAC)
+    if (isHTTPPipeliningEnabled()) {
+        // When pipelining do not rate-limit requests sent from WebCore since CFNetwork handles that.
+        return unlimitedConnectionCount;
+    }
+#endif
+
+    return maximumHTTPConnectionCountPerHost;
 }
 
-} // namespace WebCore
+static inline bool readBooleanPreference(CFStringRef key)
+{
+    Boolean keyExistsAndHasValidFormat;
+    Boolean result = CFPreferencesGetAppBooleanValue(key, kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat);
+    return keyExistsAndHasValidFormat ? result : false;
+}
 
-#endif // USE(CFNETWORK)
+bool isHTTPPipeliningEnabled()
+{
+    static bool isEnabled = readBooleanPreference(CFSTR("WebKitEnableHTTPPipelining"));
+    return isEnabled;
+}
+
+bool shouldForceHTTPPipeliningPriorityHigh()
+{
+    static bool shouldForcePriorityHigh = readBooleanPreference(CFSTR("WebKitForceHTTPPipeliningPriorityHigh"));
+    return shouldForcePriorityHigh;
+}
+
+} // namespace WebCore
index 39587a4..09f4cea 100644 (file)
 #ifndef ResourceRequestCFNet_h
 #define ResourceRequestCFNet_h
 
-#if USE(CFNETWORK)
+#include "ResourceLoadPriority.h"
 
+#if USE(CFNETWORK)
 typedef const struct _CFURLRequest* CFURLRequestRef;
+#endif
 
 namespace WebCore {
 
-    class ResourceRequest;
+class ResourceRequest;
+
+#if USE(CFNETWORK)
+void getResourceRequest(ResourceRequest&, CFURLRequestRef);
+CFURLRequestRef cfURLRequest(const ResourceRequest&);
+#endif
+
+inline ResourceLoadPriority mapHTTPPipeliningPriorityToResourceLoadPriority(int priority)
+{
+    switch (priority) {
+    case 0:
+        return ResourceLoadPriorityLow;
+    case 1:
+        return ResourceLoadPriorityMedium;
+    case 2:
+        return ResourceLoadPriorityHigh;
+    default:
+        ASSERT_NOT_REACHED();
+        return ResourceLoadPriorityLowest;
+    }
+}
+
+inline int mapResourceLoadPriorityToHTTPPipeliningPriority(ResourceLoadPriority priority)
+{
+    switch (priority) {
+    case ResourceLoadPriorityVeryLow:
+    case ResourceLoadPriorityLow:
+        return 0;
+    case ResourceLoadPriorityMedium:
+        return 1;
+    case ResourceLoadPriorityHigh:
+        return 2;
+    case ResourceLoadPriorityUnresolved:
+        ASSERT_NOT_REACHED();
+        return 0;
+    }
 
-    void getResourceRequest(ResourceRequest&, CFURLRequestRef);
-    CFURLRequestRef cfURLRequest(const ResourceRequest&);
+    ASSERT_NOT_REACHED();
+    return 0;
 }
 
-#endif // USE(CFNETWORK)
+} // namespace WebCore
 
 #endif // ResourceRequestCFNet_h
index f0357e5..640d237 100644 (file)
@@ -31,6 +31,8 @@
 #import "WebCoreSystemInterface.h"
 
 #import "FormDataStreamMac.h"
+#import "ResourceRequestCFNet.h"
+#import "WebCoreSystemInterface.h"
 
 #import <Foundation/Foundation.h>
 
@@ -65,7 +67,12 @@ void ResourceRequest::doUpdateResourceRequest()
     if (NSString* method = [m_nsRequest.get() HTTPMethod])
         m_httpMethod = method;
     m_allowCookies = [m_nsRequest.get() HTTPShouldHandleCookies];
-    
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    if (isHTTPPipeliningEnabled() && !shouldForceHTTPPipeliningPriorityHigh())
+        m_priority = mapHTTPPipeliningPriorityToResourceLoadPriority(wkGetHTTPPipeliningPriority(m_nsRequest.get()));
+#endif
+
     NSDictionary *headers = [m_nsRequest.get() allHTTPHeaderFields];
     NSEnumerator *e = [headers keyEnumerator];
     NSString *name;
@@ -111,6 +118,13 @@ void ResourceRequest::doUpdatePlatformRequest()
     wkSupportsMultipartXMixedReplace(nsRequest);
 #endif
 
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+    if (isHTTPPipeliningEnabled()) {
+        int priority = mapResourceLoadPriorityToHTTPPipeliningPriority(m_priority);
+        wkSetHTTPPipeliningPriority(nsRequest, shouldForceHTTPPipeliningPriorityHigh() ? 2 : priority);
+    }
+#endif
+
     [nsRequest setCachePolicy:(NSURLRequestCachePolicy)cachePolicy()];
     if (timeoutInterval() != unspecifiedTimeoutInterval)
         [nsRequest setTimeoutInterval:timeoutInterval()];
@@ -154,12 +168,6 @@ void ResourceRequest::applyWebArchiveHackForMail()
     // Hack because Mail checks for this property to detect data / archive loads
     [NSURLProtocol setProperty:@"" forKey:@"WebDataRequest" inRequest:(NSMutableURLRequest *)nsURLRequest()];
 }
-    
-unsigned initializeMaximumHTTPConnectionCountPerHost()
-{
-    static const unsigned preferredConnectionCount = 6;
-    return wkInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount);
-}
 
 } // namespace WebCore
 
index 2831e56..cabe536 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-26  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/53192> Add experimental support for HTTP pipelining in CFNetwork
+        <rdar://problem/8821760>
+
+        Reviewed by Antti Koivisto.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Added initialization for
+        GetHTTPPipeliningPriority and SetHTTPPipeliningPriority.
+
 2011-01-26  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin Adler.
index 483d6d6..e9bf1a9 100644 (file)
@@ -60,6 +60,7 @@ void InitWebCoreSystemInterface(void)
     INIT(GetFontInLanguageForCharacter);
     INIT(GetFontInLanguageForRange);
     INIT(GetGlyphTransformedAdvances);
+    INIT(GetHTTPPipeliningPriority);
     INIT(GetMIMETypeForExtension);
     INIT(GetNSURLResponseLastModifiedDate);
     INIT(GetPreferredExtensionForMIMEType);
@@ -75,6 +76,7 @@ void InitWebCoreSystemInterface(void)
     INIT(SetCONNECTProxyForStream);
     INIT(SetCookieStoragePrivateBrowsingEnabled);
     INIT(SetDragImage);
+    INIT(SetHTTPPipeliningPriority);
     INIT(SetNSURLConnectionDefersCallbacks);
     INIT(SetNSURLRequestShouldContentSniff);
     INIT(SetPatternBaseCTM);
index 5f61189..588476c 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-26  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/53192> Add experimental support for HTTP pipelining in CFNetwork
+        <rdar://problem/8821760>
+
+        Reviewed by Antti Koivisto.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface): Added initialization for
+        GetHTTPPipeliningPriority and SetHTTPPipeliningPriority.
+
 2011-01-26  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin Adler.
index 3d8bae7..22980ce 100644 (file)
@@ -55,6 +55,7 @@ void InitWebCoreSystemInterface(void)
         INIT(GetFontInLanguageForRange);
         INIT(GetGlyphTransformedAdvances);
         INIT(GetGlyphsForCharacters);
+        INIT(GetHTTPPipeliningPriority);
         INIT(GetMIMETypeForExtension);
         INIT(GetNSURLResponseLastModifiedDate);
         INIT(GetPreferredExtensionForMIMEType);
@@ -82,6 +83,7 @@ void InitWebCoreSystemInterface(void)
         INIT(SetCONNECTProxyForStream);
         INIT(SetCookieStoragePrivateBrowsingEnabled);
         INIT(SetDragImage);
+        INIT(SetHTTPPipeliningPriority);
         INIT(SetNSURLConnectionDefersCallbacks);
         INIT(SetNSURLRequestShouldContentSniff);
         INIT(SetPatternBaseCTM);
index 6c72be4..757f0bb 100644 (file)
@@ -1,3 +1,20 @@
+2011-01-26  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/53192> Add experimental support for HTTP pipelining in CFNetwork
+        <rdar://problem/8821760>
+
+        Reviewed by Antti Koivisto.
+
+        * WebKitSystemInterface.h:
+            New methods added for HTTP pipelining support.
+        (WKGetHTTPPipeliningPriority): Added.
+        (WKSetHTTPPipeliningPriority): Added.
+            Unrelated methods added after updating the header.
+        (WKMakeScrollbarPainter): Added.
+        (WKScrollbarPainterPaint): Added.
+        * libWebKitSystemInterfaceLeopard.a: Updated.
+        * libWebKitSystemInterfaceSnowLeopard.a: Updated.
+
 2011-01-24  Jer Noble  <jer.noble@apple.com>
 
         Reviewed by Eric Carlson.
index d232229..db39c91 100644 (file)
@@ -327,6 +327,8 @@ UInt8 WKGetNSEventKeyChar(NSEvent *);
 void WKSetCAAnimationValueFunction(CAPropertyAnimation*, NSString* function);
 
 unsigned WKInitializeMaximumHTTPConnectionCountPerHost(unsigned preferredConnectionCount);
+int WKGetHTTPPipeliningPriority(NSURLRequest *);
+void WKSetHTTPPipeliningPriority(NSMutableURLRequest *, int priority);
 
 void WKSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
 void WKSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
@@ -377,6 +379,10 @@ bool WKSandboxExtensionInvalidate(WKSandboxExtensionRef sandboxExtension);
 const char* WKSandboxExtensionGetSerializedFormat(WKSandboxExtensionRef sandboxExtension, size_t* length);
 WKSandboxExtensionRef WKSandboxExtensionCreateFromSerializedFormat(const char* serializationFormat, size_t length);
 
+typedef struct __WKScrollbarPainter *WKScrollbarPainterRef;
+WKScrollbarPainterRef WKMakeScrollbarPainter(int controlSize, bool isHorizontal);
+void WKScrollbarPainterPaint(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
+
 #endif
 
 #ifdef __cplusplus
index dd0d652..74837e3 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index d2e5a5f..0fb7206 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ