зеркало из https://github.com/mozilla/gecko-dev.git
Bug 820905 - backout ea1643fd4285 a=bajaj
This commit is contained in:
Родитель
6704076283
Коммит
f90db2bfdb
|
@ -1389,6 +1389,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)
|
||||
{
|
||||
|
@ -1396,7 +1418,11 @@ PluginTimerCallback(nsITimer *aTimer, void *aClosure)
|
|||
NPP npp = t->npp;
|
||||
uint32_t id = t->id;
|
||||
|
||||
// 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.
|
||||
|
@ -1433,6 +1459,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
|
||||
|
@ -1470,6 +1497,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
|
||||
|
|
Загрузка…
Ссылка в новой задаче