--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -114,19 +114,19 @@ using namespace mozilla::plugins::parent
// We should make this const...
static NPNetscapeFuncs sBrowserFuncs = {
sizeof(sBrowserFuncs),
(NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR,
_geturl,
_posturl,
_requestread,
- _newstream,
- _write,
- _destroystream,
+ nullptr,
+ nullptr,
+ nullptr,
_status,
_useragent,
_memalloc,
_memfree,
_memflush,
_reloadplugins,
_getJavaEnv,
_getJavaPeer,
@@ -352,43 +352,16 @@ nsNPAPIPlugin::Shutdown()
("NPP Shutdown to be called: this=%p\n", this));
NPError shutdownError;
mLibrary->NP_Shutdown(&shutdownError);
return NS_OK;
}
-nsresult
-nsNPAPIPlugin::RetainStream(NPStream *pstream, nsISupports **aRetainedPeer)
-{
- if (!aRetainedPeer)
- return NS_ERROR_NULL_POINTER;
-
- *aRetainedPeer = nullptr;
-
- if (!pstream || !pstream->ndata)
- return NS_ERROR_NULL_POINTER;
-
- nsNPAPIStreamWrapper* streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
- nsNPAPIPluginStreamListener* listener = streamWrapper->GetStreamListener();
- if (!listener) {
- return NS_ERROR_NULL_POINTER;
- }
-
- nsIStreamListener* streamListener = listener->GetStreamListenerPeer();
- if (!streamListener) {
- return NS_ERROR_NULL_POINTER;
- }
-
- *aRetainedPeer = streamListener;
- NS_ADDREF(*aRetainedPeer);
- return NS_OK;
-}
-
// Create a new NPP GET or POST (given in the type argument) url
// stream that may have a notify callback
NPError
MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target,
eNPPStreamTypeInternal type,
bool bDoNotify = false,
void *notifyData = nullptr, uint32_t len = 0,
const char *buf = nullptr)
@@ -771,136 +744,16 @@ NPError
PluginDestructionGuard guard(npp);
return MakeNewNPAPIStreamInternal(npp, relativeURL, target,
eNPPStreamTypeInternal_Post, false, nullptr,
len, buf);
}
-NPError
-_newstream(NPP npp, NPMIMEType type, const char* target, NPStream* *result)
-{
- if (!NS_IsMainThread()) {
- NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_newstream called from the wrong thread\n"));
- return NPERR_INVALID_PARAM;
- }
- NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
- ("NPN_NewStream: npp=%p, type=%s, target=%s\n", (void*)npp,
- (const char *)type, target));
-
- NPError err = NPERR_INVALID_INSTANCE_ERROR;
- if (npp && npp->ndata) {
- nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance*)npp->ndata;
-
- PluginDestructionGuard guard(inst);
-
- nsCOMPtr<nsIOutputStream> stream;
- if (NS_SUCCEEDED(inst->NewStreamFromPlugin((const char*) type, target,
- getter_AddRefs(stream)))) {
- auto* wrapper = new nsNPAPIStreamWrapper(stream, nullptr);
- if (wrapper) {
- (*result) = &wrapper->mNPStream;
- err = NPERR_NO_ERROR;
- } else {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- }
- } else {
- err = NPERR_GENERIC_ERROR;
- }
- }
- return err;
-}
-
-int32_t
-_write(NPP npp, NPStream *pstream, int32_t len, void *buffer)
-{
- if (!NS_IsMainThread()) {
- NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_write called from the wrong thread\n"));
- return 0;
- }
- NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
- ("NPN_Write: npp=%p, url=%s, len=%d, buffer=%s\n", (void*)npp,
- pstream->url, len, (char*)buffer));
-
- // negative return indicates failure to the plugin
- if (!npp)
- return -1;
-
- PluginDestructionGuard guard(npp);
-
- nsNPAPIStreamWrapper* wrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
- if (!wrapper) {
- return -1;
- }
-
- nsIOutputStream* stream = wrapper->GetOutputStream();
- if (!stream) {
- return -1;
- }
-
- uint32_t count = 0;
- nsresult rv = stream->Write((char *)buffer, len, &count);
-
- if (NS_FAILED(rv)) {
- return -1;
- }
-
- return (int32_t)count;
-}
-
-NPError
-_destroystream(NPP npp, NPStream *pstream, NPError reason)
-{
- if (!NS_IsMainThread()) {
- NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_destroystream called from the wrong thread\n"));
- return NPERR_INVALID_PARAM;
- }
- NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
- ("NPN_DestroyStream: npp=%p, url=%s, reason=%d\n", (void*)npp,
- pstream->url, (int)reason));
-
- if (!npp)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- PluginDestructionGuard guard(npp);
-
- nsNPAPIStreamWrapper *streamWrapper = static_cast<nsNPAPIStreamWrapper*>(pstream->ndata);
- if (!streamWrapper) {
- return NPERR_INVALID_PARAM;
- }
-
- nsNPAPIPluginStreamListener *listener = streamWrapper->GetStreamListener();
- if (listener) {
- // This type of stream is going from the browser to the plugin. It's either the
- // initial src/data stream or another stream resulting from NPN_GetURL* or
- // NPN_PostURL*.
- //
- // Calling OnStopBinding on the listener may cause it to be deleted due to the
- // releasing of its last references.
- listener->OnStopBinding(nullptr, NS_BINDING_ABORTED);
- } else {
- // This type of stream (NPStream) was created via NPN_NewStream. The plugin holds
- // the reference until it is to be deleted here. Deleting the wrapper will
- // release the wrapped nsIOutputStream.
- //
- // The NPStream the plugin references should always be a sub-object of its own
- // 'ndata', which is our nsNPAPIStramWrapper. See bug 548441.
- NS_ASSERTION((char*)streamWrapper <= (char*)pstream &&
- ((char*)pstream) + sizeof(*pstream)
- <= ((char*)streamWrapper) + sizeof(*streamWrapper),
- "pstream is not a subobject of wrapper");
- delete streamWrapper;
- }
-
- // 'listener' and/or 'streamWrapper' may be invalid (deleted) at this point. Don't
- // touch them again!
-
- return NPERR_NO_ERROR;
-}
void
_status(NPP npp, const char *message)
{
// NPN_Status is no longer supported.
}
void
--- a/dom/plugins/base/nsNPAPIPlugin.h
+++ b/dom/plugins/base/nsNPAPIPlugin.h
@@ -55,17 +55,16 @@ public:
// minidump was written.
void PluginCrashed(const nsAString& pluginDumpID,
const nsAString& browserDumpID);
static bool RunPluginOOP(const nsPluginTag *aPluginTag);
nsresult Shutdown();
- static nsresult RetainStream(NPStream *pstream, nsISupports **aRetainedPeer);
private:
~nsNPAPIPlugin();
NPPluginFuncs mPluginFuncs;
PluginLibrary* mLibrary;
};
@@ -265,26 +264,16 @@ NPError
NPError
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32_t len, const char *buf, NPBool file, void* notifyData);
NPError
_posturl(NPP npp, const char* relativeURL, const char *target, uint32_t len,
const char *buf, NPBool file);
-
-NPError
-_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
-
-int32_t
-_write(NPP npp, NPStream *pstream, int32_t len, void *buffer);
-
-NPError
-_destroystream(NPP npp, NPStream *pstream, NPError reason);
-
void
_status(NPP npp, const char *message);
void
_memfree (void *ptr);
uint32_t
_memflush(uint32_t size);
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -508,24 +508,16 @@ nsresult nsNPAPIPluginInstance::SetWindo
("NPP SetWindow called: this=%p, [x=%d,y=%d,w=%d,h=%d], clip[t=%d,b=%d,l=%d,r=%d], return=%d\n",
this, window->x, window->y, window->width, window->height,
window->clipRect.top, window->clipRect.bottom, window->clipRect.left, window->clipRect.right, error));
}
return NS_OK;
}
nsresult
-nsNPAPIPluginInstance::NewStreamFromPlugin(const char* type, const char* target,
- nsIOutputStream* *result)
-{
- nsPluginStreamToFile* stream = new nsPluginStreamToFile(target, mOwner);
- return stream->QueryInterface(kIOutputStreamIID, (void**)result);
-}
-
-nsresult
nsNPAPIPluginInstance::NewStreamListener(const char* aURL, void* notifyData,
nsNPAPIPluginStreamListener** listener)
{
RefPtr<nsNPAPIPluginStreamListener> sl = new nsNPAPIPluginStreamListener(this, notifyData, aURL);
mStreamListeners.AppendElement(sl);
sl.forget(listener);
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -2570,32 +2570,16 @@ PluginInstanceChild::AllocPBrowserStream
bool
PluginInstanceChild::DeallocPBrowserStreamChild(PBrowserStreamChild* stream)
{
AssertPluginThread();
delete stream;
return true;
}
-PPluginStreamChild*
-PluginInstanceChild::AllocPPluginStreamChild(const nsCString& mimeType,
- const nsCString& target,
- NPError* result)
-{
- MOZ_CRASH("not callable");
- return nullptr;
-}
-
-bool
-PluginInstanceChild::DeallocPPluginStreamChild(PPluginStreamChild* stream)
-{
- AssertPluginThread();
- delete stream;
- return true;
-}
PStreamNotifyChild*
PluginInstanceChild::AllocPStreamNotifyChild(const nsCString& url,
const nsCString& target,
const bool& post,
const nsCString& buffer,
const bool& file,
NPError* result)
@@ -2701,38 +2685,16 @@ PluginInstanceChild::GetActorForNPObject
NS_ERROR("Failed to send constructor message!");
return nullptr;
}
actor->InitializeLocal(aObject);
return actor;
}
-NPError
-PluginInstanceChild::NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
- NPStream** aStream)
-{
- AssertPluginThread();
- AutoStackHelper guard(this);
-
- auto* ps = new PluginStreamChild();
-
- NPError result;
- CallPPluginStreamConstructor(ps, nsDependentCString(aMIMEType),
- NullableString(aWindow), &result);
- if (NPERR_NO_ERROR != result) {
- *aStream = nullptr;
- PPluginStreamChild::Call__delete__(ps, NPERR_GENERIC_ERROR, true);
- return result;
- }
-
- *aStream = &ps->mStream;
- return NPERR_NO_ERROR;
-}
-
void
PluginInstanceChild::NPN_URLRedirectResponse(void* notifyData, NPBool allow)
{
if (!notifyData) {
return;
}
InfallibleTArray<PStreamNotifyChild*> notifyStreams;
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -176,24 +176,16 @@ protected:
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyChild* notifyData,
const nsCString& headers) override;
virtual bool
DeallocPBrowserStreamChild(PBrowserStreamChild* stream) override;
- virtual PPluginStreamChild*
- AllocPPluginStreamChild(const nsCString& mimeType,
- const nsCString& target,
- NPError* result) override;
-
- virtual bool
- DeallocPPluginStreamChild(PPluginStreamChild* stream) override;
-
virtual PStreamNotifyChild*
AllocPStreamNotifyChild(const nsCString& url, const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result) override;
virtual bool
DeallocPStreamNotifyChild(PStreamNotifyChild* notifyData) override;
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -240,30 +240,16 @@ PluginInstanceParent::AllocPBrowserStrea
bool
PluginInstanceParent::DeallocPBrowserStreamParent(PBrowserStreamParent* stream)
{
delete stream;
return true;
}
-PPluginStreamParent*
-PluginInstanceParent::AllocPPluginStreamParent(const nsCString& mimeType,
- const nsCString& target,
- NPError* result)
-{
- return new PluginStreamParent(this, mimeType, target, result);
-}
-
-bool
-PluginInstanceParent::DeallocPPluginStreamParent(PPluginStreamParent* stream)
-{
- delete stream;
- return true;
-}
mozilla::ipc::IPCResult
PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* value,
NPError* result)
{
#ifdef XP_WIN
HWND id;
#elif defined(MOZ_X11)
@@ -1814,25 +1800,17 @@ PluginInstanceParent::NPP_DestroyStream(
BrowserStreamParent* sp =
static_cast<BrowserStreamParent*>(s);
if (sp->mNPP != this)
MOZ_CRASH("Mismatched plugin data");
sp->NPP_DestroyStream(reason);
return NPERR_NO_ERROR;
}
- else {
- PluginStreamParent* sp =
- static_cast<PluginStreamParent*>(s);
- if (sp->mInstance != this)
- MOZ_CRASH("Mismatched plugin data");
-
- return PPluginStreamParent::Call__delete__(sp, reason, false) ?
- NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
- }
+
}
void
PluginInstanceParent::NPP_Print(NPPrint* platformPrint)
{
// TODO: implement me
NS_ERROR("Not implemented");
}
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -814,25 +814,16 @@ static NPError
static NPError
_posturlnotify(NPP aNPP, const char* relativeURL, const char *target,
uint32_t len, const char *buf, NPBool file, void* notifyData);
static NPError
_posturl(NPP aNPP, const char* relativeURL, const char *target, uint32_t len,
const char *buf, NPBool file);
-static NPError
-_newstream(NPP aNPP, NPMIMEType type, const char* window, NPStream** pstream);
-
-static int32_t
-_write(NPP aNPP, NPStream *pstream, int32_t len, void *buffer);
-
-static NPError
-_destroystream(NPP aNPP, NPStream *pstream, NPError reason);
-
static void
_status(NPP aNPP, const char *message);
static void
_memfree (void *ptr);
static uint32_t
_memflush(uint32_t size);
@@ -957,19 +948,19 @@ static void
} /* namespace mozilla */
const NPNetscapeFuncs PluginModuleChild::sBrowserFuncs = {
sizeof(sBrowserFuncs),
(NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR,
mozilla::plugins::child::_geturl,
mozilla::plugins::child::_posturl,
mozilla::plugins::child::_requestread,
- mozilla::plugins::child::_newstream,
- mozilla::plugins::child::_write,
- mozilla::plugins::child::_destroystream,
+ nullptr,
+ nullptr,
+ nullptr,
mozilla::plugins::child::_status,
mozilla::plugins::child::_useragent,
mozilla::plugins::child::_memalloc,
mozilla::plugins::child::_memfree,
mozilla::plugins::child::_memflush,
mozilla::plugins::child::_reloadplugins,
mozilla::plugins::child::_getjavaenv,
mozilla::plugins::child::_getjavapeer,
@@ -1210,65 +1201,16 @@ NPError
// FIXME what should happen when |aBuffer| is null?
InstCast(aNPP)->CallNPN_PostURL(NullableString(aRelativeURL),
NullableString(aTarget),
nsDependentCString(aBuffer, aLength),
aIsFile, &err);
return err;
}
-NPError
-_newstream(NPP aNPP,
- NPMIMEType aMIMEType,
- const char* aWindow,
- NPStream** aStream)
-{
- PLUGIN_LOG_DEBUG_FUNCTION;
- ENSURE_PLUGIN_THREAD(NPERR_INVALID_PARAM);
- return InstCast(aNPP)->NPN_NewStream(aMIMEType, aWindow, aStream);
-}
-
-int32_t
-_write(NPP aNPP,
- NPStream* aStream,
- int32_t aLength,
- void* aBuffer)
-{
- PLUGIN_LOG_DEBUG_FUNCTION;
- ENSURE_PLUGIN_THREAD(0);
-
- PluginStreamChild* ps =
- static_cast<PluginStreamChild*>(static_cast<AStream*>(aStream->ndata));
- ps->EnsureCorrectInstance(InstCast(aNPP));
- ps->EnsureCorrectStream(aStream);
- return ps->NPN_Write(aLength, aBuffer);
-}
-
-NPError
-_destroystream(NPP aNPP,
- NPStream* aStream,
- NPError aReason)
-{
- PLUGIN_LOG_DEBUG_FUNCTION;
- ENSURE_PLUGIN_THREAD(NPERR_INVALID_PARAM);
-
- PluginInstanceChild* p = InstCast(aNPP);
- AStream* s = static_cast<AStream*>(aStream->ndata);
- if (s->IsBrowserStream()) {
- BrowserStreamChild* bs = static_cast<BrowserStreamChild*>(s);
- bs->EnsureCorrectInstance(p);
- bs->NPN_DestroyStream(aReason);
- }
- else {
- PluginStreamChild* ps = static_cast<PluginStreamChild*>(s);
- ps->EnsureCorrectInstance(p);
- PPluginStreamChild::Call__delete__(ps, aReason, false);
- }
- return NPERR_NO_ERROR;
-}
void
_status(NPP aNPP,
const char* aMessage)
{
// NPN_Status is no longer supported.
}
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -473,50 +473,17 @@ static void sendBufferToFrame(NPP instan
}
else if (bufsize > 0) {
outbuf.append(buf);
}
else {
outbuf.append("Error: no data in buffer");
}
- if (instanceData->npnNewStream &&
- instanceData->err.str().length() == 0) {
- char typeHTML[] = "text/html";
- NPStream* stream;
- printf("calling NPN_NewStream...");
- NPError err = NPN_NewStream(instance, typeHTML,
- instanceData->frame.c_str(), &stream);
- printf("return value %d\n", err);
- if (err != NPERR_NO_ERROR) {
- instanceData->err << "NPN_NewStream returned " << err;
- return;
- }
-
- int32_t bytesToWrite = outbuf.length();
- int32_t bytesWritten = 0;
- while ((bytesToWrite - bytesWritten) > 0) {
- int32_t numBytes = (bytesToWrite - bytesWritten) <
- instanceData->streamChunkSize ?
- bytesToWrite - bytesWritten : instanceData->streamChunkSize;
- int32_t written = NPN_Write(instance, stream,
- numBytes, (void*)(outbuf.c_str() + bytesWritten));
- if (written <= 0) {
- instanceData->err << "NPN_Write returned " << written;
- break;
- }
- bytesWritten += numBytes;
- printf("%d bytes written, total %d\n", written, bytesWritten);
- }
- err = NPN_DestroyStream(instance, stream, NPRES_DONE);
- if (err != NPERR_NO_ERROR) {
- instanceData->err << "NPN_DestroyStream returned " << err;
- }
- }
- else {
+
// Convert CRLF to LF, and escape most other non-alphanumeric chars.
for (size_t i = 0; i < outbuf.length(); i++) {
if (outbuf[i] == '\n') {
outbuf.replace(i, 1, "%0a");
i += 2;
}
else if (outbuf[i] == '\r') {
outbuf.replace(i, 1, "");
@@ -527,17 +494,17 @@ static void sendBufferToFrame(NPP instan
if (!((ascii >= ',' && ascii <= ';') ||
(ascii >= 'A' && ascii <= 'Z') ||
(ascii >= 'a' && ascii <= 'z'))) {
char hex[8];
sprintf(hex, "%%%x", ascii);
outbuf.replace(i, 1, hex);
i += 2;
}
- }
+ // }
}
NPError err = NPN_GetURL(instance, outbuf.c_str(),
instanceData->frame.c_str());
if (err != NPERR_NO_ERROR) {
instanceData->err << "NPN_GetURL returned " << err;
}
}
@@ -1419,17 +1386,16 @@ NPP_Write(NPP instance, NPStream* stream
return len;
}
if (instanceData->closeStream) {
instanceData->closeStream = false;
if (instanceData->testrange != nullptr) {
NPN_RequestRead(stream, instanceData->testrange);
}
- NPN_DestroyStream(instance, stream, NPRES_USER_BREAK);
}
else if (instanceData->streamMode == NP_SEEK &&
stream->end != 0 &&
stream->end == ((uint32_t)instanceData->streamBufSize + len)) {
// If the complete stream has been written, and we're doing a seek test,
// then call NPN_RequestRead.
// prevent recursion
instanceData->streamMode = NP_NORMAL;
@@ -1904,39 +1870,17 @@ NPN_PostURLNotify(NPP instance, const ch
NPError
NPN_PostURL(NPP instance, const char *url,
const char *target, uint32_t len,
const char *buf, NPBool file)
{
return sBrowserFuncs->posturl(instance, url, target, len, buf, file);
}
-NPError
-NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
-{
- return sBrowserFuncs->destroystream(instance, stream, reason);
-}
-
-NPError
-NPN_NewStream(NPP instance,
- NPMIMEType type,
- const char* target,
- NPStream** stream)
-{
- return sBrowserFuncs->newstream(instance, type, target, stream);
-}
-
-int32_t
-NPN_Write(NPP instance,
- NPStream* stream,
- int32_t len,
- void* buf)
-{
- return sBrowserFuncs->write(instance, stream, len, buf);
-}
+
bool
NPN_Enumerate(NPP instance,
NPObject *npobj,
NPIdentifier **identifiers,
uint32_t *identifierCount)
{
return sBrowserFuncs->enumerate(instance, npobj, identifiers,