[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:23 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit bece61dc316b6a16b80e423e320dd00c54c6e27a
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jul 15 20:06:15 2010 +0000
Implement NPN_DestroyStream
https://bugs.webkit.org/show_bug.cgi?id=42393
Reviewed by Sam Weinig.
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_DestroyStream):
Call NetscapePlugin::destroyStream.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::destroyStream):
Check if the stream is valid, and if it is call NetscapePluginStream::destroy.
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::sendJavaScriptStream):
Keep a reference to the stream in case it's destroyed by an NPP_ call.
(WebKit::NetscapePluginStream::destroy):
Verify that the stream can be destroyed and stop it.
(WebKit::NetscapePluginStream::deliverDataToPlugin):
Add m_isStarted checks after any calls to NPP_ functions.
(WebKit::NetscapePluginStream::stop):
Set m_isStarted to false before calling NPP_DestroyStream.
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
(WebKit::NetscapePluginStream::npStream):
Add NPStream getter.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63451 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 7e1a57e..651ca0f 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,37 @@
2010-07-15 Anders Carlsson <andersca at apple.com>
+ Reviewed by Sam Weinig.
+
+ Implement NPN_DestroyStream
+ https://bugs.webkit.org/show_bug.cgi?id=42393
+
+ * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+ (WebKit::NPN_DestroyStream):
+ Call NetscapePlugin::destroyStream.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::destroyStream):
+ Check if the stream is valid, and if it is call NetscapePluginStream::destroy.
+
+ * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
+ (WebKit::NetscapePluginStream::sendJavaScriptStream):
+ Keep a reference to the stream in case it's destroyed by an NPP_ call.
+
+ (WebKit::NetscapePluginStream::destroy):
+ Verify that the stream can be destroyed and stop it.
+
+ (WebKit::NetscapePluginStream::deliverDataToPlugin):
+ Add m_isStarted checks after any calls to NPP_ functions.
+
+ (WebKit::NetscapePluginStream::stop):
+ Set m_isStarted to false before calling NPP_DestroyStream.
+
+ * WebProcess/Plugins/Netscape/NetscapePluginStream.h:
+ (WebKit::NetscapePluginStream::npStream):
+ Add NPStream getter.
+
+2010-07-15 Anders Carlsson <andersca at apple.com>
+
Reviewed by Darin Adler.
WebKitTestRunner goes off the deep end, spinning in a dispatch queue thread
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index 5db27b9..907c993 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -62,10 +62,11 @@ static int32_t NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buff
return -1;
}
-static NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
+static NPError NPN_DestroyStream(NPP npp, NPStream* stream, NPReason reason)
{
- notImplemented();
- return NPERR_GENERIC_ERROR;
+ RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+
+ return plugin->destroyStream(stream, reason);
}
static void NPN_Status(NPP instance, const char* message)
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index f9a4e3f..b68ce17 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -126,6 +126,23 @@ void NetscapePlugin::loadURL(const String& urlString, const String& target, bool
}
}
+NPError NetscapePlugin::destroyStream(NPStream* stream, NPReason reason)
+{
+ NetscapePluginStream* pluginStream = 0;
+
+ for (StreamsMap::const_iterator it = m_streams.begin(), end = m_streams.end(); it != end; ++it) {
+ if (it->second->npStream() == stream) {
+ pluginStream = it->second.get();
+ break;
+ }
+ }
+
+ if (!pluginStream)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ return pluginStream->destroy(reason);
+}
+
void NetscapePlugin::removePluginStream(NetscapePluginStream* pluginStream)
{
ASSERT(m_streams.get(pluginStream->streamID()) == pluginStream);
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index b7862a8..fd4a270 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -53,6 +53,7 @@ public:
void invalidate(const NPRect*);
const char* userAgent();
void loadURL(const WebCore::String& urlString, const WebCore::String& target, bool sendNotification, void* notificationData);
+ NPError destroyStream(NPStream*, NPReason);
void removePluginStream(NetscapePluginStream*);
@@ -94,7 +95,8 @@ private:
typedef HashMap<uint64_t, std::pair<WebCore::String, void*> > PendingURLNotifyMap;
PendingURLNotifyMap m_pendingURLNotifications;
- HashMap<uint64_t, RefPtr<NetscapePluginStream> > m_streams;
+ typedef HashMap<uint64_t, RefPtr<NetscapePluginStream> > StreamsMap;
+ StreamsMap m_streams;
RefPtr<NetscapePluginModule> m_pluginModule;
NPP_t m_npp;
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
index 7816e9e..a2dd090 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
@@ -54,6 +54,10 @@ NetscapePluginStream::~NetscapePluginStream()
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
+ // a reference to it here.
+ RefPtr<NetscapePluginStream> protect(this);
+
CString resultCString = requestURLString.utf8();
if (resultCString.isNull()) {
// There was an error evaluating the JavaScript, just call stop.
@@ -70,6 +74,21 @@ void NetscapePluginStream::sendJavaScriptStream(const String& requestURLString,
stop(NPRES_DONE);
}
+NPError NetscapePluginStream::destroy(NPReason reason)
+{
+ // It doesn't make sense to call NPN_DestroyStream on a stream that hasn't been started yet.
+ if (!m_isStarted)
+ return NPERR_GENERIC_ERROR;
+
+ // It isn't really valid for a plug-in to call NPN_DestroyStream with NPRES_DONE.
+ // (At least not for browser initiated streams, and we don't support plug-in initiated streams).
+ if (reason == NPRES_DONE)
+ return NPERR_INVALID_PARAM;
+
+ stop(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)
{
@@ -133,6 +152,10 @@ void NetscapePluginStream::deliverDataToPlugin()
while (numBytesDelivered < numBytesToDeliver) {
int32_t numBytesPluginCanHandle = m_plugin->NPP_WriteReady(&m_npStream);
+ // NPP_WriteReady could call NPN_DestroyStream and destroy the stream.
+ if (!m_isStarted)
+ return;
+
if (numBytesPluginCanHandle <= 0) {
// The plug-in can't handle more data, we'll send the rest later
m_deliveryDataTimer.startOneShot(0);
@@ -149,6 +172,10 @@ void NetscapePluginStream::deliverDataToPlugin()
ASSERT_NOT_REACHED();
}
+ // NPP_Write could call NPN_DestroyStream and destroy the stream.
+ if (!m_isStarted)
+ return;
+
numBytesWritten = min(numBytesWritten, dataLength);
m_offset += numBytesWritten;
numBytesDelivered += numBytesWritten;
@@ -171,6 +198,9 @@ void NetscapePluginStream::deliverDataToPlugin()
void NetscapePluginStream::stop(NPReason reason)
{
+ if (!m_isStarted)
+ return;
+
if (m_isStarted) {
if (reason == NPRES_DONE && m_deliveryData && !m_deliveryData->isEmpty()) {
// There is still data left that the plug-in hasn't been able to consume yet.
@@ -186,8 +216,10 @@ void NetscapePluginStream::stop(NPReason reason)
m_deliveryData = 0;
m_deliveryDataTimer.stop();
- m_plugin->NPP_DestroyStream(&m_npStream, reason);
+ // Set m_isStarted to false before calling NPP_DestroyStream in case NPP_DestroyStream calls NPN_DestroyStream.
m_isStarted = false;
+
+ m_plugin->NPP_DestroyStream(&m_npStream, reason);
}
ASSERT(!m_deliveryDataTimer.isActive());
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
index f97dbf2..1a937ef 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
@@ -50,9 +50,12 @@ public:
~NetscapePluginStream();
uint64_t streamID() const { return m_streamID; }
+ const NPStream* npStream() const { return &m_npStream; }
void sendJavaScriptStream(const WebCore::String& requestURLString, const WebCore::String& result);
+ NPError destroy(NPReason);
+
private:
NetscapePluginStream(PassRefPtr<NetscapePlugin>, uint64_t streamID, bool sendNotification, void* notificationData);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list