Bug 932886 - Stop doing slow getService bits in dom::GetCurrentJSStack, r=bz

This commit is contained in:
Olli Pettay 2013-11-01 14:55:35 +02:00
parent eef7e42e54
commit 05466579d2

View File

@ -16,6 +16,7 @@
#include "nsThreadUtils.h"
#include "XPCWrapper.h"
#include "WorkerPrivate.h"
#include "nsContentUtils.h"
namespace {
@ -166,11 +167,14 @@ GetCurrentJSStack()
JSContext* cx = nullptr;
if (NS_IsMainThread()) {
// We can't call nsContentUtils::ThreadsafeGetCurrentJSContext, since in
// xpcshell nsContentUtils is never initialized, but we still need to
// report exceptions.
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
cx = xpc->GetCurrentJSContext();
// Note, in xpcshell nsContentUtils is never initialized, but we still need
// to report exceptions.
if (nsContentUtils::XPConnect()) {
cx = nsContentUtils::XPConnect()->GetCurrentJSContext();
} else {
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
cx = xpc->GetCurrentJSContext();
}
} else {
cx = workers::GetCurrentThreadJSContext();
}