Bug 880697 - Remove dumbContext. r=gabor

Whew.
This commit is contained in:
Bobby Holley 2013-06-12 14:17:56 -07:00
parent 1bac0d1e42
commit c3249a0a24
2 changed files with 16 additions and 29 deletions

View File

@ -108,7 +108,6 @@ struct JSDContext
void* functionHookData;
JSD_CallHookProc toplevelHook;
void* toplevelHookData;
JSContext* dumbContext;
JSObject* glob;
JSD_UserCallbacks userCallbacks;
void* user;

View File

@ -9,6 +9,10 @@
*/
#include "jsd.h"
#include "nsCxPusher.h"
#include "nsContentUtils.h"
using mozilla::AutoSafeJSContext;
/***************************************************************************/
@ -33,7 +37,6 @@ void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc)
{
JS_ASSERT(jsdc->inited);
JS_ASSERT(jsdc->jsrt);
JS_ASSERT(jsdc->dumbContext);
JS_ASSERT(jsdc->glob);
}
#endif
@ -71,8 +74,8 @@ _newJSDContext(JSRuntime* jsrt,
JSObject* scopeobj)
{
JSDContext* jsdc = NULL;
JSCompartment *oldCompartment = NULL;
JSBool ok;
bool ok = true;
AutoSafeJSContext cx;
if( ! jsrt )
return NULL;
@ -115,31 +118,20 @@ _newJSDContext(JSRuntime* jsrt,
if( ! jsd_InitScriptManager(jsdc) )
goto label_newJSDContext_failure;
jsdc->dumbContext = JS_NewContext(jsdc->jsrt, 256);
if( ! jsdc->dumbContext )
goto label_newJSDContext_failure;
JS_BeginRequest(jsdc->dumbContext);
JS_SetOptions(jsdc->dumbContext, JS_GetOptions(jsdc->dumbContext));
jsdc->glob = CreateJSDGlobal(jsdc->dumbContext, &global_class);
jsdc->glob = CreateJSDGlobal(cx, &global_class);
if( ! jsdc->glob )
goto label_newJSDContext_failure;
oldCompartment = JS_EnterCompartment(jsdc->dumbContext, jsdc->glob);
if ( ! JS_AddNamedObjectRoot(jsdc->dumbContext, &jsdc->glob, "JSD context global") )
goto label_newJSDContext_failure;
ok = JS_InitStandardClasses(jsdc->dumbContext, jsdc->glob);
JS_LeaveCompartment(jsdc->dumbContext, oldCompartment);
{
JSAutoCompartment ac(cx, jsdc->glob);
ok = JS_AddNamedObjectRoot(cx, &jsdc->glob, "JSD context global") &&
JS_InitStandardClasses(cx, jsdc->glob);
}
if( ! ok )
goto label_newJSDContext_failure;
JS_EndRequest(jsdc->dumbContext);
jsdc->data = NULL;
jsdc->inited = JS_TRUE;
@ -151,12 +143,10 @@ _newJSDContext(JSRuntime* jsrt,
label_newJSDContext_failure:
if( jsdc ) {
if ( jsdc->dumbContext && jsdc->glob )
JS_RemoveObjectRootRT(JS_GetRuntime(jsdc->dumbContext), &jsdc->glob);
if ( jsdc->glob )
JS_RemoveObjectRootRT(JS_GetRuntime(cx), &jsdc->glob);
jsd_DestroyObjectManager(jsdc);
jsd_DestroyAtomTable(jsdc);
if( jsdc->dumbContext )
JS_EndRequest(jsdc->dumbContext);
free(jsdc);
}
return NULL;
@ -171,8 +161,8 @@ _destroyJSDContext(JSDContext* jsdc)
JS_REMOVE_LINK(&jsdc->links);
JSD_UNLOCK();
if ( jsdc->dumbContext && jsdc->glob ) {
JS_RemoveObjectRootRT(JS_GetRuntime(jsdc->dumbContext), &jsdc->glob);
if ( jsdc->glob ) {
JS_RemoveObjectRootRT(jsdc->jsrt, &jsdc->glob);
}
jsd_DestroyObjectManager(jsdc);
jsd_DestroyAtomTable(jsdc);
@ -185,8 +175,6 @@ _destroyJSDContext(JSDContext* jsdc)
*
* XXX we also leak the locks
*/
JS_DestroyContext(jsdc->dumbContext);
jsdc->dumbContext = NULL;
}
/***************************************************************************/