[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 4e16374..72fcfa9 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 c737081..9e57314 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 586b45f..3710faa 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 e3832e9..583786b 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 ad191ff..3b8a479 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 a92dbda..ea408c2 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.