зеркало из https://github.com/mozilla/gecko-dev.git
Bug 795086 - Make nsConsoleService only post a LogMessageRunnable to the event queue if there are any observers for it. r=bz
This commit is contained in:
Родитель
c5fbc6a7a9
Коммит
21dd8087c0
|
@ -135,7 +135,7 @@ nsConsoleService::LogMessage(nsIConsoleMessage *message)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsRefPtr<LogMessageRunnable> r = new LogMessageRunnable(message, this);
|
||||
nsRefPtr<LogMessageRunnable> r;
|
||||
nsIConsoleMessage *retiredMessage;
|
||||
|
||||
NS_ADDREF(message); // early, in case it's same as replaced below.
|
||||
|
@ -180,14 +180,22 @@ nsConsoleService::LogMessage(nsIConsoleMessage *message)
|
|||
|
||||
/*
|
||||
* Copy the listeners into the snapshot array - in case a listener
|
||||
* is removed during an Observe(...) notification...
|
||||
* is removed during an Observe(...) notification. If there are no
|
||||
* listeners, don't bother to create the Runnable, since we don't
|
||||
* need to run it and it will hold onto the memory for the message
|
||||
* unnecessarily.
|
||||
*/
|
||||
mListeners.EnumerateRead(CollectCurrentListeners, r);
|
||||
if (mListeners.Count() > 0) {
|
||||
r = new LogMessageRunnable(message, this);
|
||||
mListeners.EnumerateRead(CollectCurrentListeners, r);
|
||||
}
|
||||
}
|
||||
|
||||
if (retiredMessage != nullptr)
|
||||
NS_RELEASE(retiredMessage);
|
||||
|
||||
NS_DispatchToMainThread(r);
|
||||
if (r)
|
||||
NS_DispatchToMainThread(r);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче