зеркало из https://github.com/mozilla/gecko-dev.git
JSRuntime svc now controls lifetime; make nsIJSRuntimeService::runtime readonly
This commit is contained in:
Родитель
cae8fc76b7
Коммит
88e40b4884
|
@ -23,5 +23,5 @@
|
|||
[uuid(dcfbb49c-1dd1-11b2-9f39-935aef484817)]
|
||||
interface nsIJSRuntimeService : nsISupports
|
||||
{
|
||||
attribute JSRuntime runtime;
|
||||
readonly attribute JSRuntime runtime;
|
||||
};
|
||||
|
|
|
@ -33,7 +33,13 @@ nsJSRuntimeServiceImpl::nsJSRuntimeServiceImpl() :
|
|||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
nsJSRuntimeServiceImpl::~nsJSRuntimeServiceImpl() { }
|
||||
nsJSRuntimeServiceImpl::~nsJSRuntimeServiceImpl() {
|
||||
if (mRuntime)
|
||||
JS_DestroyRuntime(mRuntime);
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "nJRSI: destroyed runtime %p\n", mRuntime);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsJSRuntimeServiceImpl, nsIJSRuntimeService);
|
||||
|
||||
|
@ -49,6 +55,8 @@ nsJSRuntimeServiceImpl::GetSingleton()
|
|||
return singleton;
|
||||
}
|
||||
|
||||
const uint32 gGCSize = 4L * 1024L * 1024L; /* pref? */
|
||||
|
||||
/* attribute JSRuntime runtime; */
|
||||
NS_IMETHODIMP
|
||||
nsJSRuntimeServiceImpl::GetRuntime(JSRuntime **runtime)
|
||||
|
@ -56,22 +64,14 @@ nsJSRuntimeServiceImpl::GetRuntime(JSRuntime **runtime)
|
|||
if (!runtime)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mRuntime) {
|
||||
mRuntime = JS_NewRuntime(gGCSize);
|
||||
if (!mRuntime)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*runtime = mRuntime;
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "nJRSI: returning %p\n", mRuntime);
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSRuntimeServiceImpl::SetRuntime(JSRuntime *runtime)
|
||||
{
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "nJRSI: setting %p over %p\n", runtime, mRuntime);
|
||||
#endif
|
||||
NS_ASSERTION(!mRuntime || !runtime, "can\'t switch runtimes");
|
||||
if (mRuntime && runtime)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
mRuntime = runtime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче