[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 11:14:44 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5673e694e0eda8dc2f63444b004c18a60cfcac55
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jul 15 22:21:52 2010 +0000
Cancel stream loads when destroying NetscapePluginStreams
https://bugs.webkit.org/show_bug.cgi?id=42413
Reviewed by Sam Weinig.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::cancelStreamLoad):
Call PluginController::cancelStreamLoad.
(WebKit::NetscapePlugin::streamDidReceiveResponse):
Call NetscapePluginStream::didReceiveResponse.
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::didReceiveResponse):
Try to start the stream.
(WebKit::NetscapePluginStream::sendJavaScriptStream):
Don't stop the stream if it can't be started. start handles that now.
(WebKit::isSupportedTransferMode):
Return whether the given transfer mode is supported.
(WebKit::NetscapePluginStream::start):
If the stream fails to start, call notifyAndDestroyStream. If it starts successfully but has
an unsupported transfer mode, call stop.
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
Cancel the stream load unless it's being destroyed because it has finished loading.
* WebProcess/Plugins/PluginController.h:
Add cancelStreamLoad pure virtual member function.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::Stream::cancel):
Tell the stream loader to cancel and null it out.
(WebKit::PluginView::cancelStreamLoad):
Get the stream and cancel it.
* WebProcess/Plugins/PluginView.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63473 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 8fa95c5..cc76afa 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -10,6 +10,49 @@
Reviewed by Sam Weinig.
+ Cancel stream loads when destroying NetscapePluginStreams
+ https://bugs.webkit.org/show_bug.cgi?id=42413
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::cancelStreamLoad):
+ Call PluginController::cancelStreamLoad.
+
+ (WebKit::NetscapePlugin::streamDidReceiveResponse):
+ Call NetscapePluginStream::didReceiveResponse.
+
+ * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
+ (WebKit::NetscapePluginStream::didReceiveResponse):
+ Try to start the stream.
+
+ (WebKit::NetscapePluginStream::sendJavaScriptStream):
+ Don't stop the stream if it can't be started. start handles that now.
+
+ (WebKit::isSupportedTransferMode):
+ Return whether the given transfer mode is supported.
+
+ (WebKit::NetscapePluginStream::start):
+ If the stream fails to start, call notifyAndDestroyStream. If it starts successfully but has
+ an unsupported transfer mode, call stop.
+
+ (WebKit::NetscapePluginStream::notifyAndDestroyStream):
+ Cancel the stream load unless it's being destroyed because it has finished loading.
+
+ * WebProcess/Plugins/PluginController.h:
+ Add cancelStreamLoad pure virtual member function.
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::Stream::cancel):
+ Tell the stream loader to cancel and null it out.
+
+ (WebKit::PluginView::cancelStreamLoad):
+ Get the stream and cancel it.
+
+ * WebProcess/Plugins/PluginView.h:
+
+2010-07-15 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
Start loading plug-in streams
https://bugs.webkit.org/show_bug.cgi?id=42407
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 439fe38..6ebc67e 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -143,10 +143,15 @@ NPError NetscapePlugin::destroyStream(NPStream* stream, NPReason reason)
return pluginStream->destroy(reason);
}
+void NetscapePlugin::cancelStreamLoad(NetscapePluginStream* pluginStream)
+{
+ // Ask the plug-in controller to cancel this stream load.
+ m_pluginController->cancelStreamLoad(pluginStream->streamID());
+}
+
void NetscapePlugin::removePluginStream(NetscapePluginStream* pluginStream)
{
ASSERT(m_streams.get(pluginStream->streamID()) == pluginStream);
-
m_streams.remove(pluginStream->streamID());
}
@@ -328,7 +333,8 @@ void NetscapePlugin::didEvaluateJavaScript(uint64_t requestID, const String& req
void NetscapePlugin::streamDidReceiveResponse(uint64_t streamID, const KURL& responseURL, uint32_t streamLength,
uint32_t lastModifiedTime, const String& mimeType, const String& headers)
{
- // FIXME: Implement.
+ if (NetscapePluginStream* pluginStream = streamFromID(streamID))
+ pluginStream->didReceiveResponse(responseURL, streamLength, lastModifiedTime, mimeType, headers);
}
PluginController* NetscapePlugin::controller()
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index e54fdd5..13df561 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -55,6 +55,7 @@ public:
void loadURL(const WebCore::String& urlString, const WebCore::String& target, bool sendNotification, void* notificationData);
NPError destroyStream(NPStream*, NPReason);
+ void cancelStreamLoad(NetscapePluginStream*);
void removePluginStream(NetscapePluginStream*);
// Member functions for calling into the plug-in.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
index c4b5719..d809153 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
@@ -56,6 +56,11 @@ NetscapePluginStream::~NetscapePluginStream()
ASSERT(!m_sendNotification || m_urlNotifyHasBeenCalled);
}
+void NetscapePluginStream::didReceiveResponse(const KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers)
+{
+ start(responseURL, streamLength, lastModifiedTime, mimeType, headers);
+}
+
void NetscapePluginStream::sendJavaScriptStream(const String& requestURLString, const String& result)
{
// starting the stream or delivering the data to it might cause the plug-in stream to go away, so we keep
@@ -69,10 +74,8 @@ void NetscapePluginStream::sendJavaScriptStream(const String& requestURLString,
return;
}
- if (!start(requestURLString, resultCString.length(), 0, "text/plain", "")) {
- stop(NPRES_NETWORK_ERR);
+ if (!start(requestURLString, resultCString.length(), 0, "text/plain", ""))
return;
- }
deliverData(resultCString.data(), resultCString.length());
stop(NPRES_DONE);
@@ -93,8 +96,25 @@ NPError NetscapePluginStream::destroy(NPReason reason)
return NPERR_NO_ERROR;
}
-bool NetscapePluginStream::start(const WebCore::String& responseURLString, uint32_t expectedContentLength,
- uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers)
+static bool isSupportedTransferMode(uint16_t transferMode)
+{
+ switch (transferMode) {
+ case NP_NORMAL:
+ return true;
+ // FIXME: We don't support streaming to files.
+ case NP_ASFILEONLY:
+ case NP_ASFILE:
+ return false;
+ // FIXME: We don't support seekable streams.
+ case NP_SEEK:
+ return false;
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+bool NetscapePluginStream::start(const WebCore::String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers)
{
m_responseURL = responseURLString.utf8();
m_mimeType = mimeType.utf8();
@@ -102,28 +122,25 @@ bool NetscapePluginStream::start(const WebCore::String& responseURLString, uint3
m_npStream.ndata = this;
m_npStream.url = m_responseURL.data();
- m_npStream.end = expectedContentLength;
+ m_npStream.end = streamLength;
m_npStream.lastmodified = lastModifiedTime;
m_npStream.notifyData = 0;
m_npStream.headers = m_headers.length() == 0 ? 0 : m_headers.data();
NPError error = m_plugin->NPP_NewStream(const_cast<char*>(m_mimeType.data()), &m_npStream, false, &m_transferMode);
- if (error != NPERR_NO_ERROR)
+ if (error != NPERR_NO_ERROR) {
+ // We failed to start the stream, destroy it.
+ notifyAndDestroyStream(NPRES_NETWORK_ERR);
return false;
+ }
// We successfully started the stream.
m_isStarted = true;
- switch (m_transferMode) {
- case NP_NORMAL:
- break;
- // FIXME: We don't support streaming to files.
- case NP_ASFILEONLY:
- case NP_ASFILE:
- return false;
- // FIXME: We don't support seekable streams.
- case NP_SEEK:
- return false;
+ if (!isSupportedTransferMode(m_transferMode)) {
+ // Stop the stream.
+ stop(NPRES_NETWORK_ERR);
+ return false;
}
return true;
@@ -240,6 +257,9 @@ void NetscapePluginStream::notifyAndDestroyStream(NPReason reason)
#endif
}
+ if (reason != NPRES_DONE)
+ m_plugin->cancelStreamLoad(this);
+
m_plugin->removePluginStream(this);
}
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
index 260918d..074355b 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
@@ -34,6 +34,7 @@
#include <wtf/text/CString.h>
namespace WebCore {
+ class KURL;
class String;
}
@@ -52,6 +53,9 @@ public:
uint64_t streamID() const { return m_streamID; }
const NPStream* npStream() const { return &m_npStream; }
+ void didReceiveResponse(const WebCore::KURL& responseURL, uint32_t streamLength,
+ uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
+
void sendJavaScriptStream(const WebCore::String& requestURLString, const WebCore::String& result);
NPError destroy(NPReason);
@@ -59,7 +63,7 @@ public:
private:
NetscapePluginStream(PassRefPtr<NetscapePlugin>, uint64_t streamID, bool sendNotification, void* notificationData);
- bool start(const WebCore::String& responseURLString, uint32_t expectedContentLength,
+ bool start(const WebCore::String& responseURLString, uint32_t streamLength,
uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
void stop(NPReason);
diff --git a/WebKit2/WebProcess/Plugins/PluginController.h b/WebKit2/WebProcess/Plugins/PluginController.h
index 625bddb..0160e35 100644
--- a/WebKit2/WebProcess/Plugins/PluginController.h
+++ b/WebKit2/WebProcess/Plugins/PluginController.h
@@ -47,8 +47,13 @@ public:
// If a target is specified, then the URL will be loaded in the window or frame that the target refers to.
// Once the URL finishes loading, Plugin::frameDidFinishLoading will be called with the given requestID. If the URL
// fails to load, Plugin::frameDidFailToLoad will be called.
+ //
+ // If the URL is a JavaScript URL, the JavaScript code will be evaluated and the result sent back using Plugin::didEvaluateJavaScript.
virtual void loadURL(uint64_t requestID, const WebCore::String& urlString, const WebCore::String& target, bool allowPopups) = 0;
-
+
+ /// Cancels the load of a stream that was requested by loadURL.
+ virtual void cancelStreamLoad(uint64_t streamID) = 0;
+
protected:
virtual ~PluginController() { }
};
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index abdf177..a98e9cb 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -74,6 +74,7 @@ public:
}
void start();
+ void cancel();
uint64_t streamID() const { return m_streamID; }
@@ -112,6 +113,14 @@ void PluginView::Stream::start()
m_loader->load(m_request);
}
+void PluginView::Stream::cancel()
+{
+ ASSERT(m_loader);
+
+ m_loader->cancel(m_loader->cancelledError());
+ m_loader = 0;
+}
+
void PluginView::Stream::didReceiveResponse(NetscapePlugInStreamLoader*, const ResourceResponse& response)
{
// Compute the stream related data from the resource response.
@@ -471,6 +480,16 @@ void PluginView::loadURL(uint64_t requestID, const String& urlString, const Stri
m_pendingURLRequestsTimer.startOneShot(0);
}
+void PluginView::cancelStreamLoad(uint64_t streamID)
+{
+ PluginView::Stream* stream = m_streams.get(streamID).get();
+ if (!stream)
+ return;
+
+ stream->cancel();
+ removeStream(stream);
+}
+
void PluginView::didFinishLoad(WebFrame* webFrame)
{
RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame);
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index 7108212..bff43ee 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -88,6 +88,7 @@ private:
virtual void invalidate(const WebCore::IntRect&);
virtual WebCore::String userAgent(const WebCore::KURL&);
virtual void loadURL(uint64_t requestID, const WebCore::String& urlString, const WebCore::String& target, bool allowPopups);
+ virtual void cancelStreamLoad(uint64_t streamID);
// WebFrame::LoadListener
virtual void didFinishLoad(WebFrame*);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list