[BlackBerry] Synchronize platform/network/blackberry
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 02:19:50 +0000 (02:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2012 02:19:50 +0000 (02:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81874

We changed a lot in these files locally. But the changes are not upstreamed.
It is not convenient to do the other upstreaming work based on these differences.
So upstream these changes.

Patch by Jason Liu <jason.liu@torchmobile.com.cn> on 2012-03-22
Reviewed by Rob Buis.

No new tests. Just synchronize codes.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::NetworkJob):
(WebCore::NetworkJob::initialize):
(WebCore::NetworkJob::handleNotifyHeaderReceived):
(WebCore::NetworkJob::handleNotifyDataReceived):
(WebCore::NetworkJob::sendResponseIfNeeded):
(WebCore::NetworkJob::sendRequestWithCredentials):
(WebCore::NetworkJob::handleAbout):
* platform/network/blackberry/NetworkJob.h:
(WebCore::NetworkJob::isError):
(NetworkJob):
* platform/network/blackberry/NetworkManager.cpp:
(WebCore::NetworkManager::startJob):
* platform/network/blackberry/ResourceRequest.h:
(WebCore::ResourceRequest::ResourceRequest):
* platform/network/blackberry/ResourceRequestBlackBerry.cpp:
(WebCore::platformTargetTypeForRequest):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/blackberry/NetworkJob.cpp
Source/WebCore/platform/network/blackberry/NetworkJob.h
Source/WebCore/platform/network/blackberry/NetworkManager.cpp
Source/WebCore/platform/network/blackberry/ResourceRequest.h
Source/WebCore/platform/network/blackberry/ResourceRequestBlackBerry.cpp

index 4e163742f210b8039315f97ea984221fee5e33de..72fcfa9dbf4ef8464f767ab17a22ae8f968ef10c 100644 (file)
@@ -1,3 +1,34 @@
+2012-03-22  Jason Liu  <jason.liu@torchmobile.com.cn>
+
+        [BlackBerry] Synchronize platform/network/blackberry
+        https://bugs.webkit.org/show_bug.cgi?id=81874
+
+        We changed a lot in these files locally. But the changes are not upstreamed.
+        It is not convenient to do the other upstreaming work based on these differences.
+        So upstream these changes.
+
+        Reviewed by Rob Buis.
+
+        No new tests. Just synchronize codes.
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::NetworkJob):
+        (WebCore::NetworkJob::initialize):
+        (WebCore::NetworkJob::handleNotifyHeaderReceived):
+        (WebCore::NetworkJob::handleNotifyDataReceived):
+        (WebCore::NetworkJob::sendResponseIfNeeded):
+        (WebCore::NetworkJob::sendRequestWithCredentials):
+        (WebCore::NetworkJob::handleAbout):
+        * platform/network/blackberry/NetworkJob.h:
+        (WebCore::NetworkJob::isError):
+        (NetworkJob):
+        * platform/network/blackberry/NetworkManager.cpp:
+        (WebCore::NetworkManager::startJob):
+        * platform/network/blackberry/ResourceRequest.h:
+        (WebCore::ResourceRequest::ResourceRequest):
+        * platform/network/blackberry/ResourceRequestBlackBerry.cpp:
+        (WebCore::platformTargetTypeForRequest):
+
 2012-03-22  Tom Sepez  <tsepez@chromium.org>
 
         XSS Auditor bypass via script tag src=data:, URLS.
index c7370813f13d3dbbcd0507c9205a3a5c002fab43..9e57314ea5199dc91ba5c1607d249aabddd856a9 100644 (file)
@@ -109,7 +109,6 @@ NetworkJob::NetworkJob()
     , m_dataReceived(false)
     , m_responseSent(false)
     , m_callingClient(false)
-    , m_isXHR(false)
     , m_needsRetryAsFTPDirectory(false)
     , m_isOverrideContentType(false)
     , m_extendedStatusCode(0)
@@ -170,8 +169,6 @@ bool NetworkJob::initialize(int playerId,
         return false;
     setWrappedStream(wrappedStream);
 
-    m_isXHR = request.getTargetType() == BlackBerry::Platform::NetworkRequest::TargetIsXMLHTTPRequest;
-
     return true;
 }
 
@@ -310,7 +307,11 @@ void NetworkJob::handleNotifyHeaderReceived(const String& key, const String& val
         m_contentDisposition = value;
 
     if (lowerKey == "set-cookie") {
-        if (m_frame && m_frame->loader() && m_frame->loader()->client()
+        // FIXME: If a tab is closed, sometimes network data will come in after the frame has been detached from its page but before it is deleted.
+        // If this happens, m_frame->page() will return 0, and m_frame->loader()->client() will be in a bad state and calling into it will crash.
+        // For now we check for this explicitly by checking m_frame->page(). But we should find out why the network job hasn't been cancelled when the frame was detached.
+        // See RIM PR 134207
+        if (m_frame && m_frame->page() && m_frame->loader() && m_frame->loader()->client()
             && static_cast<FrameLoaderClientBlackBerry*>(m_frame->loader()->client())->cookiesEnabled())
             handleSetCookieHeader(value);
     }
@@ -401,7 +402,7 @@ void NetworkJob::handleNotifyDataReceived(const char* buf, size_t len)
         // is on a file system if it has a MIME mappable file extension.
         // The file extension is likely to be correct.
         if (m_isFile) {
-            String urlFilename = m_response.url().lastPathComponent();
+            WTF::String urlFilename = m_response.url().lastPathComponent();
             size_t pos = urlFilename.reverseFind('.');
             if (pos != WTF::notFound) {
                 String extension = urlFilename.substring(pos + 1);
@@ -659,8 +660,8 @@ void NetworkJob::sendResponseIfNeeded()
         m_response.setSuggestedFilename(suggestedFilename);
     }
 
-    // Make sure local files aren't cached, since this just duplicates them.
-    if (m_isFile || m_isData || m_isAbout)
+    // Don't cache resources for "about:"
+    if (m_isAbout)
         m_response.setHTTPHeaderField("Cache-Control", "no-cache");
 
     if (isClientAvailable()) {
@@ -941,7 +942,7 @@ void NetworkJob::handleAbout()
     String result;
 
     bool handled = false;
-    if (aboutWhat.isEmpty() || equalIgnoringCase(aboutWhat, "blank")) {
+    if (equalIgnoringCase(aboutWhat, "blank")) {
         handled = true;
     } else if (equalIgnoringCase(aboutWhat, "credits")) {
         result.append(String("<html><head><title>Open Source Credits</title> <style> .about {padding:14px;} </style> <meta name=\"viewport\" content=\"width=device-width, user-scalable=no\"></head><body>"));
@@ -1012,10 +1013,9 @@ void NetworkJob::handleAbout()
         handled = true;
 #endif
     }
-
     if (handled) {
         CString resultString = result.utf8();
-        notifyStatusReceived(404, 0);
+        notifyStatusReceived(BlackBerry::Platform::FilterStream::StatusSuccess, 0);
         notifyStringHeaderReceived("Content-Length", String::number(resultString.length()));
         notifyStringHeaderReceived("Content-Type", "text/html");
         notifyDataReceivedPlain(resultString.data(), resultString.length());
index 586b45f4bc3b2cd5106d4ebc789831eb0a3061ea..3710faa4b86f0784f95a375e647159f0baca26ed 100644 (file)
@@ -145,7 +145,7 @@ private:
 
     bool isError(int statusCode)
     {
-        return statusCode < 0 || (!m_isXHR && (400 <= statusCode && statusCode < 600));
+        return statusCode < 0 || (400 <= statusCode && statusCode < 600);
     }
 
 private:
@@ -174,7 +174,6 @@ private:
     bool m_dataReceived;
     bool m_responseSent;
     bool m_callingClient;
-    bool m_isXHR; // FIXME - After 7.0, remove this. Only the Qt port reports HTTP error statuses as didFails, so we probably shouldn't.
     bool m_needsRetryAsFTPDirectory;
     bool m_isOverrideContentType;
 
index e3832e933f930af868dae565fd769ac0fd6da97b..583786bd1e7feeb6c35f3873b968ae290c36e863 100644 (file)
 #include "ResourceHandleInternal.h"
 #include "ResourceRequest.h"
 
+#include <BlackBerryPlatformClient.h>
+#include <BlackBerryPlatformLog.h>
+#include <BuildInformation.h>
+#include <network/FilterStream.h>
 #include <network/NetworkRequest.h>
 
 namespace WebCore {
@@ -108,7 +112,7 @@ bool NetworkManager::startJob(int playerId, const String& pageGroupName, PassRef
 
         if (authType != BlackBerry::Platform::NetworkRequest::AuthNone)
             platformRequest.setCredentials(username.utf8().data(), password.utf8().data(), authType);
-    } else if (url.protocolIsInHTTPFamily()) {
+    } else if (url.protocolInHTTPFamily()) {
         // For URLs that match the paths of those previously challenged for HTTP Basic authentication,
         // try and reuse the credential preemptively, as allowed by RFC 2617.
         Credential credential = CredentialStorage::get(url);
index ad191ff8423e378af00dc8e7ec0457bf7f6c08ae..3b8a47982cd10be74cf7ffa8ed22f57c8e19b782 100644 (file)
@@ -57,6 +57,7 @@ public:
         , m_mustHandleInternally(false)
         , m_isRequestedByPlugin(false)
         , m_forceDownload(false)
+        , m_targetType(TargetIsUnspecified)
     {
     }
 
@@ -66,6 +67,7 @@ public:
         , m_mustHandleInternally(false)
         , m_isRequestedByPlugin(false)
         , m_forceDownload(false)
+        , m_targetType(TargetIsUnspecified)
     {
     }
 
@@ -75,6 +77,7 @@ public:
         , m_mustHandleInternally(false)
         , m_isRequestedByPlugin(false)
         , m_forceDownload(false)
+        , m_targetType(TargetIsUnspecified)
     {
         setHTTPReferrer(referrer);
     }
@@ -85,6 +88,7 @@ public:
         , m_mustHandleInternally(false)
         , m_isRequestedByPlugin(false)
         , m_forceDownload(false)
+        , m_targetType(TargetIsUnspecified)
     {
     }
 
@@ -118,8 +122,6 @@ public:
     TargetType targetType() const { return m_targetType; }
     void setTargetType(TargetType type) { m_targetType = type; }
 
-    static TargetType targetTypeFromMimeType(const String& mimeType);
-
 private:
     friend class ResourceRequestBase;
 
index a92dbda640bd5f40d9a357146a9fda8d5d2172e4..ea408c277b0d62dbe32da12ada9b084935024c6a 100644 (file)
@@ -23,7 +23,6 @@
 #include "CookieManager.h"
 #include <BlackBerryPlatformClient.h>
 #include <network/NetworkRequest.h>
-#include <wtf/HashMap.h>
 #include <wtf/text/CString.h>
 
 using BlackBerry::Platform::NetworkRequest;
@@ -80,53 +79,28 @@ static inline NetworkRequest::TargetType platformTargetTypeForRequest(const Reso
         return NetworkRequest::TargetIsWorker;
     case ResourceRequest::TargetIsSharedWorker:
         return NetworkRequest::TargetIsSharedWorker;
+
+        // FIXME: this need to be updated to the right value, but
+        // we need to coordinate with AIR api change.
+    case ResourceRequest::TargetIsFavicon:
+        return NetworkRequest::TargetIsImage;
+    case ResourceRequest::TargetIsPrefetch:
+        return NetworkRequest::TargetIsSubresource;
+    case ResourceRequest::TargetIsPrerender:
+        return NetworkRequest::TargetIsSubresource;
+    case ResourceRequest::TargetIsXHR:
+        return NetworkRequest::TargetIsSubresource;
+    case ResourceRequest::TargetIsTextTrack:
+        return NetworkRequest::TargetIsSubresource;
+    case ResourceRequest::TargetIsUnspecified:
+        return NetworkRequest::TargetIsSubresource;
+
     default:
         ASSERT_NOT_REACHED();
         return NetworkRequest::TargetIsUnknown;
     }
 }
 
-typedef HashMap<String, ResourceRequest::TargetType> MimeTypeResourceRequestTypeMap;
-
-static const MimeTypeResourceRequestTypeMap& mimeTypeRequestTypeMap()
-{
-    static MimeTypeResourceRequestTypeMap* map = 0;
-    if (!map) {
-        map = new MimeTypeResourceRequestTypeMap;
-
-        if (map) {
-            // The list here should match extensionMap[] in MIMETypeRegistryBlackBerry.cpp
-            map->add(String("text/css"), ResourceRequest::TargetIsStyleSheet);
-            map->add(String("application/x-javascript"), ResourceRequest::TargetIsScript);
-            map->add(String("image/bmp"), ResourceRequest::TargetIsImage);
-            map->add(String("image/gif"), ResourceRequest::TargetIsImage);
-            map->add(String("image/x-icon"), ResourceRequest::TargetIsImage);
-            map->add(String("image/jpeg"), ResourceRequest::TargetIsImage);
-            map->add(String("image/png"), ResourceRequest::TargetIsImage);
-            map->add(String("image/x-portable-bitmap"), ResourceRequest::TargetIsImage);
-            map->add(String("image/x-portable-graymap"), ResourceRequest::TargetIsImage);
-            map->add(String("image/x-portable-pixmap"), ResourceRequest::TargetIsImage);
-            map->add(String("image/svg+xml"), ResourceRequest::TargetIsImage);
-            map->add(String("image/tiff"), ResourceRequest::TargetIsImage);
-            map->add(String("image/x-xbitmap"), ResourceRequest::TargetIsImage);
-            map->add(String("image/x-xpm"), ResourceRequest::TargetIsImage);
-        }
-    }
-
-    return *map;
-}
-
-ResourceRequest::TargetType ResourceRequest::targetTypeFromMimeType(const String& mimeType)
-{
-    const MimeTypeResourceRequestTypeMap& map = mimeTypeRequestTypeMap();
-
-    MimeTypeResourceRequestTypeMap::const_iterator iter = map.find(mimeType);
-    if (iter == map.end())
-        return ResourceRequest::TargetIsUnspecified;
-
-    return iter->second;
-}
-
 void ResourceRequest::initializePlatformRequest(NetworkRequest& platformRequest, bool cookiesEnabled, bool isInitial, bool isRedirect) const
 {
     // If this is the initial load, skip the request body and headers.