зеркало из https://github.com/mozilla/gecko-dev.git
work with service to manage JSRuntimes
This commit is contained in:
Родитель
f4df3a45be
Коммит
97cca12af5
|
@ -38,6 +38,7 @@
|
||||||
#include "nsIXPConnect.h"
|
#include "nsIXPConnect.h"
|
||||||
#include "nsIXPCSecurityManager.h"
|
#include "nsIXPCSecurityManager.h"
|
||||||
#include "nsIJSContextStack.h"
|
#include "nsIJSContextStack.h"
|
||||||
|
#include "nsIJSRuntimeService.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
#if defined(OJI)
|
#if defined(OJI)
|
||||||
|
@ -424,12 +425,26 @@ nsJSEnvironment::GetScriptingEnvironment()
|
||||||
|
|
||||||
nsJSEnvironment::nsJSEnvironment()
|
nsJSEnvironment::nsJSEnvironment()
|
||||||
{
|
{
|
||||||
mRuntime = JS_Init(gGCSize);
|
nsresult result;
|
||||||
|
|
||||||
|
NS_WITH_SERVICE(nsIJSRuntimeService, rtsvc, "nsJSRuntimeService", &result);
|
||||||
|
|
||||||
|
// get the JSRuntime from the runtime svc, if possible
|
||||||
|
if (NS_SUCCEEDED(result)) {
|
||||||
|
result = rtsvc->GetRuntime(&mRuntime);
|
||||||
|
if (NS_FAILED(result) || !mRuntime) {
|
||||||
|
mRuntime = JS_NewRuntime(gGCSize);
|
||||||
|
if (NS_SUCCEEDED(result)) // got service, so set it back
|
||||||
|
rtsvc->SetRuntime(mRuntime);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mRuntime = JS_NewRuntime(gGCSize);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(OJI)
|
#if defined(OJI)
|
||||||
// Initialize LiveConnect.
|
// Initialize LiveConnect.
|
||||||
nsILiveConnectManager* manager = NULL;
|
nsILiveConnectManager* manager = NULL;
|
||||||
nsresult result = nsServiceManager::GetService(nsIJVMManager::GetCID(),
|
result = nsServiceManager::GetService(nsIJVMManager::GetCID(),
|
||||||
nsILiveConnectManager::GetIID(),
|
nsILiveConnectManager::GetIID(),
|
||||||
(nsISupports **)&manager);
|
(nsISupports **)&manager);
|
||||||
|
|
||||||
|
@ -440,11 +455,17 @@ nsJSEnvironment::nsJSEnvironment()
|
||||||
result = nsServiceManager::ReleaseService(nsIJVMManager::GetCID(), manager);
|
result = nsServiceManager::ReleaseService(nsIJVMManager::GetCID(), manager);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsJSEnvironment::~nsJSEnvironment()
|
nsJSEnvironment::~nsJSEnvironment()
|
||||||
{
|
{
|
||||||
JS_Finish(mRuntime);
|
nsresult result;
|
||||||
|
NS_WITH_SERVICE(nsIJSRuntimeService, rtsvc, "nsJSRuntimeService", &result);
|
||||||
|
if (NS_SUCCEEDED(result)) {
|
||||||
|
rtsvc->SetRuntime(0);
|
||||||
|
}
|
||||||
|
JS_DestroyRuntime(mRuntime);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIScriptContext* nsJSEnvironment::GetNewContext()
|
nsIScriptContext* nsJSEnvironment::GetNewContext()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче