Commit 369e6479 authored by andersca@apple.com's avatar andersca@apple.com
Browse files

WebCore:

2009-03-18  Anders Carlsson  <andersca@apple.com>

        Reviewed by Darin Adler.

        <rdar://problem/6504776> 
        CrashTracer: [USER] 188 crashes in Safari at com.apple.WebCore • WTF::HashTableIterator<WTF::RefPtr<WebCore::ResourceLoader>, ...

        Return early in case calling the client ends up spinning the run loop and completing/cancelling the load.
        
        * loader/NetscapePlugInStreamLoader.cpp:
        (WebCore::NetscapePlugInStreamLoader::didCancel):

WebKit/mac:

2009-03-18  Anders Carlsson  <andersca@apple.com>

        Reviewed by Darin Adler.

        <rdar://problem/6504776> 
        CrashTracer: [USER] 188 crashes in Safari at com.apple.WebCore • WTF::HashTableIterator<WTF::RefPtr<WebCore::ResourceLoader>, ...
        
        If the m_pluginView member was zeroed out as a result of making a call into the plug-in, the pluginFunctionCallDepth would be off
        causing the plug-in never to be stopped. Simplify the code by using a RAII object.

        * Plugins/WebBaseNetscapePluginStream.mm:
        (PluginStopDeferrer::PluginStopDeferrer):
        (PluginStopDeferrer::~PluginStopDeferrer):
        (WebNetscapePluginStream::startStream):
        (WebNetscapePluginStream::wantsAllStreams):
        (WebNetscapePluginStream::destroyStream):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9b19d812
2009-03-18 Anders Carlsson <andersca@apple.com>
Reviewed by Darin Adler.
<rdar://problem/6504776>
CrashTracer: [USER] 188 crashes in Safari at com.apple.WebCore • WTF::HashTableIterator<WTF::RefPtr<WebCore::ResourceLoader>, ...
Return early in case calling the client ends up spinning the run loop and completing/cancelling the load.
* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::didCancel):
2009-03-18 David Levin <levin@chromium.org>
 
Reviewed by Dimitri Glazkov.
......@@ -119,6 +119,11 @@ void NetscapePlugInStreamLoader::didCancel(const ResourceError& error)
m_client->didFail(this, error);
// If calling didFail spins the run loop the stream loader can reach the terminal state.
// If that's the case we just return early.
if (reachedTerminalState())
return;
// We need to remove the stream loader after the call to didFail, since didFail can
// spawn a new run loop and if the loader has been removed it won't be deferred when
// the document loader is asked to defer loading.
......
2009-03-18 Anders Carlsson <andersca@apple.com>
Reviewed by Darin Adler.
<rdar://problem/6504776>
CrashTracer: [USER] 188 crashes in Safari at com.apple.WebCore • WTF::HashTableIterator<WTF::RefPtr<WebCore::ResourceLoader>, ...
If the m_pluginView member was zeroed out as a result of making a call into the plug-in, the pluginFunctionCallDepth would be off
causing the plug-in never to be stopped. Simplify the code by using a RAII object.
* Plugins/WebBaseNetscapePluginStream.mm:
(PluginStopDeferrer::PluginStopDeferrer):
(PluginStopDeferrer::~PluginStopDeferrer):
(WebNetscapePluginStream::startStream):
(WebNetscapePluginStream::wantsAllStreams):
(WebNetscapePluginStream::destroyStream):
2009-03-17 Darin Adler <darin@apple.com>
 
Reviewed by Adele Peterson.
......
......@@ -54,6 +54,26 @@ using namespace WebCore;
static NSString *CarbonPathFromPOSIXPath(NSString *posixPath);
class PluginStopDeferrer {
public:
PluginStopDeferrer(WebNetscapePluginView* pluginView)
: m_pluginView(pluginView)
{
ASSERT(m_pluginView);
[m_pluginView.get() willCallPlugInFunction];
}
~PluginStopDeferrer()
{
ASSERT(m_pluginView);
[m_pluginView.get() didCallPlugInFunction];
}
private:
RetainPtr<WebNetscapePluginView> m_pluginView;
};
typedef HashMap<NPStream*, NPP> StreamMap;
static StreamMap& streams()
{
......@@ -218,9 +238,12 @@ void WebNetscapePluginStream::startStream(NSURL *url, long long expectedContentL
// FIXME: Need a way to check if stream is seekable
[m_pluginView.get() willCallPlugInFunction];
NPError npErr = m_pluginFuncs->newstream(m_plugin, (char *)[m_mimeType.get() UTF8String], &m_stream, NO, &m_transferMode);
[m_pluginView.get() didCallPlugInFunction];
NPError npErr;
{
PluginStopDeferrer deferrer(m_pluginView.get());
npErr = m_pluginFuncs->newstream(m_plugin, (char *)[m_mimeType.get() UTF8String], &m_stream, NO, &m_transferMode);
}
LOG(Plugins, "NPP_NewStream URL=%@ MIME=%@ error=%d", m_responseURL.get(), m_mimeType.get(), npErr);
if (npErr != NPERR_NO_ERROR) {
......@@ -340,12 +363,11 @@ bool WebNetscapePluginStream::wantsAllStreams() const
void *value = 0;
NPError error;
[m_pluginView.get() willCallPlugInFunction];
{
PluginStopDeferrer deferrer(m_pluginView.get());
JSC::JSLock::DropAllLocks dropAllLocks(false);
error = m_pluginFuncs->getvalue(m_plugin, NPPVpluginWantsAllNetworkStreams, &value);
}
[m_pluginView.get() didCallPlugInFunction];
if (error != NPERR_NO_ERROR)
return false;
......@@ -370,9 +392,9 @@ void WebNetscapePluginStream::destroyStream()
ASSERT(m_path);
NSString *carbonPath = CarbonPathFromPOSIXPath(m_path.get());
ASSERT(carbonPath != NULL);
[m_pluginView.get() willCallPlugInFunction];
PluginStopDeferrer deferrer(m_pluginView.get());
m_pluginFuncs->asfile(m_plugin, &m_stream, [carbonPath fileSystemRepresentation]);
[m_pluginView.get() didCallPlugInFunction];
LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", m_responseURL.get(), carbonPath);
}
......@@ -395,12 +417,11 @@ void WebNetscapePluginStream::destroyStream()
}
if (m_newStreamSuccessful) {
[m_pluginView.get() willCallPlugInFunction];
PluginStopDeferrer deferrer(m_pluginView.get());
#if !LOG_DISABLED
NPError npErr =
#endif
m_pluginFuncs->destroystream(m_plugin, &m_stream, m_reason);
[m_pluginView.get() didCallPlugInFunction];
LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", m_responseURL.get(), npErr);
}
......@@ -416,9 +437,8 @@ void WebNetscapePluginStream::destroyStream()
if (m_sendNotification) {
// NPP_URLNotify expects the request URL, not the response URL.
[m_pluginView.get() willCallPlugInFunction];
PluginStopDeferrer deferrer(m_pluginView.get());
m_pluginFuncs->urlnotify(m_plugin, [m_requestURL.get() _web_URLCString], m_reason, m_notifyData);
[m_pluginView.get() didCallPlugInFunction];
LOG(Plugins, "NPP_URLNotify requestURL=%@ reason=%d", m_requestURL.get(), m_reason);
}
......@@ -489,9 +509,8 @@ void WebNetscapePluginStream::deliverData()
int32 totalBytesDelivered = 0;
while (totalBytesDelivered < totalBytes) {
[m_pluginView.get() willCallPlugInFunction];
PluginStopDeferrer deferrer(m_pluginView.get());
int32 deliveryBytes = m_pluginFuncs->writeready(m_plugin, &m_stream);
[m_pluginView.get() didCallPlugInFunction];
LOG(Plugins, "NPP_WriteReady responseURL=%@ bytes=%d", m_responseURL.get(), deliveryBytes);
if (m_isTerminated)
......@@ -505,9 +524,8 @@ void WebNetscapePluginStream::deliverData()
} else {
deliveryBytes = MIN(deliveryBytes, totalBytes - totalBytesDelivered);
NSData *subdata = [m_deliveryData.get() subdataWithRange:NSMakeRange(totalBytesDelivered, deliveryBytes)];
[m_pluginView.get() willCallPlugInFunction];
PluginStopDeferrer deferrer(m_pluginView.get());
deliveryBytes = m_pluginFuncs->write(m_plugin, &m_stream, m_offset, [subdata length], (void *)[subdata bytes]);
[m_pluginView.get() didCallPlugInFunction];
if (deliveryBytes < 0) {
// Netscape documentation says that a negative result from NPP_Write means cancel the load.
cancelLoadAndDestroyStreamWithError(pluginCancelledConnectionError());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment