Title: [116591] trunk/Source/WebCore
Revision
116591
Author
[email protected]
Date
2012-05-09 18:13:35 -0700 (Wed, 09 May 2012)

Log Message

[BlackBerry]  Refactor data scheme support
https://bugs.webkit.org/show_bug.cgi?id=85938

Reviewed by Rob Buis.

We will create a DataStream in our platform repository,
so that can be wrapped up by NetworkJob for webkit rendering,
and by DownloadStream for downloading.

Refactor, no new tests.

* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::NetworkJob):
(WebCore::NetworkJob::initialize):
(WebCore::NetworkJob::cancelJob):
(WebCore::NetworkJob::sendResponseIfNeeded):
* platform/network/blackberry/NetworkJob.h:
(NetworkJob):
* platform/network/blackberry/NetworkManager.cpp:
(WebCore::NetworkManager::startJob):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116590 => 116591)


--- trunk/Source/WebCore/ChangeLog	2012-05-10 01:01:27 UTC (rev 116590)
+++ trunk/Source/WebCore/ChangeLog	2012-05-10 01:13:35 UTC (rev 116591)
@@ -1,3 +1,26 @@
+2012-05-09  Charles Wei  <[email protected]>
+
+        [BlackBerry]  Refactor data scheme support
+        https://bugs.webkit.org/show_bug.cgi?id=85938
+
+        Reviewed by Rob Buis.
+
+        We will create a DataStream in our platform repository,
+        so that can be wrapped up by NetworkJob for webkit rendering,
+        and by DownloadStream for downloading.
+
+        Refactor, no new tests.
+
+        * platform/network/blackberry/NetworkJob.cpp:
+        (WebCore::NetworkJob::NetworkJob):
+        (WebCore::NetworkJob::initialize):
+        (WebCore::NetworkJob::cancelJob):
+        (WebCore::NetworkJob::sendResponseIfNeeded):
+        * platform/network/blackberry/NetworkJob.h:
+        (NetworkJob):
+        * platform/network/blackberry/NetworkManager.cpp:
+        (WebCore::NetworkManager::startJob):
+
 2012-05-09  Dana Jansens  <[email protected]>
 
         [chromium] Don't draw when canDraw() is false

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (116590 => 116591)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-05-10 01:01:27 UTC (rev 116590)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp	2012-05-10 01:13:35 UTC (rev 116591)
@@ -20,7 +20,6 @@
 #include "NetworkJob.h"
 
 #include "AboutData.h"
-#include "Base64.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "CookieManager.h"
@@ -41,10 +40,9 @@
 #include <BlackBerryPlatformLog.h>
 #include <BlackBerryPlatformWebKitCredits.h>
 #include <BuildInformation.h>
+#include <LocalizeResource.h>
 #include <network/MultipartStream.h>
-#include <network/NetworkRequest.h>
 #include <network/NetworkStreamFactory.h>
-#include <wtf/ASCIICType.h>
 
 namespace WebCore {
 
@@ -65,39 +63,12 @@
     return statusCode == 401;
 }
 
-static void escapeDecode(const char* src, int length, Vector<char>& out)
-{
-    out.resize(length);
-    const char* const srcEnd = src + length;
-    char* dst = out.data();
-    for (; src < srcEnd; ) {
-        char inputChar = *src++;
-        if (inputChar == '%' && src + 2 <= srcEnd) {
-            int digit1 = 0;
-            char character = *src++;
-            if (isASCIIHexDigit(character))
-                digit1 = toASCIIHexValue(character);
-
-            int digit2 = 0;
-            character = *src++;
-            if (isASCIIHexDigit(character))
-                digit2 = toASCIIHexValue(character);
-
-            *dst++ = (digit1 << 4) | digit2;
-        } else
-            *dst++ = inputChar;
-    }
-    out.resize(dst - out.data());
-}
-
 NetworkJob::NetworkJob()
     : m_playerId(0)
-    , m_loadDataTimer(this, &NetworkJob::fireLoadDataTimer)
     , m_loadAboutTimer(this, &NetworkJob::fireLoadAboutTimer)
     , m_deleteJobTimer(this, &NetworkJob::fireDeleteJobTimer)
     , m_streamFactory(0)
     , m_isFile(false)
-    , m_isData(false)
     , m_isAbout(false)
     , m_isFTP(false)
     , m_isFTPDir(true)
@@ -134,7 +105,6 @@
 
     m_response.setURL(url);
     m_isFile = url.protocolIs("file") || url.protocolIs("local");
-    m_isData = url.protocolIs("data");
     m_isAbout = url.protocolIs("about");
     m_isFTP = url.protocolIs("ftp");
 
@@ -160,8 +130,8 @@
         m_isOverrideContentType = true;
     }
 
-    // No need to create the streams for data and about.
-    if (m_isData || m_isAbout)
+    // No need to create the streams for about.
+    if (m_isAbout)
         return true;
 
     if (!request.getSuggestedSaveName().empty()) {
@@ -188,11 +158,6 @@
 
     // Cancel jobs loading local data by killing the timer, and jobs
     // getting data from the network by calling the inherited URLStream::cancel.
-    if (m_loadDataTimer.isActive()) {
-        m_loadDataTimer.stop();
-        notifyClose(BlackBerry::Platform::FilterStream::StatusCancelled);
-        return 0;
-    }
 
     if (m_loadAboutTimer.isActive()) {
         m_loadAboutTimer.stop();
@@ -612,7 +577,9 @@
     if (isError(m_extendedStatusCode) && !m_dataReceived)
         return;
 
-    String urlFilename = m_response.url().lastPathComponent();
+    String urlFilename;
+    if (!m_response.url().protocolIsData() && !m_response.url().protocolIs("about"))
+        urlFilename = m_response.url().lastPathComponent();
 
     // Get the MIME type that was set by the content sniffer
     // if there's no custom sniffer header, try to set it from the Content-Type header
@@ -635,18 +602,18 @@
         m_response.setExpectedContentLength(contentLength.toInt64());
 
     // Set suggested filename for downloads from the Content-Disposition header; if this fails,
-    // fill it in from the url and sniffed mime type;Skip this for data and about URLs,
+    // fill it in from the url and sniffed mime type;Skip this for about URLs,
     // because they have no Content-Disposition header and the format is wrong to be a filename.
-    if (!m_isData && !m_isAbout) {
+    if (!m_isAbout) {
         String suggestedFilename = filenameFromHTTPContentDisposition(m_contentDisposition);
         if (suggestedFilename.isEmpty()) {
             // Check and see if an extension already exists.
             String mimeExtension = MIMETypeRegistry::getPreferredExtensionForMIMEType(mimeType);
             if (urlFilename.isEmpty()) {
                 if (mimeExtension.isEmpty()) // No extension found for the mimeType.
-                    suggestedFilename = String("Untitled");
+                    suggestedFilename = String(BlackBerry::Platform::LocalizeResource::getString(BlackBerry::Platform::FILENAME_UNTITLED));
                 else
-                    suggestedFilename = String("Untitled") + "." + mimeExtension;
+                    suggestedFilename = String(BlackBerry::Platform::LocalizeResource::getString(BlackBerry::Platform::FILENAME_UNTITLED)) + "." + mimeExtension;
             } else {
                 if (urlFilename.reverseFind('.') == notFound && !mimeExtension.isEmpty())
                    suggestedFilename = urlFilename + '.' + mimeExtension;
@@ -675,72 +642,6 @@
     }
 }
 
-void NetworkJob::parseData()
-{
-    Vector<char> result;
-
-    String contentType("text/plain;charset=US-ASCII");
-
-    String data(m_response.url().string().substring(5));
-    Vector<String> hparts;
-    bool isBase64 = false;
-
-    size_t index = data.find(',');
-    if (index != notFound && index > 0) {
-        contentType = data.left(index).lower();
-        data = "" + 1);
-
-        contentType.split(';', hparts);
-        Vector<String>::iterator i;
-        for (i = hparts.begin(); i != hparts.end(); ++i) {
-            if (i->stripWhiteSpace().lower() == "base64") {
-                isBase64 = true;
-                String value = *i;
-                do {
-                    if (*i == value) {
-                        int position = i - hparts.begin();
-                        hparts.remove(position);
-                        i = hparts.begin() + position;
-                    } else
-                        ++i;
-                } while (i != hparts.end());
-                break;
-            }
-        }
-        contentType = String();
-        for (i = hparts.begin(); i != hparts.end(); ++i) {
-            if (i > hparts.begin())
-                contentType += ",";
-
-            contentType += *i;
-        }
-    } else if (!index)
-        data = "" // Broken header.
-
-    {
-        CString latin = data.latin1();
-        escapeDecode(latin.data(), latin.length(), result);
-    }
-
-    if (isBase64) {
-        String s(result.data(), result.size());
-        CString latin = s.removeCharacters(isSpaceOrNewline).latin1();
-        result.clear();
-        result.append(latin.data(), latin.length());
-        Vector<char> bytesOut;
-        if (base64Decode(result, bytesOut))
-            result.swap(bytesOut);
-        else
-            result.clear();
-    }
-
-    notifyStatusReceived(result.isEmpty() ? 404 : 200, 0);
-    notifyStringHeaderReceived("Content-Type", contentType);
-    notifyStringHeaderReceived("Content-Length", String::number(result.size()));
-    notifyDataReceivedPlain(result.data(), result.size());
-    notifyClose(BlackBerry::Platform::FilterStream::StatusSuccess);
-}
-
 bool NetworkJob::handleAuthHeader(const ProtectionSpaceServerType space, const String& header)
 {
     if (!m_handle)

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h (116590 => 116591)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2012-05-10 01:01:27 UTC (rev 116590)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h	2012-05-10 01:13:35 UTC (rev 116591)
@@ -60,7 +60,6 @@
     bool isRunning() const { return m_isRunning; }
 #endif
     bool isCancelled() const { return m_cancelled; }
-    void loadDataURL() { m_loadDataTimer.startOneShot(0); }
     void loadAboutURL();
     int cancelJob();
     bool isDeferringLoading() const { return m_deferLoadingCount > 0; }
@@ -113,11 +112,6 @@
     void sendResponseIfNeeded();
     void sendMultipartResponseIfNeeded();
 
-    void fireLoadDataTimer(Timer<NetworkJob>*)
-    {
-        parseData();
-    }
-
     void fireLoadAboutTimer(Timer<NetworkJob>*)
     {
         handleAbout();
@@ -125,8 +119,6 @@
 
     void fireDeleteJobTimer(Timer<NetworkJob>*);
 
-    void parseData();
-
     void handleAbout();
 
     // The server needs authentication credentials. Search in the
@@ -151,7 +143,6 @@
     String m_pageGroupName;
     RefPtr<ResourceHandle> m_handle;
     ResourceResponse m_response;
-    Timer<NetworkJob> m_loadDataTimer;
     Timer<NetworkJob> m_loadAboutTimer;
     OwnPtr<ResourceResponse> m_multipartResponse;
     Timer<NetworkJob> m_deleteJobTimer;
@@ -160,7 +151,6 @@
     String m_contentDisposition;
     BlackBerry::Platform::NetworkStreamFactory* m_streamFactory;
     bool m_isFile;
-    bool m_isData;
     bool m_isAbout;
     bool m_isFTP;
     bool m_isFTPDir;

Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp (116590 => 116591)


--- trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp	2012-05-10 01:01:27 UTC (rev 116590)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkManager.cpp	2012-05-10 01:13:35 UTC (rev 116591)
@@ -136,11 +136,6 @@
 
     m_jobs.append(networkJob);
 
-    if (url.protocolIs("data")) {
-        networkJob->loadDataURL();
-        return true;
-    }
-
     if (url.protocolIs("about")) {
         // If the protocol matches "about", loadAboutURL should recognize and handle it.
         networkJob->loadAboutURL();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to