Bug 816640: nrappkit timers need to be threadsafe r=ekr

This commit is contained in:
Randell Jesup 2012-12-14 18:16:29 -05:00
Родитель 5cbdd27144
Коммит ff2218cb04
1 изменённых файлов: 5 добавлений и 1 удалений

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

@ -43,7 +43,8 @@ protected:
void *cb_arg_; void *cb_arg_;
}; };
NS_IMPL_ISUPPORTS1(nrappkitTimerCallback, nsITimerCallback) // We're going to release ourself in the callback, so we need to be threadsafe
NS_IMPL_THREADSAFE_ISUPPORTS1(nrappkitTimerCallback, nsITimerCallback)
NS_IMETHODIMP nrappkitTimerCallback::Notify(nsITimer *timer) { NS_IMETHODIMP nrappkitTimerCallback::Notify(nsITimer *timer) {
r_log(LOG_GENERIC, LOG_DEBUG, "Timer callback fired"); r_log(LOG_GENERIC, LOG_DEBUG, "Timer callback fired");
@ -79,6 +80,9 @@ int NR_async_timer_set(int timeout, NR_async_cb cb, void *arg, char *func,
if (handle) if (handle)
*handle = timer.get(); *handle = timer.get();
// Bug 818806: if we have no handle to the timer, we have no way to avoid
// it leaking (though not the callback object) if it never fires (or if
// we exit before it fires).
return 0; return 0;
} }