diff --git a/dom/plugins/ipc/PluginAsyncSurrogate.cpp b/dom/plugins/ipc/PluginAsyncSurrogate.cpp index d860de85761f..dbf293a9a921 100644 --- a/dom/plugins/ipc/PluginAsyncSurrogate.cpp +++ b/dom/plugins/ipc/PluginAsyncSurrogate.cpp @@ -172,11 +172,11 @@ PluginAsyncSurrogate::NP_GetEntryPoints(NPPluginFuncs* aFuncs) aFuncs->setwindow = &NPP_SetWindow; aFuncs->writeready = &NPP_WriteReady; aFuncs->event = &NPP_HandleEvent; + aFuncs->destroystream = &NPP_DestroyStream; // We need to set these so that content code doesn't make assumptions // about these operations not being supported aFuncs->write = &PluginModuleParent::NPP_Write; aFuncs->asfile = &PluginModuleParent::NPP_StreamAsFile; - aFuncs->destroystream = &PluginModuleParent::NPP_DestroyStream; } NPError @@ -267,6 +267,19 @@ PluginAsyncSurrogate::NPP_WriteReady(NPStream* aStream) return 0; } +NPError +PluginAsyncSurrogate::NPP_DestroyStream(NPStream* aStream, NPReason aReason) +{ + for (uint32_t idx = 0, len = mPendingNewStreamCalls.Length(); idx < len; ++idx) { + PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[idx]; + if (curPendingCall.mStream == aStream) { + mPendingNewStreamCalls.RemoveElementAt(idx); + break; + } + } + return NPERR_NO_ERROR; +} + /* static */ NPError PluginAsyncSurrogate::NPP_Destroy(NPP aInstance, NPSavedData** aSave) { @@ -350,6 +363,16 @@ PluginAsyncSurrogate::NPP_WriteReady(NPP aInstance, NPStream* aStream) return surrogate->NPP_WriteReady(aStream); } +/* static */ NPError +PluginAsyncSurrogate::NPP_DestroyStream(NPP aInstance, + NPStream* aStream, + NPReason aReason) +{ + PluginAsyncSurrogate* surrogate = Cast(aInstance); + MOZ_ASSERT(surrogate); + return surrogate->NPP_DestroyStream(aStream, aReason); +} + PluginAsyncSurrogate::PendingNewStreamCall::PendingNewStreamCall( NPMIMEType aType, NPStream* aStream, NPBool aSeekable) : mType(NullableString(aType)) @@ -403,7 +426,7 @@ PluginAsyncSurrogate::OnInstanceCreated(PluginInstanceParent* aInstance) &streamType); if (curError != NPERR_NO_ERROR) { // If we failed here then the send failed and we need to clean up - parent::_destroystream(mInstance, curPendingCall.mStream, NPRES_DONE); + DestroyAsyncStream(curPendingCall.mStream); } } mPendingNewStreamCalls.Clear(); diff --git a/dom/plugins/ipc/PluginAsyncSurrogate.h b/dom/plugins/ipc/PluginAsyncSurrogate.h index 8000ba0b5843..b216b8f465b8 100644 --- a/dom/plugins/ipc/PluginAsyncSurrogate.h +++ b/dom/plugins/ipc/PluginAsyncSurrogate.h @@ -42,6 +42,7 @@ public: void NPP_Print(NPPrint* aPrintInfo); int16_t NPP_HandleEvent(void* aEvent); int32_t NPP_WriteReady(NPStream* aStream); + NPError NPP_DestroyStream(NPStream* aStream, NPReason aReason); void OnInstanceCreated(PluginInstanceParent* aInstance); static bool Create(PluginModuleParent* aParent, NPMIMEType aPluginType, NPP aInstance, uint16_t aMode, int16_t aArgc, @@ -98,6 +99,8 @@ private: static void NPP_Print(NPP aInstance, NPPrint* aPrintInfo); static int16_t NPP_HandleEvent(NPP aInstance, void* aEvent); static int32_t NPP_WriteReady(NPP aInstance, NPStream* aStream); + static NPError NPP_DestroyStream(NPP aInstance, NPStream* aStream, + NPReason aReason); static NPObject* ScriptableAllocate(NPP aInstance, NPClass* aClass); static void ScriptableInvalidate(NPObject* aObject); diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index f3028b1bdc44..4e146640c246 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -1436,11 +1436,7 @@ PluginModuleParent::NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) { - PluginInstanceParent* i = PluginInstanceParent::Cast(instance); - if (!i) - return NPERR_GENERIC_ERROR; - - return i->NPP_DestroyStream(stream, reason); + RESOLVE_AND_CALL(instance, NPP_DestroyStream(stream, reason)); } int32_t