Bug 1638925 - Log names of nsINamed runnables, r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D79620
This commit is contained in:
Honza Bambas 2020-06-17 16:14:27 +00:00
parent 41e8aa0689
commit 91ff5e401f
2 changed files with 24 additions and 0 deletions

View File

@ -39,6 +39,8 @@ static LazyLogModule sEventDispatchAndRunLog("events");
#endif
#define LOG1(args) \
MOZ_LOG(sEventDispatchAndRunLog, mozilla::LogLevel::Error, args)
#define LOG1_ENABLED() \
MOZ_LOG_TEST(sEventDispatchAndRunLog, mozilla::LogLevel::Error)
using namespace mozilla;
@ -619,6 +621,24 @@ LogTaskBase<T>::Run::Run(T* aEvent, bool aWillRunAgain)
LOG1(("EXEC %p", mEvent));
}
template <>
LogTaskBase<nsIRunnable>::Run::Run(nsIRunnable* aEvent, bool aWillRunAgain)
: mEvent(aEvent), mWillRunAgain(aWillRunAgain) {
if (!LOG1_ENABLED()) {
return;
}
nsCOMPtr<nsINamed> named(do_QueryInterface(aEvent));
if (!named) {
LOG1(("EXEC %p", mEvent));
return;
}
nsAutoCString name;
named->GetName(name);
LOG1(("EXEC %p [%s]", aEvent, name.BeginReading()));
}
template <typename T>
LogTaskBase<T>::Run::~Run() {
LOG1((mWillRunAgain ? "INTERRUPTED %p" : "DONE %p", mEvent));

View File

@ -1905,6 +1905,10 @@ class LogTaskBase {
};
};
// Specialized constructor; must be explicitly declared.
template <>
LogTaskBase<nsIRunnable>::Run::Run(nsIRunnable* aEvent, bool aWillRunAgain);
class MicroTaskRunnable;
typedef LogTaskBase<nsIRunnable> LogRunnable;