Bug 901106 - Get rid of vestigial nsJSRuntime instance and make it a namespace. r=mrbkap

We'll rename the namespace shortly.
This commit is contained in:
Bobby Holley 2013-08-19 16:24:29 -07:00
parent 9f05e412a1
commit a6c8c396cf
5 changed files with 11 additions and 59 deletions

View File

@ -55,9 +55,6 @@ nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
provider.swap(gExceptionProvider);
// And pre-create the javascript language.
NS_CreateJSRuntime(getter_AddRefs(mJSRuntime));
}
NS_INTERFACE_MAP_BEGIN(nsDOMScriptObjectFactory)

View File

@ -1773,8 +1773,6 @@ nsGlobalWindow::UnmarkGrayTimers()
// nsGlobalWindow::nsIScriptGlobalObject
//*****************************************************************************
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
nsresult
nsGlobalWindow::EnsureScriptEnvironment()
{
@ -1787,10 +1785,9 @@ nsGlobalWindow::EnsureScriptEnvironment()
NS_ASSERTION(!GetCurrentInnerWindowInternal(),
"mJSObject is null, but we have an inner window?");
// NB: The existing ownership model requires us to get the script object
// factory before we can access the nsJSRuntime. This will go away shortly.
nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
// Ensure that nsJSRuntime has been initialized. This is idempotent.
nsresult rv = nsJSRuntime::Init();
NS_ENSURE_SUCCESS(rv, rv);
// If this window is a [i]frame, don't bother GC'ing when the frame's context
// is destroyed since a GC will happen when the frameset or host document is
@ -1802,7 +1799,7 @@ nsGlobalWindow::EnsureScriptEnvironment()
// should probably assert the context is clean???
context->WillInitializeContext();
nsresult rv = context->InitContext();
rv = context->InitContext();
NS_ENSURE_SUCCESS(rv, rv);
mContext = context;

View File

@ -17,7 +17,6 @@
class nsIScriptContext;
class nsIScriptGlobalObject;
class nsIDOMEventListener;
class nsJSRuntime;
typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
(const char* aName);
@ -41,9 +40,6 @@ public:
uint32_t aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID) = 0;
protected:
nsRefPtr<nsJSRuntime> mJSRuntime;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,

View File

@ -2561,20 +2561,6 @@ nsJSContext::LikelyShortLivingObjectCreated()
++sLikelyShortLivingObjectsNeedingGC;
}
/**********************************************************************
* nsJSRuntime implementation
*********************************************************************/
// QueryInterface implementation for nsJSRuntime
NS_INTERFACE_MAP_BEGIN(nsJSRuntime)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsJSRuntime)
NS_IMPL_RELEASE(nsJSRuntime)
//static
void
nsJSRuntime::Startup()
{
@ -2750,7 +2736,6 @@ NS_DOMStructuredCloneError(JSContext* cx,
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
//static
nsresult
nsJSRuntime::Init()
{
@ -2873,7 +2858,6 @@ nsJSRuntime::Init()
return NS_OK;
}
//static
nsScriptNameSpaceManager*
nsJSRuntime::GetNameSpaceManager()
{
@ -2891,7 +2875,6 @@ nsJSRuntime::GetNameSpaceManager()
return gNameSpaceManager;
}
/* static */
void
nsJSRuntime::Shutdown()
{
@ -2911,19 +2894,6 @@ nsJSRuntime::Shutdown()
sDidShutdown = true;
}
// A factory for the runtime.
nsresult NS_CreateJSRuntime(nsJSRuntime **aRuntime)
{
nsresult rv = nsJSRuntime::Init();
NS_ENSURE_SUCCESS(rv, rv);
*aRuntime = new nsJSRuntime();
if (*aRuntime == nullptr)
return NS_ERROR_OUT_OF_MEMORY;
NS_IF_ADDREF(*aRuntime);
return NS_OK;
}
// A fast-array class for JS. This class supports both nsIJSScriptArray and
// nsIArray. If it is JS itself providing and consuming this class, all work
// can be done via nsIJSScriptArray, and avoid the conversion of elements

View File

@ -182,22 +182,17 @@ private:
class nsIJSRuntimeService;
class nsJSRuntime MOZ_FINAL : public nsISupports
namespace nsJSRuntime
{
public:
// let people who can see us use our runtime for convenience.
static JSRuntime *sRuntime;
extern JSRuntime *sRuntime;
public:
// nsISupports
NS_DECL_ISUPPORTS
static void Startup();
static void Shutdown();
void Startup();
void Shutdown();
// Setup all the statics etc - safe to call multiple times after Startup()
static nsresult Init();
nsresult Init();
// Get the NameSpaceManager, creating if necessary
static nsScriptNameSpaceManager* GetNameSpaceManager();
nsScriptNameSpaceManager* GetNameSpaceManager();
};
// An interface for fast and native conversion to/from nsIArray. If an object
@ -220,9 +215,6 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsIJSArgArray, NS_IJSARGARRAY_IID)
/* factory functions */
nsresult NS_CreateJSRuntime(nsJSRuntime **aRuntime);
/* prototypes */
void NS_ScriptErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);