Created
May 25, 2010 23:10
-
-
Save benjamn/413807 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool | |
JetpackChild::Init(base::ProcessHandle aParentProcessHandle, | |
MessageLoop* aIOLoop, | |
IPC::Channel* aChannel) | |
{ | |
if (!Open(aChannel, aParentProcessHandle, aIOLoop)) | |
return false; | |
if (!(mRuntime = JS_NewRuntime(32L * 1024L * 1024L)) || | |
!(mImplCx = JS_NewContext(mRuntime, 8192)) || | |
!(mUserCx = JS_NewContext(mRuntime, 8192))) | |
return false; | |
{ | |
JSAutoRequest request(mImplCx); | |
JS_SetContextPrivate(mImplCx, this); | |
JSObject* implGlobal = JS_NewObject(mImplCx, NULL, NULL, NULL); | |
JS_SetGlobalObject(mImplCx, implGlobal); | |
if (!implGlobal || | |
!JS_InitStandardClasses(mImplCx, implGlobal) || | |
!JS_DefineProperties(mImplCx, implGlobal, | |
const_cast<JSPropertySpec*>(sImplProperties)) || | |
!JS_DefineFunctions(mImplCx, implGlobal, | |
const_cast<JSFunctionSpec*>(sImplMethods))) | |
return false; | |
} | |
{ | |
JSAutoRequest request(mUserCx); | |
JS_SetContextPrivate(mUserCx, this); | |
JSObject* userGlobal = JS_NewObject(mUserCx, NULL, NULL, NULL); | |
JS_SetGlobalObject(mUserCx, userGlobal); | |
if (!userGlobal || | |
!JS_InitStandardClasses(mUserCx, userGlobal)) | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment