Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsDll Class Reference

#include <xcDll.h>

Collaboration diagram for nsDll:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsDll (nsIFile *dllSpec, nsNativeComponentLoader *loader)
 ~nsDll (void)
PRBool Load (void)
PRBool Unload (void)
PRBool IsLoaded (void)
void MarkForUnload (PRBool mark)
PRBool IsMarkedForUnload (void)
nsresult Shutdown (void)
voidFindSymbol (const char *symbol)
PRBool HasChanged (void)
void GetDisplayPath (nsACString &string)
PRLibraryGetInstance (void)
nsresult GetDllSpec (nsIFile **dllSpec)
nsresult GetModule (nsISupports *servMgr, nsIModule **mobj)

Private Member Functions

void Init (nsIFile *dllSpec)

Private Attributes

nsCOMPtr< nsIFilem_dllSpec
PRLibrarym_instance
nsIModulem_moduleObject
nsNativeComponentLoaderm_loader
PRBool m_markForUnload

Detailed Description

Definition at line 74 of file xcDll.h.


Constructor & Destructor Documentation

nsDll::nsDll ( nsIFile dllSpec,
nsNativeComponentLoader loader 
)

Definition at line 77 of file xcDll.cpp.

    : m_dllSpec(do_QueryInterface(dllSpec)),
      m_instance(NULL), 
      m_moduleObject(NULL),
      m_loader(loader),
      m_markForUnload(PR_FALSE)
{
    NS_ASSERTION(loader, "Null loader when creating a nsDLL");
}

Definition at line 87 of file xcDll.cpp.

{
    //#if DEBUG_dougt
    // The dll gets deleted when the dllStore is destroyed. This happens on
    // app shutdown. At that point, unloading dlls can cause crashes if we have
    // - dll dependencies
    // - callbacks
    // - static dtors
    // Hence turn it back on after all the above have been removed.
    //Unload();
    //#endif
}

Member Function Documentation

void * nsDll::FindSymbol ( const char *  symbol)

Definition at line 194 of file xcDll.cpp.

{
       if (symbol == NULL)
              return (NULL);
       
       // If not already loaded, load it now.
       if (Load() != PR_TRUE)
              return (NULL);

    return(PR_FindSymbol(m_instance, symbol));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDll::GetDisplayPath ( nsACString &  string)

Definition at line 101 of file xcDll.cpp.

{
    m_dllSpec->GetNativeLeafName(aLeafName);
    
    if (aLeafName.IsEmpty())
        aLeafName.AssignLiteral("unknown!");
}

Here is the caller graph for this function:

Definition at line 208 of file xcDll.cpp.

{
    NS_ASSERTION(m_dllSpec, "m_dllSpec NULL");
    NS_ASSERTION(fsobj, "xcDll::GetModule : Null argument" );

    *fsobj = m_dllSpec;
    NS_ADDREF(*fsobj);
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 114 of file xcDll.h.

{ return (m_instance); }
nsresult nsDll::GetModule ( nsISupports *  servMgr,
nsIModule **  mobj 
)

Definition at line 218 of file xcDll.cpp.

{
    // using the backpointer of the loader.
    nsIComponentManager* compMgr = m_loader->mCompMgr;
    NS_ASSERTION(compMgr, "Global Component Manager is null" );
    if (!compMgr) return NS_ERROR_UNEXPECTED;

    NS_ASSERTION(cobj, "xcDll::GetModule : Null argument" );

    if (m_moduleObject)
    {
        NS_ADDREF(m_moduleObject);
        *cobj = m_moduleObject;
        return NS_OK;
    }

       // If not already loaded, load it now.
       if (Load() != PR_TRUE) return NS_ERROR_FAILURE;

    // We need a nsIFile for location
    if (!m_dllSpec)
    {
        return NS_ERROR_FAILURE;
    }

    nsGetModuleProc proc =
      (nsGetModuleProc) FindSymbol(NS_GET_MODULE_SYMBOL);

    if (proc == NULL)
        return NS_ERROR_FACTORY_NOT_LOADED;

    nsresult rv = (*proc) (compMgr, m_dllSpec, &m_moduleObject);
    if (NS_SUCCEEDED(rv))
    {
        NS_ADDREF(m_moduleObject);
        *cobj = m_moduleObject;
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file xcDll.cpp.

{
    nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(m_loader->mCompMgr);
    if (!manager)
        return PR_TRUE;

    // If mod date has changed, then dll has changed
    PRInt64 currentDate;
    nsresult rv = m_dllSpec->GetLastModifiedTime(&currentDate);
    if (NS_FAILED(rv))
        return PR_TRUE;
    PRBool changed = PR_TRUE;
    manager->HasFileChanged(m_dllSpec, nsnull, currentDate, &changed); 
    return changed;
}

Here is the call graph for this function:

void nsDll::Init ( nsIFile dllSpec) [private]
PRBool nsDll::IsLoaded ( void  ) [inline]

Definition at line 97 of file xcDll.h.

       {
              return ((m_instance != 0) ? PR_TRUE : PR_FALSE);
       }

Here is the caller graph for this function:

Definition at line 102 of file xcDll.h.

{ return m_markForUnload; }

Here is the caller graph for this function:

Definition at line 126 of file xcDll.cpp.

{
       if (m_instance != NULL)
       {
              // Already loaded
              return (PR_TRUE);
       }

    if (m_dllSpec)
    {
#ifdef NS_BUILD_REFCNT_LOGGING
        nsTraceRefcntImpl::SetActivityIsLegal(PR_FALSE);
#endif
        
    // load the component
    nsCOMPtr<nsILocalFile> lf(do_QueryInterface(m_dllSpec));
    NS_ASSERTION(lf, "nsIFile here must implement a nsILocalFile"); 
    lf->Load(&m_instance);

#ifdef NS_BUILD_REFCNT_LOGGING
        nsTraceRefcntImpl::SetActivityIsLegal(PR_TRUE);
        if (m_instance) {
            // Inform refcnt tracer of new library so that calls through the
            // new library can be traced.
            nsXPIDLCString displayPath;
            GetDisplayPath(displayPath);
            nsTraceRefcntImpl::LoadLibrarySymbols(displayPath.get(), m_instance);
        }
#endif
    }

#ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD
    // Debugging help for components. Component dlls need to have their
    // symbols loaded before we can put a breakpoint in the debugger.
    // This will help figureing out the point when the dll was loaded.
    nsXPIDLCString displayPath;
    GetDisplayPath(displayPath);
    BreakAfterLoad(displayPath.get());
#endif

    return ((m_instance == NULL) ? PR_FALSE : PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsDll::MarkForUnload ( PRBool  mark) [inline]

Definition at line 101 of file xcDll.h.

Here is the caller graph for this function:

Definition at line 265 of file xcDll.cpp.

{
    // Release the module object if we got one
    nsrefcnt refcnt;
    if (m_moduleObject)
    {
        NS_RELEASE2(m_moduleObject, refcnt);
        NS_ASSERTION(refcnt == 0, "Dll moduleObject refcount non zero");
    }
#ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD
    for (int i = 0; i < sBreakListCount; i++)
    {
        delete sBreakList[i];
        sBreakList[i] = nsnull;
    }
    sBreakListCount = 0;
#endif
    return NS_OK;

}

Here is the caller graph for this function:

Definition at line 169 of file xcDll.cpp.

{
       if (m_instance == NULL)
              return (PR_FALSE);

    // Shutdown the dll
    Shutdown();

#ifdef NS_BUILD_REFCNT_LOGGING
    nsTraceRefcntImpl::SetActivityIsLegal(PR_FALSE);
#endif
       PRStatus ret = PR_UnloadLibrary(m_instance);
#ifdef NS_BUILD_REFCNT_LOGGING
    nsTraceRefcntImpl::SetActivityIsLegal(PR_TRUE);
#endif

       if (ret == PR_SUCCESS)
       {
              m_instance = NULL;
              return (PR_TRUE);
       }
       else
              return (PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 77 of file xcDll.h.

Definition at line 78 of file xcDll.h.

Definition at line 80 of file xcDll.h.

Definition at line 81 of file xcDll.h.

Definition at line 79 of file xcDll.h.


The documentation for this class was generated from the following files: