More plugin crash fixes: failure from NPP_Write doesn't actually destroy the stream, it just tells the browser to destroy the stream. NPP_NewStream resulting from NPN_GetURLNotify didn't have the notifyData field set correctly. Other minor logging and cleanup.

--HG--
extra : rebase_source : 932c0290a7c1779275266607d5e853d5c1994396
This commit is contained in:
Benjamin Smedberg 2009-09-23 19:00:23 -04:00
parent 29c6cc37ec
commit 7464979f8c
6 changed files with 18 additions and 10 deletions

View File

@ -37,6 +37,7 @@
#include "BrowserStreamChild.h"
#include "PluginInstanceChild.h"
#include "StreamNotifyChild.h"
namespace mozilla {
namespace plugins {
@ -45,6 +46,7 @@ BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,
@ -61,6 +63,9 @@ BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
mStream.url = mURL.get();
mStream.end = length;
mStream.lastmodified = lastmodified;
if (notifyData)
mStream.notifyData =
static_cast<const StreamNotifyChild*>(notifyData)->mClosure;
if (!mHeaders.IsEmpty())
mStream.headers = mHeaders.get();
@ -99,9 +104,6 @@ BrowserStreamChild::AnswerNPP_Write(const int32_t& offset,
*consumed = mInstance->mPluginIface->write(&mInstance->mData, &mStream,
offset, data.Length(),
const_cast<char*>(data.get()));
if (*consumed < 0)
mClosed = true;
return true;
}

View File

@ -45,6 +45,7 @@ namespace mozilla {
namespace plugins {
class PluginInstanceChild;
class PStreamNotifyChild;
class BrowserStreamChild : public PBrowserStreamChild, public AStream
{
@ -53,6 +54,7 @@ public:
const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
const PStreamNotifyChild* notifyData,
const nsCString& headers,
const nsCString& mimeType,
const bool& seekable,

View File

@ -11,9 +11,15 @@ BrowserStreamParent::BrowserStreamParent(PluginInstanceParent* npp,
: mNPP(npp)
, mStream(stream)
{
printf("BrowserStreamParent::BrowserStreamParent<%p>\n", (void*) this);
mStream->pdata = static_cast<AStream*>(this);
}
BrowserStreamParent::~BrowserStreamParent()
{
printf("BrowserStreamParent::~BrowserStreamParent<%p>\n", (void*) this);
}
bool
BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
NPError* result)
@ -64,12 +70,9 @@ BrowserStreamParent::Write(int32_t offset,
int32_t result;
if (!CallNPP_Write(offset,
nsCString(static_cast<char*>(buffer), len),
&result)) {
&result))
return -1;
}
if (result == -1)
mNPP->CallPBrowserStreamDestructor(this, NPRES_USER_BREAK, true);
return result;
}

View File

@ -54,7 +54,7 @@ class BrowserStreamParent : public PBrowserStreamParent, public AStream
public:
BrowserStreamParent(PluginInstanceParent* npp,
NPStream* stream);
virtual ~BrowserStreamParent() { }
virtual ~BrowserStreamParent();
NS_OVERRIDE virtual bool IsBrowserStream() { return true; }

View File

@ -462,8 +462,8 @@ PluginInstanceChild::AllocPBrowserStream(const nsCString& url,
NPError* rv,
uint16_t *stype)
{
return new BrowserStreamChild(this, url, length, lastmodified, headers,
mimeType, seekable, rv, stype);
return new BrowserStreamChild(this, url, length, lastmodified, notifyData,
headers, mimeType, seekable, rv, stype);
}
bool

View File

@ -47,6 +47,7 @@ namespace plugins {
class StreamNotifyChild : public PStreamNotifyChild
{
friend class PluginInstanceChild;
friend class BrowserStreamChild;
public:
StreamNotifyChild(const nsCString& aURL, void* aClosure)