mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1276310 part 5. Remove the now-unused XPCContext. r=bholley
The XPCShellImpl change is needed because we're now unifying XPCShellImpl with some file that does "using namespace xpc" at toplevel, so the "Atob" and "Btoa" barewords in its JSFunctionSpecs become ambiguous. Luckily, the file-static versions of those in XPCShellImpl are completely identical to the xpc-namespaced versions anyway.
This commit is contained in:
parent
c064e99123
commit
5254910dfb
@ -1,45 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=99: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* Per JSContext object. */
|
||||
|
||||
#include "xpcprivate.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
XPCContext::XPCContext(XPCJSRuntime* aRuntime,
|
||||
JSContext* aJSContext)
|
||||
: mRuntime(aRuntime),
|
||||
mJSContext(aJSContext)
|
||||
{
|
||||
MOZ_COUNT_CTOR(XPCContext);
|
||||
|
||||
MOZ_ASSERT(!JS_GetSecondContextPrivate(mJSContext), "Must be null");
|
||||
JS_SetSecondContextPrivate(mJSContext, this);
|
||||
}
|
||||
|
||||
XPCContext::~XPCContext()
|
||||
{
|
||||
MOZ_COUNT_DTOR(XPCContext);
|
||||
MOZ_ASSERT(JS_GetSecondContextPrivate(mJSContext) == this, "Must match this");
|
||||
JS_SetSecondContextPrivate(mJSContext, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
XPCContext::DebugDump(int16_t depth)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
depth--;
|
||||
XPC_LOG_ALWAYS(("XPCContext @ %x", this));
|
||||
XPC_LOG_INDENT();
|
||||
XPC_LOG_ALWAYS(("mRuntime @ %x", mRuntime));
|
||||
XPC_LOG_ALWAYS(("mJSContext @ %x", mJSContext));
|
||||
|
||||
XPC_LOG_OUTDENT();
|
||||
#endif
|
||||
}
|
@ -22,7 +22,6 @@ using mozilla::dom::DestroyProtoAndIfaceCache;
|
||||
XPCJSContextStack::~XPCJSContextStack()
|
||||
{
|
||||
if (mSafeJSContext) {
|
||||
delete XPCContext::GetXPCContext(mSafeJSContext);
|
||||
mSafeJSContext = nullptr;
|
||||
}
|
||||
}
|
||||
@ -68,6 +67,6 @@ XPCJSContextStack::InitSafeJSContext()
|
||||
if (!JS::InitSelfHostedCode(mSafeJSContext))
|
||||
MOZ_CRASH("InitSelfHostedCode failed");
|
||||
|
||||
if (!mRuntime->InitXPCContext(mSafeJSContext))
|
||||
MOZ_CRASH("InitXPCContext failed");
|
||||
if (!mRuntime->JSContextInitialized(mSafeJSContext))
|
||||
MOZ_CRASH("JSContextCreated failed");
|
||||
}
|
||||
|
@ -3652,11 +3652,8 @@ XPCJSRuntime::newXPCJSRuntime()
|
||||
}
|
||||
|
||||
bool
|
||||
XPCJSRuntime::InitXPCContext(JSContext* cx)
|
||||
XPCJSRuntime::JSContextInitialized(JSContext* cx)
|
||||
{
|
||||
// If we were the first cx ever created (like the SafeJSContext), the caller
|
||||
// would have had no way to enter a request. Enter one now before doing the
|
||||
// rest of the cx setup.
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// if it is our first context then we need to generate our string ids
|
||||
@ -3677,10 +3674,6 @@ XPCJSRuntime::InitXPCContext(JSContext* cx)
|
||||
}
|
||||
}
|
||||
|
||||
XPCContext* xpc = new XPCContext(this, cx);
|
||||
if (!xpc)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3791,12 +3784,6 @@ XPCJSRuntime::DebugDump(int16_t depth)
|
||||
XPC_LOG_INDENT();
|
||||
XPC_LOG_ALWAYS(("mJSRuntime @ %x", Runtime()));
|
||||
|
||||
JSContext* cx = JS_GetContext(Runtime());
|
||||
XPCContext* xpc = XPCContext::GetXPCContext(cx);
|
||||
XPC_LOG_INDENT();
|
||||
xpc->DebugDump(depth);
|
||||
XPC_LOG_OUTDENT();
|
||||
|
||||
XPC_LOG_ALWAYS(("mWrappedJSClassMap @ %x with %d wrapperclasses(s)",
|
||||
mWrappedJSClassMap, mWrappedJSClassMap->Count()));
|
||||
// iterate wrappersclasses...
|
||||
|
@ -543,26 +543,6 @@ Options(JSContext* cx, unsigned argc, Value* vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
Atob(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (!args.length())
|
||||
return true;
|
||||
|
||||
return xpc::Base64Decode(cx, args[0], args.rval());
|
||||
}
|
||||
|
||||
static bool
|
||||
Btoa(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (!args.length())
|
||||
return true;
|
||||
|
||||
return xpc::Base64Encode(cx, args[0], args.rval());
|
||||
}
|
||||
|
||||
static PersistentRootedValue *sScriptedInterruptCallback = nullptr;
|
||||
|
||||
static bool
|
||||
@ -673,8 +653,8 @@ static const JSFunctionSpec glob_functions[] = {
|
||||
#endif
|
||||
JS_FS("options", Options, 0,0),
|
||||
JS_FS("sendCommand", SendCommand, 1,0),
|
||||
JS_FS("atob", Atob, 1,0),
|
||||
JS_FS("btoa", Btoa, 1,0),
|
||||
JS_FS("atob", xpc::Atob, 1,0),
|
||||
JS_FS("btoa", xpc::Btoa, 1,0),
|
||||
JS_FS("setInterruptCallback", SetInterruptCallback, 1,0),
|
||||
JS_FS("simulateActivityCallback", SimulateActivityCallback, 1,0),
|
||||
JS_FS("registerAppManifest", RegisterAppManifest, 1, 0),
|
||||
|
@ -19,7 +19,6 @@ UNIFIED_SOURCES += [
|
||||
'nsXPConnect.cpp',
|
||||
'Sandbox.cpp',
|
||||
'XPCCallContext.cpp',
|
||||
'XPCContext.cpp',
|
||||
'XPCConvert.cpp',
|
||||
'XPCDebug.cpp',
|
||||
'XPCException.cpp',
|
||||
|
@ -466,7 +466,7 @@ public:
|
||||
XPCWrappedNativeProtoMap* GetDetachedWrappedNativeProtoMap() const
|
||||
{return mDetachedWrappedNativeProtoMap;}
|
||||
|
||||
bool InitXPCContext(JSContext* cx);
|
||||
bool JSContextInitialized(JSContext* cx);
|
||||
|
||||
virtual bool
|
||||
DescribeCustomObjects(JSObject* aObject, const js::Class* aClasp,
|
||||
@ -659,41 +659,6 @@ private:
|
||||
friend class XPCIncrementalReleaseRunnable;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
// XPCContext is mostly a dumb class to hold JSContext specific data and
|
||||
// maps that let us find wrappers created for the given JSContext.
|
||||
|
||||
// no virtuals
|
||||
class XPCContext
|
||||
{
|
||||
friend class XPCJSRuntime;
|
||||
public:
|
||||
static XPCContext* GetXPCContext(JSContext* aJSContext)
|
||||
{
|
||||
MOZ_ASSERT(JS_GetSecondContextPrivate(aJSContext), "should already have XPCContext");
|
||||
return static_cast<XPCContext*>(JS_GetSecondContextPrivate(aJSContext));
|
||||
}
|
||||
|
||||
XPCJSRuntime* GetRuntime() const {return mRuntime;}
|
||||
JSContext* GetJSContext() const {return mJSContext;}
|
||||
|
||||
void DebugDump(int16_t depth);
|
||||
|
||||
~XPCContext();
|
||||
|
||||
private:
|
||||
XPCContext(); // no implementation
|
||||
XPCContext(XPCJSRuntime* aRuntime, JSContext* aJSContext);
|
||||
|
||||
static XPCContext* newXPCContext(XPCJSRuntime* aRuntime,
|
||||
JSContext* aJSContext);
|
||||
private:
|
||||
XPCJSRuntime* mRuntime;
|
||||
JSContext* mJSContext;
|
||||
bool mErrorUnreported;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// No virtuals
|
||||
|
Loading…
Reference in New Issue
Block a user