VirtualBox

Ignore:
Timestamp:
Nov 8, 2023 5:23:58 PM (15 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160085
Message:

libs/xpcom: Cleanup nsComponentManager.cpp, convert from PR_LOG to IPRT's logging infrastructure, bugref:10545

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/components/nsComponentManager.cpp

    r101907 r101988  
    8787#include NEW_H     // for placement new
    8888
    89 
    90 #ifdef XP_BEOS
    91 #include <FindDirectory.h>
    92 #include <Path.h>
    93 #endif
    94 
    95 #include "prlog.h"
    96 
    97 PRLogModuleInfo* nsComponentManagerLog = nsnull;
    98 
    99 #if 0 || defined (DEBUG_timeless)
    100  #define SHOW_DENIED_ON_SHUTDOWN
    101  #define SHOW_CI_ON_EXISTING_SERVICE
    102  #define XPCOM_CHECK_PENDING_CIDS
    103 #endif
     89#include <iprt/assert.h>
     90#include <VBox/log.h>
    10491
    10592// Loader Types
     
    715702nsresult nsComponentManagerImpl::Init(void)
    716703{
    717     PR_ASSERT(mShuttingDown != NS_SHUTDOWN_INPROGRESS);
     704    Assert(mShuttingDown != NS_SHUTDOWN_INPROGRESS);
    718705    if (mShuttingDown == NS_SHUTDOWN_INPROGRESS)
    719706        return NS_ERROR_FAILURE;
    720707
    721708    mShuttingDown = NS_SHUTDOWN_NEVERHAPPENED;
    722 
    723     if (nsComponentManagerLog == nsnull)
    724     {
    725         nsComponentManagerLog = PR_NewLogModule("nsComponentManager");
    726     }
    727709
    728710    // Initialize our arena
     
    837819    }
    838820
    839     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
    840            ("nsComponentManager: Initialized."));
    841 
     821    Log(("nsComponentManager: Initialized.\n"));
    842822    return NS_OK;
    843823}
     
    851831nsresult nsComponentManagerImpl::Shutdown(void)
    852832{
    853     PR_ASSERT(mShuttingDown == NS_SHUTDOWN_NEVERHAPPENED);
     833    Assert(mShuttingDown == NS_SHUTDOWN_NEVERHAPPENED);
    854834    if (mShuttingDown != NS_SHUTDOWN_NEVERHAPPENED)
    855835        return NS_ERROR_FAILURE;
     
    858838
    859839    // Shutdown the component manager
    860     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning Shutdown."));
     840    Log(("nsComponentManager: Beginning Shutdown.\n"));
    861841
    862842    PRInt32 i;
     
    866846        nsresult rv = WritePersistentRegistry();
    867847        if (NS_FAILED(rv)) {
    868             PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, ("nsComponentManager: Could not write out perisistant registry."));
    869 #ifdef DEBUG
    870             printf("Could not write out perisistant registry!\n");
    871 #endif
     848            Log(("nsComponentManager: Could not write out perisistant registry.\n"));
    872849        }
    873850    }
     
    910887    mShuttingDown = NS_SHUTDOWN_COMPLETE;
    911888
    912     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Shutdown complete."));
    913 
     889    Log(("nsComponentManager: Shutdown complete.\n"));
    914890    return NS_OK;
    915891}
     
    917893nsComponentManagerImpl::~nsComponentManagerImpl()
    918894{
    919     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning destruction."));
    920 
     895    Log(("nsComponentManager: Beginning destruction.\n"));
    921896    if (mShuttingDown != NS_SHUTDOWN_COMPLETE)
    922897        Shutdown();
     
    925900        nsAutoMonitor::DestroyMonitor(mMon);
    926901    }
    927     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Destroyed."));
     902    Log(("nsComponentManager: Destroyed.\n"));
    928903}
    929904
     
    15561531    rv = aEntry->GetFactory(aFactory, this);
    15571532    if (NS_FAILED(rv)) {
    1558         PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    1559                ("nsComponentManager: FAILED to load factory from %s (%s)\n",
    1560                 (const char *)aEntry->mLocation, mLoaderData[aEntry->mTypeIndex].type));
     1533        Log(("nsComponentManager: FAILED to load factory from %s (%s)\n",
     1534             (const char *)aEntry->mLocation, mLoaderData[aEntry->mTypeIndex].type));
    15611535        return rv;
    15621536    }
     
    16221596                                    nsIFactory **aFactory)
    16231597{
    1624     PR_ASSERT(aFactory != nsnull);
     1598    Assert(aFactory != nsnull);
    16251599
    16261600    nsFactoryEntry *entry = GetFactoryEntry(aClass);
     
    16381612                                    nsIFactory **aFactory)
    16391613{
    1640     PR_ASSERT(aFactory != nsnull);
     1614    Assert(aFactory != nsnull);
    16411615
    16421616    nsFactoryEntry *entry = GetFactoryEntry(contractID, aContractIDLen);
     
    16621636    nsCOMPtr<nsIFactory> factory;
    16631637
    1664 #ifdef PR_LOGGING
    1665     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_DEBUG))
    1666     {
    1667         char *buf = aClass.ToString();
    1668         PR_LogPrint("nsComponentManager: GetClassObject(%s)", buf);
    1669         if (buf)
    1670             PR_Free(buf);
    1671     }
     1638#ifdef LOG_ENABLED
     1639    char *buf = aClass.ToString();
     1640    LogFlow(("nsComponentManager: GetClassObject(%s)", buf));
     1641    if (buf)
     1642        PR_Free(buf);
    16721643#endif
    16731644
    1674     PR_ASSERT(aResult != nsnull);
     1645    Assert(aResult != nsnull);
    16751646
    16761647    rv = FindFactory(aClass, getter_AddRefs(factory));
     
    16791650    rv = factory->QueryInterface(aIID, aResult);
    16801651
    1681     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    1682            ("\t\tGetClassObject() %s", NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    1683 
     1652    Log(("\t\tGetClassObject() %s", NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    16841653    return rv;
    16851654}
     
    16951664    nsCOMPtr<nsIFactory> factory;
    16961665
    1697 #ifdef PR_LOGGING
    1698     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_DEBUG))
    1699     {
    1700         PR_LogPrint("nsComponentManager: GetClassObject(%s)", contractID);
    1701     }
    1702 #endif
    1703 
    1704     PR_ASSERT(aResult != nsnull);
     1666    Log(("nsComponentManager: GetClassObject(%s)", contractID));
     1667    Assert(aResult != nsnull);
    17051668
    17061669    rv = FindFactory(contractID, strlen(contractID), getter_AddRefs(factory));
     
    17091672    rv = factory->QueryInterface(aIID, aResult);
    17101673
    1711     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    1712            ("\t\tGetClassObject() %s", NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    1713 
     1674    Log(("\t\tGetClassObject() %s", NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    17141675    return rv;
    17151676}
     
    17391700        rv = NS_OK;
    17401701    }
    1741 #ifdef PR_LOGGING
    1742     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING)) {
    1743         char *buf = 0;
    1744         if (NS_SUCCEEDED(rv))
    1745             buf = aClass->ToString();
    1746         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    1747                ("nsComponentManager: ContractIDToClassID(%s)->%s", aContractID,
    1748                 NS_SUCCEEDED(rv) ? buf : "[FAILED]"));
    1749         if (buf)
    1750             PR_Free(buf);
    1751     }
     1702#ifdef LOG_ENABLED
     1703    char *buf = 0;
     1704    if (NS_SUCCEEDED(rv))
     1705        buf = aClass->ToString();
     1706    Log(("nsComponentManager: ContractIDToClassID(%s)->%s", aContractID,
     1707         NS_SUCCEEDED(rv) ? buf : "[FAILED]"));
     1708    if (buf)
     1709        PR_Free(buf);
    17521710#endif
    17531711    return rv;
     
    17701728
    17711729    nsresult rv = NS_ERROR_FACTORY_NOT_REGISTERED;
    1772 #ifdef PR_LOGGING
    1773     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
    1774     {
    1775         char *buf = aClass.ToString();
    1776         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    1777                ("nsComponentManager: CLSIDToContractID(%s)->%s", buf,
    1778                 NS_SUCCEEDED(rv) ? *aContractID : "[FAILED]"));
    1779         if (buf)
    1780             PR_Free(buf);
    1781     }
     1730
     1731#ifdef LOG_ENABLED
     1732    char *buf = aClass.ToString();
     1733    Log(("nsComponentManager: CLSIDToContractID(%s)->%s", buf,
     1734         NS_SUCCEEDED(rv) ? *aContractID : "[FAILED]"));
     1735    if (buf)
     1736        PR_Free(buf);
    17821737#endif
    17831738    return rv;
     
    18821837    }
    18831838
    1884 #ifdef PR_LOGGING
    1885     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
    1886     {
    1887         char *buf = aClass.ToString();
    1888         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    1889                ("nsComponentManager: CreateInstance(%s) %s", buf,
    1890                 NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    1891         if (buf)
    1892             PR_Free(buf);
    1893     }
     1839#ifdef LOG_ENABLED
     1840    char *buf = aClass.ToString();
     1841    Log(("nsComponentManager: CreateInstance(%s) %s", buf,
     1842         NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
     1843    if (buf)
     1844        PR_Free(buf);
    18941845#endif
    18951846
     
    19651916    }
    19661917
    1967     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    1968            ("nsComponentManager: CreateInstanceByContractID(%s) %s", aContractID,
    1969             NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    1970 
     1918    Log(("nsComponentManager: CreateInstanceByContractID(%s) %s", aContractID,
     1919         NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    19711920    return rv;
    19721921}
     
    24642413    registryName[registryNameLen] = '\0';
    24652414    *regName = registryName;
    2466 
    2467 #ifdef DEBUG_shaver_off
    2468     fprintf(stderr, "MakeRegistryName(%s, %s, &[%s])\n",
    2469             aDllName, prefix, *regName);
    2470 #endif
    24712415
    24722416    return NS_OK;
     
    26042548{
    26052549    nsAutoMonitor mon(mMon);
    2606 #ifdef PR_LOGGING
    2607     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
    2608     {
    2609         char *buf = aClass.ToString();
    2610         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    2611                ("nsComponentManager: RegisterFactory(%s, %s)", buf,
    2612                 (aContractID ? aContractID : "(null)")));
    2613         if (buf)
    2614             PR_Free(buf);
    2615     }
     2550#ifdef LOG_ENABLED
     2551    char *buf = aClass.ToString();
     2552    Log(("nsComponentManager: RegisterFactory(%s, %s)", buf,
     2553         (aContractID ? aContractID : "(null)")));
     2554    if (buf)
     2555        PR_Free(buf);
    26162556#endif
    26172557    nsFactoryEntry *entry = nsnull;
     
    26322572    {
    26332573        // Already registered
    2634         PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    2635                ("\t\tFactory already registered."));
     2574        Log(("\t\tFactory already registered."));
    26362575        return NS_ERROR_FACTORY_EXISTS;
    26372576    }
     
    26532592        nsresult rv = HashContractID(aContractID, strlen(aContractID), entry);
    26542593        if (NS_FAILED(rv)) {
    2655             PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    2656                    ("\t\tFactory register succeeded. "
    2657                     "Hashing contractid (%s) FAILED.", aContractID));
     2594            Log(("\t\tFactory register succeeded. "
     2595                 "Hashing contractid (%s) FAILED.", aContractID));
    26582596            return rv;
    26592597        }
    26602598    }
    26612599
    2662     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    2663            ("\t\tFactory register succeeded contractid=%s.",
    2664             aContractID ? aContractID : "<none>"));
    2665 
     2600    Log(("\t\tFactory register succeeded contractid=%s.",
     2601          aContractID ? aContractID : "<none>"));
    26662602    return NS_OK;
    26672603}
     
    27682704    const char *contractID = (aContractID && *aContractID) ? aContractID : nsnull;
    27692705    const char *className = (aClassName && *aClassName) ? aClassName : nsnull;
    2770 #ifdef PR_LOGGING
    2771     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
    2772     {
    2773         char *buf = aClass.ToString();
    2774         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    2775                ("nsComponentManager: RegisterComponentCommon(%s, %s, %s, %s)",
    2776                 buf,
    2777                 contractID ? contractID : "(null)",
    2778                 aRegistryName, aType));
    2779         if (buf)
    2780             PR_Free(buf);
    2781     }
     2706#ifdef LOG_ENABLED
     2707    char *buf = aClass.ToString();
     2708    Log(("nsComponentManager: RegisterComponentCommon(%s, %s, %s, %s)",
     2709         buf, contractID ? contractID : "(null)",
     2710         aRegistryName, aType));
     2711    if (buf)
     2712        PR_Free(buf);
    27822713#endif
    27832714    if (entry && !aReplace) {
    2784         PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    2785                ("\t\tFactory already registered."));
     2715        Log(("\t\tFactory already registered."));
    27862716        return NS_ERROR_FACTORY_EXISTS;
    27872717    }
     
    27922722    nsresult rv = GetLoaderForType(typeIndex, getter_AddRefs(loader));
    27932723    if (NS_FAILED(rv)) {
    2794         PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    2795                ("\t\tgetting loader for %s FAILED\n", aType));
     2724        Log(("\t\tgetting loader for %s FAILED\n", aType));
    27962725        return rv;
    27972726    }
     
    28302759        rv = HashContractID(contractID, aContractIDLen, entry);
    28312760        if (NS_FAILED(rv)) {
    2832             PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    2833                    ("\t\tHashContractID(%s) FAILED\n", contractID));
     2761            Log(("\t\tHashContractID(%s) FAILED\n", contractID));
    28342762            return rv;
    28352763        }
     
    29822910                                          nsIFactory *aFactory)
    29832911{
    2984 #ifdef PR_LOGGING
    2985     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
    2986     {
    2987         char *buf = aClass.ToString();
    2988         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    2989                ("nsComponentManager: UnregisterFactory(%s)", buf));
    2990         if (buf)
    2991             PR_Free(buf);
    2992     }
     2912#ifdef LOG_ENABLED
     2913    char *buf = aClass.ToString();
     2914    Log(("nsComponentManager: UnregisterFactory(%s)", buf));
     2915    if (buf)
     2916        PR_Free(buf);
    29932917#endif
    29942918    nsFactoryEntry *old;
     
    30082932    }
    30092933
    3010     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    3011            ("\t\tUnregisterFactory() %s",
    3012             NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
     2934    Log(("\t\tUnregisterFactory() %s",
     2935         NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"));
    30132936    return rv;
    30142937}
     
    30192942{
    30202943#ifdef PR_LOGGING
    3021     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
    3022     {
    3023         char *buf = aClass.ToString();
    3024         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    3025                ("nsComponentManager: UnregisterComponent(%s)", buf));
    3026         if (buf)
    3027             PR_Free(buf);
    3028     }
     2944    char *buf = aClass.ToString();
     2945    Log(("nsComponentManager: UnregisterComponent(%s)", buf));
     2946    if (buf)
     2947        PR_Free(buf);
    30292948#endif
    30302949
     
    30432962    }
    30442963
    3045     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    3046            ("nsComponentManager: Factory unregister(%s) succeeded.", registryName));
    3047 
     2964    Log(("nsComponentManager: Factory unregister(%s) succeeded.", registryName));
    30482965    return NS_OK;
    30492966}
     
    30742991    nsAutoMonitor mon(mMon);
    30752992
    3076     PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    3077            ("nsComponentManager: Unloading Libraries."));
     2993    Log(("nsComponentManager: Unloading Libraries."));
    30782994
    30792995    // UnloadAll the loaders
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette