mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-15 06:20:41 +00:00
Bug 820905 - backout ea1643fd4285
--HG-- extra : rebase_source : 50ddda21ab6942b6397366b9823b36df257b9482
This commit is contained in:
parent
4e8b660625
commit
650e1ba147
@ -1384,6 +1384,28 @@ nsNPAPIPluginInstance::PrivateModeStateChanged(bool enabled)
|
||||
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
class DelayUnscheduleEvent : public nsRunnable {
|
||||
public:
|
||||
nsRefPtr<nsNPAPIPluginInstance> mInstance;
|
||||
uint32_t mTimerID;
|
||||
DelayUnscheduleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aTimerId)
|
||||
: mInstance(aInstance)
|
||||
, mTimerID(aTimerId)
|
||||
{}
|
||||
|
||||
~DelayUnscheduleEvent() {}
|
||||
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
DelayUnscheduleEvent::Run()
|
||||
{
|
||||
mInstance->UnscheduleTimer(mTimerID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
PluginTimerCallback(nsITimer *aTimer, void *aClosure)
|
||||
{
|
||||
@ -1394,7 +1416,11 @@ PluginTimerCallback(nsITimer *aTimer, void *aClosure)
|
||||
PLUGIN_LOG(PLUGIN_LOG_NOISY, ("nsNPAPIPluginInstance running plugin timer callback this=%p\n", npp->ndata));
|
||||
|
||||
MAIN_THREAD_JNI_REF_GUARD;
|
||||
// Some plugins (Flash on Android) calls unscheduletimer
|
||||
// from this callback.
|
||||
t->inCallback = true;
|
||||
(*(t->callback))(npp, id);
|
||||
t->inCallback = false;
|
||||
|
||||
// Make sure we still have an instance and the timer is still alive
|
||||
// after the callback.
|
||||
@ -1431,6 +1457,7 @@ nsNPAPIPluginInstance::ScheduleTimer(uint32_t interval, NPBool repeat, void (*ti
|
||||
|
||||
nsNPAPITimer *newTimer = new nsNPAPITimer();
|
||||
|
||||
newTimer->inCallback = false;
|
||||
newTimer->npp = &mNPP;
|
||||
|
||||
// generate ID that is unique to this instance
|
||||
@ -1468,6 +1495,12 @@ nsNPAPIPluginInstance::UnscheduleTimer(uint32_t timerID)
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
if (t->inCallback) {
|
||||
nsCOMPtr<nsIRunnable> e = new DelayUnscheduleEvent(this, timerID);
|
||||
NS_DispatchToCurrentThread(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// cancel the timer
|
||||
t->timer->Cancel();
|
||||
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
uint32_t id;
|
||||
nsCOMPtr<nsITimer> timer;
|
||||
void (*callback)(NPP npp, uint32_t timerID);
|
||||
bool inCallback;
|
||||
};
|
||||
|
||||
class nsNPAPIPluginInstance : public nsISupports
|
||||
|
Loading…
x
Reference in New Issue
Block a user