Back to index

lightning-sunbird  0.9+nobinonly
Functions
jvmmgr.cpp File Reference
#include "prlog.h"
#include "nsJVMManager.h"
#include "nsIServiceManager.h"
#include "nsIJVMPrefsWindow.h"
#include "ProxyJNI.h"
#include "lcglue.h"
#include "nsCSecurityContext.h"
#include "nsIJSContextStack.h"

Go to the source code of this file.

Functions

static NS_DEFINE_CID (kJVMManagerCID, NS_JVMMANAGER_CID)
static NS_DEFINE_IID (kIJVMConsoleIID, NS_IJVMCONSOLE_IID)
static NS_DEFINE_IID (kIJVMPrefsWindowIID, NS_IJVMPREFSWINDOW_IID)
static NS_DEFINE_IID (kISymantecDebuggerIID, NS_ISYMANTECDEBUGGER_IID)
PR_BEGIN_EXTERN_C JVM_ReleaseJVMMgr (nsJVMManager *mgr)
static nsIJVMPluginGetRunningJVM (void)
 JVM_StartupJVM (void)
 JVM_ShutdownJVM (void)
 JVM_GetJVMStatus (void)
 JVM_AddToClassPath (const char *dirPath)
static nsIJVMConsoleGetConsole (void)
 JVM_ShowConsole (void)
 JVM_HideConsole (void)
 JVM_IsConsoleVisible (void)
 JVM_PrintToConsole (const char *msg)
static nsIJVMPrefsWindowGetPrefsWindow (void)
 JVM_ShowPrefsWindow (void)
 JVM_HidePrefsWindow (void)
 JVM_IsPrefsWindowVisible (void)
 JVM_StartDebugger (void)
 JVM_GetJNIEnv (void)
 JVM_ReleaseJNIEnv (JNIEnv *env)
 JVM_SpendTime (PRUint32 timeMillis)
 JVM_MaybeStartupLiveConnect ()
 JVM_MaybeShutdownLiveConnect (void)
 JVM_IsLiveConnectEnabled (void)
 JVM_GetJSSecurityContext ()

Function Documentation

static nsIJVMConsole* GetConsole ( void  ) [static]

Definition at line 137 of file jvmmgr.cpp.

{
    // PENDING(edburns): workaround for bug 76677, make sure the JVM is
    // started.
    JNIEnv* env = JVM_GetJNIEnv();
    if (!env)
        return nsnull;
    
    nsIJVMConsole* console = nsnull;
    nsIJVMPlugin* jvm = GetRunningJVM();
    if (jvm)
        jvm->QueryInterface(kIJVMConsoleIID, (void**)&console);
    return console;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIJVMPrefsWindow* GetPrefsWindow ( void  ) [static]

Definition at line 209 of file jvmmgr.cpp.

{
    nsIJVMPrefsWindow* prefsWin = NULL;
    nsIJVMPlugin* jvm = GetRunningJVM();
    if (jvm) {
        jvm->QueryInterface(kIJVMPrefsWindowIID, (void**)&prefsWin);
        // jvm->Release(); // GetRunningJVM no longer calls AddRef
    }
    return prefsWin;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIJVMPlugin* GetRunningJVM ( void  ) [static]

Definition at line 65 of file jvmmgr.cpp.

{
    nsIJVMPlugin* jvm = NULL;
    nsresult rv;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
    if (NS_FAILED(rv)) return jvm;
    nsJVMManager* jvmMgr = (nsJVMManager *)managerService.get();  
    if (jvmMgr) {
        nsJVMStatus status = jvmMgr->GetJVMStatus();
        if (status == nsJVMStatus_Enabled)
            status = jvmMgr->StartupJVM();
        if (status == nsJVMStatus_Running) {
            jvm = jvmMgr->GetJVMPlugin();
        }
    }
    return jvm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JVM_AddToClassPath ( const char *  dirPath)

Definition at line 120 of file jvmmgr.cpp.

{
    nsresult err = NS_ERROR_FAILURE;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &err);
    if (NS_FAILED(err)) return PR_FALSE;
    nsJVMManager* mgr = (nsJVMManager *)managerService.get();
    if (mgr) {
        err = mgr->AddToClassPath(dirPath);
    }
    return err == NS_OK;
}

Here is the call graph for this function:

Definition at line 278 of file jvmmgr.cpp.

{
       /* get proxy env for current thread. */
       JVMContext* context = GetJVMContext();
    JNIEnv* env = context->proxyEnv;
       if (env != NULL)
              return env;

       // Create a Proxy JNI to associate with this NSPR thread.
    nsIJVMPlugin* jvmPlugin = GetRunningJVM();
       if (jvmPlugin != NULL)
              env = CreateProxyJNI(jvmPlugin);

       /* Associate the JNIEnv with the current thread. */
       context->proxyEnv = env;

    return env;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 365 of file jvmmgr.cpp.

{
    JSContext *cx = nsnull;
    nsCOMPtr<nsIJSContextStack> stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");
    if (stack) stack->Peek(&cx);

    nsCSecurityContext *securityContext = new nsCSecurityContext(cx);
    if (securityContext == nsnull) {
        return nsnull;
    }

    NS_ADDREF(securityContext);
    return securityContext;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 106 of file jvmmgr.cpp.

{
    nsresult rv;
    nsJVMStatus status = nsJVMStatus_Disabled;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
    if (NS_FAILED(rv)) return status;
    nsJVMManager* mgr = (nsJVMManager *)managerService.get();  
    if (mgr) {
        status = mgr->GetJVMStatus();
    }
    return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 163 of file jvmmgr.cpp.

{
    nsJVMStatus status = JVM_GetJVMStatus();
    if (status == nsJVMStatus_Running) {
        nsIJVMConsole* console = GetConsole();
        if (console) {
            console->Hide();
            console->Release();
        }
    }
}

Here is the call graph for this function:

Definition at line 231 of file jvmmgr.cpp.

{
    nsJVMStatus status = JVM_GetJVMStatus();
    if (status == nsJVMStatus_Running) {
        nsIJVMPrefsWindow* prefsWin = GetPrefsWindow();
        if (prefsWin) {
            prefsWin->Hide();
            prefsWin->Release();
        }
    }
}

Here is the call graph for this function:

Definition at line 176 of file jvmmgr.cpp.

{
    PRBool result = PR_FALSE;
    nsJVMStatus status = JVM_GetJVMStatus();
    if (status == nsJVMStatus_Running) {
        nsIJVMConsole* console = GetConsole();
        if (console) {
            nsresult err = console->IsVisible(&result);
            PR_ASSERT(err != NS_OK ? result == PR_FALSE : PR_TRUE);
            console->Release();
        }
    }
    return result;
}

Here is the call graph for this function:

Definition at line 350 of file jvmmgr.cpp.

{
    PRBool result = PR_FALSE;
    nsresult rv;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
    if (NS_FAILED(rv)) return result;
    nsJVMManager* mgr = (nsJVMManager *)managerService.get();
    if (mgr) {
        result = mgr->IsLiveConnectEnabled();
    }
    return result;
}

Here is the call graph for this function:

Definition at line 244 of file jvmmgr.cpp.

{
    PRBool result = PR_FALSE;
    nsJVMStatus status = JVM_GetJVMStatus();
    if (status == nsJVMStatus_Running) {
        nsIJVMPrefsWindow* prefsWin = GetPrefsWindow();
        if (prefsWin) {
            nsresult err = prefsWin->IsVisible(&result);
            PR_ASSERT(err != NS_OK ? result == PR_FALSE : PR_TRUE);
            prefsWin->Release();
        }
    }
    return result;
}

Here is the call graph for this function:

Definition at line 336 of file jvmmgr.cpp.

{
    PRBool result = PR_FALSE;
    nsresult rv;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
    if (NS_FAILED(rv)) return result;
    nsJVMManager* mgr = (nsJVMManager *)managerService.get(); 
    if (mgr) {
        result = mgr->MaybeShutdownLiveConnect();
    }
    return result;
}

Here is the call graph for this function:

Definition at line 321 of file jvmmgr.cpp.

{
    PRBool result = PR_FALSE;
    nsresult rv;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
    if (NS_FAILED(rv)) return result;
    nsJVMManager* mgr = (nsJVMManager *)managerService.get();  
    if (mgr) {
        result = mgr->MaybeStartupLiveConnect();
    }
    return result;
}

Here is the call graph for this function:

JVM_PrintToConsole ( const char *  msg)

Definition at line 192 of file jvmmgr.cpp.

{
    nsJVMStatus status = JVM_GetJVMStatus();
    if (status != nsJVMStatus_Running)
        return;
    nsIJVMConsole* console = GetConsole();
    if (console) {
        console->Print(msg);
        console->Release();
    }
}

Here is the call graph for this function:

this is now done when the NSPR thread is shutdown. JNIEnvs are always tied to the lifetime of threads.

Definition at line 298 of file jvmmgr.cpp.

{
}

Here is the caller graph for this function:

Definition at line 59 of file jvmmgr.cpp.

{
    mgr->Release();
}

Definition at line 153 of file jvmmgr.cpp.

{
    nsIJVMConsole* console = GetConsole();
    if (console) {
        console->Show();
        console->Release();
    }
}

Here is the call graph for this function:

Definition at line 221 of file jvmmgr.cpp.

{
    nsIJVMPrefsWindow* prefsWin = GetPrefsWindow();
    if (prefsWin) {
        prefsWin->Show();
        prefsWin->Release();
    }
}

Here is the call graph for this function:

Definition at line 91 of file jvmmgr.cpp.

{
    nsJVMStatus status = nsJVMStatus_Failed;
    nsresult rv;
    nsCOMPtr<nsIJVMManager> managerService = do_GetService(kJVMManagerCID, &rv);
    if (NS_FAILED(rv)) return status;
    nsJVMManager* mgr = (nsJVMManager *)managerService.get();  
    if (mgr) {
        status = mgr->ShutdownJVM();
    }
    return status;
}

Here is the call graph for this function:

JVM_SpendTime ( PRUint32  timeMillis)

Definition at line 307 of file jvmmgr.cpp.

{
#ifdef XP_MAC
       nsresult result = NS_ERROR_NOT_INITIALIZED;
    nsIJVMPlugin* jvm = GetRunningJVM();
    if (jvm != NULL)
              result = jvm->SpendTime(timeMillis);
       return result;
#else
       return NS_ERROR_NOT_IMPLEMENTED;
#endif
}

Here is the call graph for this function:

Definition at line 262 of file jvmmgr.cpp.

{
    nsIJVMPlugin* jvm = GetRunningJVM();
    if (jvm) {
        nsISymantecDebugger* debugger;
        if (jvm->QueryInterface(kISymantecDebuggerIID, (void**)&debugger) == NS_OK) {
            // XXX should we make sure the vm is started first?
            debugger->StartDebugger(nsSymantecDebugPort_SharedMemory);
            debugger->Release();
        }
        // jvm->Release(); // GetRunningJVM no longer calls AddRef
    }
}

Here is the call graph for this function:

Definition at line 84 of file jvmmgr.cpp.

Here is the call graph for this function:

static NS_DEFINE_CID ( kJVMManagerCID  ,
NS_JVMMANAGER_CID   
) [static]
static NS_DEFINE_IID ( kIJVMConsoleIID  ,
NS_IJVMCONSOLE_IID   
) [static]
static NS_DEFINE_IID ( kIJVMPrefsWindowIID  ,
NS_IJVMPREFSWINDOW_IID   
) [static]
static NS_DEFINE_IID ( kISymantecDebuggerIID  ,
NS_ISYMANTECDEBUGGER_IID   
) [static]