Title: [150217] trunk/Source
Revision
150217
Author
mary...@torchmobile.com.cn
Date
2013-05-16 17:11:54 -0700 (Thu, 16 May 2013)

Log Message

[BlackBerry] Unable to download blob resource
https://bugs.webkit.org/show_bug.cgi?id=115888

Reviewed by Benjamin Poulain.

Source/WebCore:

Add BlobStream to handle over blob data from BlobResourceHandle to download stream.
RIM bug 331086, internally reviewed by Charles Wei and Leo Yang.

* PlatformBlackBerry.cmake:
* platform/network/blackberry/BlobStream.cpp: Added.
(WebCore):
(WebCore::BlobStream::BlobStream):
(WebCore::BlobStream::~BlobStream):
(WebCore::BlobStream::didReceiveData):
(WebCore::BlobStream::didFinishLoading):
(WebCore::BlobStream::didFail):
(WebCore::BlobStream::url):
(WebCore::BlobStream::mimeType):
* platform/network/blackberry/BlobStream.h: Added.
(WebCore):
(BlobStream):

Source/WebKit/blackberry:

For blob resource (blob:http....), it's not suitable to go to NetworkStream
which don't handle "blob" protocol at all. since blob data already handled
in BlobResourceHandle, simply get the data out to download stream.

RIM bug 331086, internally reviewed by Charles Wei and Leo Yang.

* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::convertMainResourceLoadToDownload):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150216 => 150217)


--- trunk/Source/WebCore/ChangeLog	2013-05-17 00:06:10 UTC (rev 150216)
+++ trunk/Source/WebCore/ChangeLog	2013-05-17 00:11:54 UTC (rev 150217)
@@ -1,3 +1,27 @@
+2013-05-16  Mary Wu  <mary...@torchmobile.com.cn>
+
+        [BlackBerry] Unable to download blob resource
+        https://bugs.webkit.org/show_bug.cgi?id=115888
+
+        Reviewed by Benjamin Poulain.
+
+        Add BlobStream to handle over blob data from BlobResourceHandle to download stream.
+        RIM bug 331086, internally reviewed by Charles Wei and Leo Yang.
+
+        * PlatformBlackBerry.cmake:
+        * platform/network/blackberry/BlobStream.cpp: Added.
+        (WebCore):
+        (WebCore::BlobStream::BlobStream):
+        (WebCore::BlobStream::~BlobStream):
+        (WebCore::BlobStream::didReceiveData):
+        (WebCore::BlobStream::didFinishLoading):
+        (WebCore::BlobStream::didFail):
+        (WebCore::BlobStream::url):
+        (WebCore::BlobStream::mimeType):
+        * platform/network/blackberry/BlobStream.h: Added.
+        (WebCore):
+        (BlobStream):
+
 2013-05-16  Anders Carlsson  <ander...@apple.com>
 
         Remove SystemTime header and implementations

Modified: trunk/Source/WebCore/PlatformBlackBerry.cmake (150216 => 150217)


--- trunk/Source/WebCore/PlatformBlackBerry.cmake	2013-05-17 00:06:10 UTC (rev 150216)
+++ trunk/Source/WebCore/PlatformBlackBerry.cmake	2013-05-17 00:11:54 UTC (rev 150217)
@@ -44,6 +44,7 @@
     platform/network/NetworkStorageSessionStub.cpp
     platform/network/ProxyServer.cpp
     platform/network/blackberry/AutofillBackingStore.cpp
+    platform/network/blackberry/BlobStream.cpp
     platform/network/blackberry/CookieJarBlackBerry.cpp
     platform/network/blackberry/DNSBlackBerry.cpp
     platform/network/blackberry/DeferredData.cpp

Added: trunk/Source/WebCore/platform/network/blackberry/BlobStream.cpp (0 => 150217)


--- trunk/Source/WebCore/platform/network/blackberry/BlobStream.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/blackberry/BlobStream.cpp	2013-05-17 00:11:54 UTC (rev 150217)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "BlobStream.h"
+
+#include "ResourceHandle.h"
+
+using BlackBerry::Platform::FilterStream;
+
+namespace WebCore {
+
+BlobStream::BlobStream(const ResourceResponse& response, ResourceHandle* handle)
+    : FilterStream()
+    , m_response(response)
+{
+    registerStreamId();
+    handle->setClient(this);
+}
+
+BlobStream::~BlobStream()
+{
+}
+
+void BlobStream::didReceiveData(ResourceHandle*, const char* data, int len, int)
+{
+    notifyDataReceived(BlackBerry::Platform::createNetworkBufferByWrappingData(data, len));
+}
+
+void BlobStream::didFinishLoading(ResourceHandle*, double)
+{
+    notifyClose(FilterStream::StatusSuccess);
+}
+
+void BlobStream::didFail(ResourceHandle*, const ResourceError&)
+{
+    notifyClose(FilterStream::StatusErrorIO);
+}
+
+BlackBerry::Platform::String BlobStream::url() const
+{
+    return m_response.url().string();
+}
+
+const BlackBerry::Platform::String BlobStream::mimeType() const
+{
+    return m_response.mimeType();
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/platform/network/blackberry/BlobStream.h (0 => 150217)


--- trunk/Source/WebCore/platform/network/blackberry/BlobStream.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/network/blackberry/BlobStream.h	2013-05-17 00:11:54 UTC (rev 150217)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef BlobStream_h
+#define BlobStream_h
+
+#include "ResourceHandleClient.h"
+#include "ResourceResponse.h"
+
+#include <network/FilterStream.h>
+
+namespace WebCore {
+
+class ResourceHandle;
+
+class BlobStream : public ResourceHandleClient, public BlackBerry::Platform::FilterStream {
+public:
+    BlobStream(const ResourceResponse&, ResourceHandle*);
+    virtual ~BlobStream();
+
+    // From class BlackBerry::Platform::FilterStream.
+    virtual BlackBerry::Platform::String url() const OVERRIDE;
+    virtual const BlackBerry::Platform::String mimeType() const OVERRIDE;
+
+    // From class ResourceHandleClient.
+    virtual void didReceiveData(ResourceHandle*, const char*, int, int) OVERRIDE;
+    virtual void didFinishLoading(ResourceHandle*, double) OVERRIDE;
+    virtual void didFail(ResourceHandle*, const ResourceError&) OVERRIDE;
+
+private:
+    ResourceResponse m_response;
+};
+
+} // namespace WebCore
+
+#endif // BlobStream_h

Modified: trunk/Source/WebKit/blackberry/ChangeLog (150216 => 150217)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-05-17 00:06:10 UTC (rev 150216)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-05-17 00:11:54 UTC (rev 150217)
@@ -1,3 +1,19 @@
+2013-05-16  Mary Wu  <mary...@torchmobile.com.cn>
+
+        [BlackBerry] Unable to download blob resource
+        https://bugs.webkit.org/show_bug.cgi?id=115888
+
+        Reviewed by Benjamin Poulain.
+
+        For blob resource (blob:http....), it's not suitable to go to NetworkStream
+        which don't handle "blob" protocol at all. since blob data already handled
+        in BlobResourceHandle, simply get the data out to download stream.
+
+        RIM bug 331086, internally reviewed by Charles Wei and Leo Yang.
+
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::convertMainResourceLoadToDownload):
+
 2013-05-16  Andreas Kling  <akl...@apple.com>
 
         Page::chrome() should return a reference.

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (150216 => 150217)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2013-05-17 00:06:10 UTC (rev 150216)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2013-05-17 00:11:54 UTC (rev 150217)
@@ -24,6 +24,7 @@
 #include "BackForwardController.h"
 #include "BackingStoreClient.h"
 #include "BackingStore_p.h"
+#include "BlobStream.h"
 #include "CredentialManager.h"
 #include "CredentialTransformData.h"
 #include "DumpRenderTreeClient.h"
@@ -1202,6 +1203,9 @@
 {
     ASSERT(documentLoader);
     ResourceBuffer* buff = documentLoader->mainResourceData().get();
+    BlackBerry::Platform::String filename = response.suggestedFilename();
+    if (filename.empty())
+        filename = request.suggestedSaveName();
 
     if (!buff) {
         // If no cached, like policyDownload resource which don't go render at all, just direct to downloadStream.
@@ -1212,14 +1216,12 @@
         // associated with a ResourceHandle. For instance, Blob objects
         // have their own ResourceHandle class which won't call startJob
         // to do the proper setup. Do it here.
-        if (!stream) {
-            int playerId = static_cast<FrameLoaderClientBlackBerry*>(m_frame->loader()->client())->playerId();
-            NetworkManager::instance()->startJob(playerId, handle, request, m_frame, false);
-            stream = NetworkManager::instance()->streamForHandle(handle);
-        }
+        if (!stream)
+            stream = new BlobStream(response, handle);
+
         ASSERT(stream);
 
-        m_webPagePrivate->m_client->downloadRequested(stream, response.suggestedFilename());
+        m_webPagePrivate->m_client->downloadRequested(stream, filename);
         return;
     }
 
@@ -1231,10 +1233,10 @@
     STATIC_LOCAL_STRING(s_base64, ";base64,");
     url.append(s_base64);
     url.append(BlackBerry::Platform::String::fromUtf8(base64Encode(CString(buff->data(), buff->size())).utf8().data()));
-    NetworkRequest req;
-    req.setRequestUrl(url.string(), BlackBerry::Platform::String::fromAscii("GET"));
-    BlackBerry::Platform::DataStream *stream = new BlackBerry::Platform::DataStream(req);
-    m_webPagePrivate->m_client->downloadRequested(stream, response.suggestedFilename());
+    NetworkRequest netRequest;
+    netRequest.setRequestUrl(url.string());
+    BlackBerry::Platform::DataStream *stream = new BlackBerry::Platform::DataStream(netRequest);
+    m_webPagePrivate->m_client->downloadRequested(stream, filename);
     stream->streamOpen();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to