Bug 751885 - Cancel pending events when plugin is destroyed on Android r=blassey
This commit is contained in:
@@ -69,6 +69,29 @@
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
class PluginEventRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PluginEventRunnable(nsNPAPIPluginInstance* instance, ANPEvent* event)
|
||||
: mInstance(instance), mEvent(*event), mCanceled(false) {}
|
||||
|
||||
virtual nsresult Run() {
|
||||
if (mCanceled)
|
||||
return NS_OK;
|
||||
|
||||
mInstance->HandleEvent(&mEvent, nsnull);
|
||||
mInstance->PopPostedEvent(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void Cancel() { mCanceled = true; }
|
||||
private:
|
||||
nsNPAPIPluginInstance* mInstance;
|
||||
ANPEvent mEvent;
|
||||
bool mCanceled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
@@ -215,6 +238,14 @@ nsresult nsNPAPIPluginInstance::Stop()
|
||||
}
|
||||
mRunning = DESTROYED;
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
for (PRUint32 i = 0; i < mPostedEvents.Length(); i++) {
|
||||
mPostedEvents[i]->Cancel();
|
||||
}
|
||||
|
||||
mPostedEvents.Clear();
|
||||
#endif
|
||||
|
||||
nsJSNPRuntime::OnPluginDestroy(&mNPP);
|
||||
|
||||
if (error != NPERR_NO_ERROR)
|
||||
@@ -792,6 +823,19 @@ void nsNPAPIPluginInstance::RequestJavaSurface()
|
||||
((SurfaceGetter*)mSurfaceGetter.get())->RequestSurface();
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::PostEvent(void* event)
|
||||
{
|
||||
PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event);
|
||||
mPostedEvents.AppendElement(nsRefPtr<PluginEventRunnable>(r));
|
||||
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
|
||||
void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
|
||||
{
|
||||
mPostedEvents.RemoveElement(r);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsresult nsNPAPIPluginInstance::GetDrawingModel(PRInt32* aModel)
|
||||
|
||||
Reference in New Issue
Block a user