Bug 1136930: Hook PluginAsyncSurrogate into NPP_DestroyStream; r=jimm

--HG--
extra : rebase_source : 379d6a8bee1d6f608872e17aa10606b24dbde764
This commit is contained in:
Aaron Klotz 2015-02-25 16:25:33 -07:00
Родитель d41d4d70dc
Коммит 8dbfc84a1c
3 изменённых файлов: 29 добавлений и 7 удалений

Просмотреть файл

@ -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();

Просмотреть файл

@ -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);

Просмотреть файл

@ -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