зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset eb7402ddbe54 (bug 873622) for Windows bustage.
CLOSED TREE
This commit is contained in:
Родитель
6c954fa541
Коммит
420889df7c
|
@ -2422,7 +2422,11 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
|
|||
|
||||
nsresult nsScriptSecurityManager::Init()
|
||||
{
|
||||
NS_ADDREF(sXPConnect = nsXPConnect::XPConnect());
|
||||
nsXPConnect* xpconnect = nsXPConnect::GetXPConnect();
|
||||
if (!xpconnect)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ADDREF(sXPConnect = xpconnect);
|
||||
|
||||
JSContext* cx = GetSafeJSContext();
|
||||
if (!cx) return NS_ERROR_FAILURE; // this can happen of xpt loading fails
|
||||
|
|
|
@ -361,7 +361,10 @@ nsContentUtils::Init()
|
|||
nsresult rv = NS_GetNameSpaceManager(&sNameSpaceManager);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
sXPConnect = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpconnect = nsXPConnect::GetXPConnect();
|
||||
NS_ENSURE_TRUE(xpconnect, NS_ERROR_FAILURE);
|
||||
|
||||
sXPConnect = xpconnect;
|
||||
|
||||
sSecurityManager = nsScriptSecurityManager::GetScriptSecurityManager();
|
||||
if(!sSecurityManager)
|
||||
|
|
|
@ -262,7 +262,12 @@ File(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc) {
|
||||
XPCThrower::Throw(NS_ERROR_UNEXPECTED, cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject* glob = JS_GetGlobalForScopeChain(cx);
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
|
@ -297,7 +302,12 @@ Blob(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc) {
|
||||
XPCThrower::Throw(NS_ERROR_UNEXPECTED, cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject* glob = JS_GetGlobalForScopeChain(cx);
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
|
|
|
@ -24,7 +24,7 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
|||
jsval *argv /* = nullptr */,
|
||||
jsval *rval /* = nullptr */)
|
||||
: mState(INIT_FAILED),
|
||||
mXPC(nsXPConnect::XPConnect()),
|
||||
mXPC(nsXPConnect::GetXPConnect()),
|
||||
mXPCContext(nullptr),
|
||||
mJSContext(cx),
|
||||
mContextPopRequired(false),
|
||||
|
@ -48,7 +48,7 @@ XPCCallContext::XPCCallContext(XPCContext::LangType callerLanguage,
|
|||
XPCWrappedNative* wrapper,
|
||||
XPCWrappedNativeTearOff* tearOff)
|
||||
: mState(INIT_FAILED),
|
||||
mXPC(nsXPConnect::XPConnect()),
|
||||
mXPC(nsXPConnect::GetXPConnect()),
|
||||
mXPCContext(nullptr),
|
||||
mJSContext(cx),
|
||||
mContextPopRequired(false),
|
||||
|
|
|
@ -65,7 +65,10 @@ JSValIsInterfaceOfType(JSContext *cx, HandleValue v, REFNSIID iid)
|
|||
if (v.isPrimitive())
|
||||
return false;
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsCOMPtr<nsIXPConnect> xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc)
|
||||
return false;
|
||||
|
||||
RootedObject obj(cx, &v.toObject());
|
||||
if (NS_SUCCEEDED(xpc->GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wn))) && wn &&
|
||||
NS_SUCCEEDED(wn->Native()->QueryInterface(iid, (void**)&iface)) && iface)
|
||||
|
@ -2805,8 +2808,9 @@ nsXPCComponents_Utils::ReportError(const JS::Value &errorArg, JSContext *cx)
|
|||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIStackFrame> frame;
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
xpc->GetCurrentJSStack(getter_AddRefs(frame));
|
||||
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
if (xpc)
|
||||
xpc->GetCurrentJSStack(getter_AddRefs(frame));
|
||||
|
||||
nsXPIDLCString fileName;
|
||||
int32_t lineNo = 0;
|
||||
|
@ -3478,7 +3482,9 @@ GetPrincipalOrSOP(JSContext *cx, HandleObject from, nsISupports **out)
|
|||
MOZ_ASSERT(out);
|
||||
*out = NULL;
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsCOMPtr<nsIXPConnect> xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc)
|
||||
return NS_ERROR_XPC_UNEXPECTED;
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
xpc->GetWrappedNativeOfJSObject(cx, from,
|
||||
getter_AddRefs(wrapper));
|
||||
|
@ -3679,7 +3685,9 @@ AssembleSandboxMemoryReporterName(JSContext *cx, nsCString &sandboxName)
|
|||
if (sandboxName.IsEmpty())
|
||||
sandboxName = NS_LITERAL_CSTRING("[anonymous sandbox]");
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
NS_ENSURE_TRUE(xpc, NS_ERROR_XPC_UNEXPECTED);
|
||||
|
||||
// Get the xpconnect native call context.
|
||||
nsAXPCNativeCallContext *cc = nullptr;
|
||||
xpc->GetCurrentNativeCallContext(&cc);
|
||||
|
@ -4416,9 +4424,9 @@ nsXPCComponents_Utils::Dispatch(const jsval &runnableArg, const jsval &scope,
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIRunnable> run;
|
||||
nsresult rv = nsXPConnect::XPConnect()->WrapJS(cx, &runnable.toObject(),
|
||||
NS_GET_IID(nsIRunnable),
|
||||
getter_AddRefs(run));
|
||||
nsresult rv = nsXPConnect::GetXPConnect()->WrapJS(cx, &runnable.toObject(),
|
||||
NS_GET_IID(nsIRunnable),
|
||||
getter_AddRefs(run));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
MOZ_ASSERT(run);
|
||||
|
||||
|
@ -4761,7 +4769,9 @@ NS_IMETHODIMP
|
|||
nsXPCComponents::GetStack(nsIStackFrame * *aStack)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = xpc->GetCurrentJSStack(aStack);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -297,7 +297,9 @@ nsXPCException::Initialize(const char *aMessage, nsresult aResult, const char *a
|
|||
return rc;
|
||||
} else {
|
||||
nsresult rv;
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = xpc->GetCurrentJSStack(&mLocation);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -398,7 +400,11 @@ nsXPCException::NewException(const char *aMessage,
|
|||
location = aLocation;
|
||||
NS_ADDREF(location);
|
||||
} else {
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc) {
|
||||
NS_RELEASE(e);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = xpc->GetCurrentJSStack(&location);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(e);
|
||||
|
|
|
@ -147,7 +147,10 @@ XPCJSContextStack::GetSafeJSContext()
|
|||
if (NS_FAILED(rv))
|
||||
return NULL;
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsRefPtr<nsXPConnect> xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc)
|
||||
return NULL;
|
||||
|
||||
XPCJSRuntime* xpcrt = xpc->GetRuntime();
|
||||
if (!xpcrt)
|
||||
return NULL;
|
||||
|
|
|
@ -714,7 +714,10 @@ static void
|
|||
GetWrapperObject(MutableHandleObject obj)
|
||||
{
|
||||
obj.set(NULL);
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc)
|
||||
return;
|
||||
|
||||
nsAXPCNativeCallContext *ccxp = NULL;
|
||||
xpc->GetCurrentNativeCallContext(&ccxp);
|
||||
if (!ccxp)
|
||||
|
@ -766,7 +769,7 @@ nsJSCID::CreateInstance(const JS::Value& iidval, JSContext* cx,
|
|||
if (NS_FAILED(rv) || !inst)
|
||||
return NS_ERROR_XPC_CI_RETURNED_FAILURE;
|
||||
|
||||
rv = nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, obj, inst, nullptr, iid, true, retval, nullptr);
|
||||
rv = nsXPConnect::GetXPConnect()->WrapNativeToJSVal(cx, obj, inst, nullptr, iid, true, retval, nullptr);
|
||||
if (NS_FAILED(rv) || JSVAL_IS_PRIMITIVE(*retval))
|
||||
return NS_ERROR_XPC_CANT_CREATE_WN;
|
||||
return NS_OK;
|
||||
|
@ -815,7 +818,7 @@ nsJSCID::GetService(const JS::Value& iidval, JSContext* cx,
|
|||
|
||||
RootedObject instJSObj(cx);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = nsXPConnect::XPConnect()->WrapNative(cx, obj, srvc, *iid, getter_AddRefs(holder));
|
||||
rv = nsXPConnect::GetXPConnect()->WrapNative(cx, obj, srvc, *iid, getter_AddRefs(holder));
|
||||
if (NS_FAILED(rv) || !holder ||
|
||||
// Assign, not compare
|
||||
!(instJSObj = holder->GetJSObject()))
|
||||
|
@ -892,7 +895,7 @@ xpc_NewIDObject(JSContext *cx, HandleObject jsobj, const nsID& aID)
|
|||
nsCOMPtr<nsIJSID> iid =
|
||||
dont_AddRef(static_cast<nsIJSID*>(nsJSID::NewID(aID)));
|
||||
if (iid) {
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (xpc) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = xpc->WrapNative(cx, jsobj,
|
||||
|
|
|
@ -608,8 +608,9 @@ XPCJSRuntime::UnmarkSkippableJSHolders()
|
|||
void
|
||||
xpc_UnmarkSkippableJSHolders()
|
||||
{
|
||||
if (nsXPConnect::XPConnect()->GetRuntime()) {
|
||||
nsXPConnect::XPConnect()->GetRuntime()->UnmarkSkippableJSHolders();
|
||||
if (nsXPConnect::GetXPConnect() &&
|
||||
nsXPConnect::GetXPConnect()->GetRuntime()) {
|
||||
nsXPConnect::GetXPConnect()->GetRuntime()->UnmarkSkippableJSHolders();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2258,7 +2259,7 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
|
|||
|
||||
virtual void initExtraZoneStats(JS::Zone *zone, JS::ZoneStats *zStats) MOZ_OVERRIDE {
|
||||
// Get the compartment's global.
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
AutoSafeJSContext cx;
|
||||
JSCompartment *comp = js::GetAnyCompartmentInZone(zone);
|
||||
xpc::ZoneStatsExtras *extras = new xpc::ZoneStatsExtras;
|
||||
|
@ -2291,7 +2292,7 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
|
|||
GetCompartmentName(c, cName, true);
|
||||
|
||||
// Get the compartment's global.
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
AutoSafeJSContext cx;
|
||||
bool needZone = true;
|
||||
RootedObject global(cx, JS_GetGlobalForCompartmentOrNull(cx, c));
|
||||
|
@ -3003,8 +3004,8 @@ XPCRootSetElem::AddToRootSet(XPCLock *lock, XPCRootSetElem **listHead)
|
|||
void
|
||||
XPCRootSetElem::RemoveFromRootSet(XPCLock *lock)
|
||||
{
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
JS::PokeGC(xpc->GetRuntime()->GetJSRuntime());
|
||||
if (nsXPConnect *xpc = nsXPConnect::GetXPConnect())
|
||||
JS::PokeGC(xpc->GetRuntime()->GetJSRuntime());
|
||||
|
||||
NS_ASSERTION(mSelfp, "Must be linked");
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ nsresult xpcJSWeakReference::Init(JSContext* cx, const JS::Value& object)
|
|||
|
||||
// See if the object is a wrapped native that supports weak references.
|
||||
nsISupports* supports =
|
||||
nsXPConnect::XPConnect()->GetNativeOfWrapper(cx, obj);
|
||||
nsXPConnect::GetXPConnect()->GetNativeOfWrapper(cx, obj);
|
||||
nsCOMPtr<nsISupportsWeakReference> supportsWeakRef =
|
||||
do_QueryInterface(supports);
|
||||
if (supportsWeakRef) {
|
||||
|
|
|
@ -65,7 +65,7 @@ LookupInterfaceOrAncestor(uint32_t tableSize, const xpc_qsHashEntry *table,
|
|||
* supports, including ancestors.
|
||||
*/
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
if (NS_FAILED(nsXPConnect::XPConnect()->GetInfoForIID(&iid, getter_AddRefs(info))))
|
||||
if (NS_FAILED(nsXPConnect::GetXPConnect()->GetInfoForIID(&iid, getter_AddRefs(info))))
|
||||
return nullptr;
|
||||
|
||||
const nsIID *piid;
|
||||
|
|
|
@ -241,7 +241,7 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
|
|||
return false;
|
||||
JS_SetPendingException(cx, thrown);
|
||||
success = true;
|
||||
} else if ((xpc = nsXPConnect::XPConnect())) {
|
||||
} else if ((xpc = nsXPConnect::GetXPConnect())) {
|
||||
JS::RootedObject glob(cx, JS_GetGlobalForScopeChain(cx));
|
||||
if (!glob)
|
||||
return false;
|
||||
|
|
|
@ -350,11 +350,12 @@ JSBool XPCVariant::InitializeData(JSContext* cx)
|
|||
|
||||
// XXX This could be smarter and pick some more interesting iface.
|
||||
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc;
|
||||
nsCOMPtr<nsISupports> wrapper;
|
||||
const nsIID& iid = NS_GET_IID(nsISupports);
|
||||
|
||||
return NS_SUCCEEDED(xpc->WrapJS(cx, jsobj,
|
||||
return nullptr != (xpc = nsXPConnect::GetXPConnect()) &&
|
||||
NS_SUCCEEDED(xpc->WrapJS(cx, jsobj,
|
||||
iid, getter_AddRefs(wrapper))) &&
|
||||
NS_SUCCEEDED(nsVariant::SetFromInterface(&mData, iid, wrapper));
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID,
|
|||
|
||||
if (!clazz) {
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
nsXPConnect::GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (info) {
|
||||
bool canScript, isBuiltin;
|
||||
if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
|
||||
|
@ -240,7 +240,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
|||
// We so often ask for nsISupports that we can short-circuit the test...
|
||||
if (!aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
nsXPConnect::GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (!info)
|
||||
return nullptr;
|
||||
bool canScript, isBuiltin;
|
||||
|
@ -276,7 +276,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
|||
// C++ QI failure. See if that is the case.
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
|
||||
nsXPConnect::XPConnect()->
|
||||
nsXPConnect::GetXPConnect()->
|
||||
GetWrappedNativeOfJSObject(cx,
|
||||
&jsexception.toObject(),
|
||||
getter_AddRefs(wrapper));
|
||||
|
@ -684,7 +684,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
|||
|
||||
*aInstancePtr = nullptr;
|
||||
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_QueryInterface(xpc->GetDefaultSecurityManager());
|
||||
if (!secMan)
|
||||
|
|
|
@ -117,7 +117,13 @@ nsCxPusher::Push(JSContext *cx)
|
|||
void
|
||||
nsCxPusher::DoPush(JSContext* cx)
|
||||
{
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsIXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc) {
|
||||
// If someone tries to push a cx when we don't have the relevant state,
|
||||
// it's probably safest to just crash.
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
// NB: The GetDynamicScriptContext is historical and might not be sane.
|
||||
if (cx && nsJSUtils::GetDynamicScriptContext(cx) &&
|
||||
xpc::IsJSContextOnStack(cx))
|
||||
|
@ -165,6 +171,7 @@ nsCxPusher::Pop()
|
|||
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(nsXPConnect::GetXPConnect());
|
||||
|
||||
// Leave the request before popping.
|
||||
mAutoRequest.destroyIfConstructed();
|
||||
|
@ -177,7 +184,7 @@ nsCxPusher::Pop()
|
|||
MOZ_ASSERT_IF(mPushedContext, mCompartmentDepthOnEntry ==
|
||||
js::GetEnterCompartmentDepth(mPushedContext));
|
||||
DebugOnly<JSContext*> stackTop;
|
||||
MOZ_ASSERT(mPushedContext == nsXPConnect::XPConnect()->GetCurrentJSContext());
|
||||
MOZ_ASSERT(mPushedContext == nsXPConnect::GetXPConnect()->GetCurrentJSContext());
|
||||
xpc::PopJSContext();
|
||||
|
||||
if (!mScriptIsRunning && mScx) {
|
||||
|
@ -213,7 +220,7 @@ AutoJSContext::Init(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
|
|||
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsIXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
if (!aSafe) {
|
||||
mCx = xpc->GetCurrentJSContext();
|
||||
}
|
||||
|
@ -236,7 +243,7 @@ AutoSafeJSContext::AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMP
|
|||
|
||||
AutoPushJSContext::AutoPushJSContext(JSContext *aCx) : mCx(aCx)
|
||||
{
|
||||
if (mCx && mCx != nsXPConnect::XPConnect()->GetCurrentJSContext()) {
|
||||
if (mCx && mCx != nsXPConnect::GetXPConnect()->GetCurrentJSContext()) {
|
||||
mPusher.Push(mCx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,29 +137,48 @@ nsXPConnect::~nsXPConnect()
|
|||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsXPConnect::InitStatics()
|
||||
{
|
||||
gSelf = new nsXPConnect();
|
||||
gOnceAliveNowDead = false;
|
||||
if (!gSelf->mRuntime) {
|
||||
NS_RUNTIMEABORT("Couldn't create XPCJSRuntime.");
|
||||
}
|
||||
|
||||
// Initial extra ref to keep the singleton alive
|
||||
// balanced by explicit call to ReleaseXPConnectSingleton()
|
||||
NS_ADDREF(gSelf);
|
||||
|
||||
// Set XPConnect as the main thread observer.
|
||||
if (NS_FAILED(nsThread::SetMainThreadObserver(gSelf))) {
|
||||
nsXPConnect*
|
||||
nsXPConnect::GetXPConnect()
|
||||
{
|
||||
// Do a release-mode assert that we're not doing anything significant in
|
||||
// XPConnect off the main thread. If you're an extension developer hitting
|
||||
// this, you need to change your code. See bug 716167.
|
||||
if (!MOZ_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread()))
|
||||
MOZ_CRASH();
|
||||
|
||||
if (!gSelf) {
|
||||
if (gOnceAliveNowDead)
|
||||
return nullptr;
|
||||
gSelf = new nsXPConnect();
|
||||
if (!gSelf)
|
||||
return nullptr;
|
||||
|
||||
if (!gSelf->mRuntime) {
|
||||
NS_RUNTIMEABORT("Couldn't create XPCJSRuntime.");
|
||||
}
|
||||
|
||||
// Initial extra ref to keep the singleton alive
|
||||
// balanced by explicit call to ReleaseXPConnectSingleton()
|
||||
NS_ADDREF(gSelf);
|
||||
|
||||
// Set XPConnect as the main thread observer.
|
||||
//
|
||||
// The cycle collector sometimes calls GetXPConnect, but it should never
|
||||
// be the one that initializes gSelf.
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (NS_FAILED(nsThread::SetMainThreadObserver(gSelf))) {
|
||||
NS_RELEASE(gSelf);
|
||||
// Fall through to returning null
|
||||
}
|
||||
}
|
||||
return gSelf;
|
||||
}
|
||||
|
||||
// static
|
||||
nsXPConnect*
|
||||
nsXPConnect::GetSingleton()
|
||||
{
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
NS_IF_ADDREF(xpc);
|
||||
return xpc;
|
||||
}
|
||||
|
@ -211,7 +230,8 @@ nsXPConnect::ReleaseXPConnectSingleton()
|
|||
XPCJSRuntime*
|
||||
nsXPConnect::GetRuntimeInstance()
|
||||
{
|
||||
nsXPConnect* xpc = XPConnect();
|
||||
nsXPConnect* xpc = GetXPConnect();
|
||||
NS_ASSERTION(xpc, "Must not be called if XPC failed to initialize");
|
||||
return xpc->GetRuntime();
|
||||
}
|
||||
|
||||
|
@ -2032,7 +2052,7 @@ NS_EXPORT_(void)
|
|||
xpc_ActivateDebugMode()
|
||||
{
|
||||
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
|
||||
nsXPConnect::XPConnect()->SetDebugModeWhenPossible(true, true);
|
||||
nsXPConnect::GetXPConnect()->SetDebugModeWhenPossible(true, true);
|
||||
nsXPConnect::CheckForDebugMode(rt->GetJSRuntime());
|
||||
}
|
||||
|
||||
|
@ -2057,7 +2077,7 @@ bool
|
|||
PushJSContext(JSContext *aCx)
|
||||
{
|
||||
// JSD mumbo jumbo.
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
JSRuntime *rt = XPCJSRuntime::Get()->GetJSRuntime();
|
||||
if (xpc::gDebugMode != xpc::gDesiredDebugMode) {
|
||||
if (!xpc::gDesiredDebugMode) {
|
||||
|
@ -2232,7 +2252,11 @@ void
|
|||
DumpJSHeap(FILE* file)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Must dump GC heap on main thread.");
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
||||
if (!xpc) {
|
||||
NS_ERROR("Failed to get nsXPConnect instance!");
|
||||
return;
|
||||
}
|
||||
js::DumpHeapComplete(xpc->GetRuntime()->GetJSRuntime(), file);
|
||||
}
|
||||
|
||||
|
|
|
@ -476,18 +476,8 @@ public:
|
|||
// non-interface implementation
|
||||
public:
|
||||
// These get non-addref'd pointers
|
||||
static nsXPConnect* XPConnect()
|
||||
{
|
||||
// Do a release-mode assert that we're not doing anything significant in
|
||||
// XPConnect off the main thread. If you're an extension developer hitting
|
||||
// this, you need to change your code. See bug 716167.
|
||||
if (!MOZ_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread()))
|
||||
MOZ_CRASH();
|
||||
|
||||
return gSelf;
|
||||
}
|
||||
|
||||
static nsXPConnect* FastGetXPConnect() { return gSelf ? gSelf : XPConnect(); }
|
||||
static nsXPConnect* GetXPConnect();
|
||||
static nsXPConnect* FastGetXPConnect() { return gSelf ? gSelf : GetXPConnect(); }
|
||||
static XPCJSRuntime* GetRuntimeInstance();
|
||||
XPCJSRuntime* GetRuntime() {return mRuntime;}
|
||||
|
||||
|
@ -516,7 +506,7 @@ public:
|
|||
static nsXPConnect* GetSingleton();
|
||||
|
||||
// Called by module code in dll startup
|
||||
static void InitStatics();
|
||||
static void InitStatics() { gSelf = nullptr; gOnceAliveNowDead = false; }
|
||||
// Called by module code on dll shutdown.
|
||||
static void ReleaseXPConnectSingleton();
|
||||
|
||||
|
@ -654,7 +644,7 @@ class XPCJSRuntime
|
|||
{
|
||||
public:
|
||||
static XPCJSRuntime* newXPCJSRuntime(nsXPConnect* aXPConnect);
|
||||
static XPCJSRuntime* Get() { return nsXPConnect::XPConnect()->GetRuntime(); }
|
||||
static XPCJSRuntime* Get() { return nsXPConnect::GetXPConnect()->GetRuntime(); }
|
||||
|
||||
JSRuntime* GetJSRuntime() const {return mJSRuntime;}
|
||||
nsXPConnect* GetXPConnect() const {return mXPConnect;}
|
||||
|
|
|
@ -1935,7 +1935,7 @@ do_QueryInterfaceNative(JSContext* cx, HandleObject wrapper)
|
|||
nativeSupports = wn->Native();
|
||||
}
|
||||
} else {
|
||||
nsIXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
nsIXPConnect *xpc = nsXPConnect::GetXPConnect();
|
||||
nativeSupports = xpc->GetNativeOfWrapper(cx, wrapper);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче