[BlackBerry] Update NetworkJob to accept batched headers
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 17:43:56 +0000 (17:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 17:43:56 +0000 (17:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81273

Batch up the headers into a vector before they come into
webkit to increase performance, and simplify the API.

Patch by Tay Grigg <tgrigg@rim.com> on 2012-03-16
Reviewed by George Staikos.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::notifyHeadersReceived):
* platform/network/blackberry/NetworkJob.h:
(NetworkJob):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/blackberry/NetworkJob.cpp
Source/WebCore/platform/network/blackberry/NetworkJob.h

index 3d27f88c59056be1a23d534e1e73d84d280c9ab5..e56d98e3ffce0f90d75ed7c8211a5f4b6e2ee638 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-16  Tay Grigg  <tgrigg@rim.com>
+
+        [BlackBerry] Update NetworkJob to accept batched headers
+        https://bugs.webkit.org/show_bug.cgi?id=81273
+
+        Batch up the headers into a vector before they come into
+        webkit to increase performance, and simplify the API.
+
+        Reviewed by George Staikos.
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::notifyHeadersReceived):
+        * platform/network/blackberry/NetworkJob.h:
+        (NetworkJob):
+
 2012-03-16  Dana Jansens  <danakj@chromium.org>
 
         [chromium] Add overdraw metrics for texture uploads
index 912b7e99695f612b0ba3452616fbb11e4d2f8b9b..60cc86c3f209e57b5a25a26f8fbe93a70c25c2d8 100644 (file)
@@ -248,29 +248,32 @@ void NetworkJob::notifyWMLOverride()
         handleNotifyWMLOverride();
 }
 
-void NetworkJob::notifyHeaderReceived(const char* key, const char* value)
+void NetworkJob::notifyHeadersReceived(BlackBerry::Platform::NetworkRequest::HeaderList& headers)
 {
-    if (shouldDeferLoading())
-        m_deferredData.deferHeaderReceived(key, value);
-    else {
-        String keyString(key);
-        String valueString;
-        if (equalIgnoringCase(keyString, "Location")) {
-            // Location, like all headers, is supposed to be Latin-1. But some sites (wikipedia) send it in UTF-8.
-            // All byte strings that are valid UTF-8 are also valid Latin-1 (although outside ASCII, the meaning will
-            // differ), but the reverse isn't true. So try UTF-8 first and fall back to Latin-1 if it's invalid.
-            // (High Latin-1 should be url-encoded anyway.)
-            //
-            // FIXME: maybe we should do this with other headers?
-            // Skip it for now - we don't want to rewrite random bytes unless we're sure. (Definitely don't want to
-            // rewrite cookies, for instance.) Needs more investigation.
-            valueString = String::fromUTF8(value);
-            if (valueString.isNull())
-                valueString = value;
-        } else
-            valueString = value;
-
-        handleNotifyHeaderReceived(keyString, valueString);
+    BlackBerry::Platform::NetworkRequest::HeaderList::const_iterator endIt = headers.end();
+    for (BlackBerry::Platform::NetworkRequest::HeaderList::const_iterator it = headers.begin(); it != endIt; ++it) {
+        if (shouldDeferLoading())
+            m_deferredData.deferHeaderReceived(it->first.c_str(), it->second.c_str());
+        else {
+            String keyString(it->first.c_str());
+            String valueString;
+            if (equalIgnoringCase(keyString, "Location")) {
+                // Location, like all headers, is supposed to be Latin-1. But some sites (wikipedia) send it in UTF-8.
+                // All byte strings that are valid UTF-8 are also valid Latin-1 (although outside ASCII, the meaning will
+                // differ), but the reverse isn't true. So try UTF-8 first and fall back to Latin-1 if it's invalid.
+                // (High Latin-1 should be url-encoded anyway.)
+                //
+                // FIXME: maybe we should do this with other headers?
+                // Skip it for now - we don't want to rewrite random bytes unless we're sure. (Definitely don't want to
+                // rewrite cookies, for instance.) Needs more investigation.
+                valueString = String::fromUTF8(it->second.c_str());
+                if (valueString.isNull())
+                    valueString = it->second.c_str();
+            } else
+                valueString = it->second.c_str();
+
+            handleNotifyHeaderReceived(keyString, valueString);
+        }
     }
 }
 
index a50059ab1c169bf537b20fd96b58175cb3cc415e..586b45f4bc3b2cd5106d4ebc789831eb0a3061ea 100644 (file)
@@ -69,7 +69,7 @@ public:
     void handleNotifyStatusReceived(int status, const String& message);
     virtual void notifyWMLOverride();
     void handleNotifyWMLOverride() { m_response.setIsWML(true); }
-    virtual void notifyHeaderReceived(const char* key, const char* value);
+    virtual void notifyHeadersReceived(BlackBerry::Platform::NetworkRequest::HeaderList& headers);
     virtual void notifyMultipartHeaderReceived(const char* key, const char* value);
     // Exists only to resolve ambiguity between char* and String parameters
     void notifyStringHeaderReceived(const String& key, const String& value);