Changeset 101988 in vbox for trunk/src/libs/xpcom18a4/xpcom/components/nsComponentManager.cpp
- Timestamp:
- Nov 8, 2023 5:23:58 PM (15 months ago)
- svn:sync-xref-src-repo-rev:
- 160085
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/components/nsComponentManager.cpp
r101907 r101988 87 87 #include NEW_H // for placement new 88 88 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> 104 91 105 92 // Loader Types … … 715 702 nsresult nsComponentManagerImpl::Init(void) 716 703 { 717 PR_ASSERT(mShuttingDown != NS_SHUTDOWN_INPROGRESS);704 Assert(mShuttingDown != NS_SHUTDOWN_INPROGRESS); 718 705 if (mShuttingDown == NS_SHUTDOWN_INPROGRESS) 719 706 return NS_ERROR_FAILURE; 720 707 721 708 mShuttingDown = NS_SHUTDOWN_NEVERHAPPENED; 722 723 if (nsComponentManagerLog == nsnull)724 {725 nsComponentManagerLog = PR_NewLogModule("nsComponentManager");726 }727 709 728 710 // Initialize our arena … … 837 819 } 838 820 839 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 840 ("nsComponentManager: Initialized.")); 841 821 Log(("nsComponentManager: Initialized.\n")); 842 822 return NS_OK; 843 823 } … … 851 831 nsresult nsComponentManagerImpl::Shutdown(void) 852 832 { 853 PR_ASSERT(mShuttingDown == NS_SHUTDOWN_NEVERHAPPENED);833 Assert(mShuttingDown == NS_SHUTDOWN_NEVERHAPPENED); 854 834 if (mShuttingDown != NS_SHUTDOWN_NEVERHAPPENED) 855 835 return NS_ERROR_FAILURE; … … 858 838 859 839 // Shutdown the component manager 860 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning Shutdown."));840 Log(("nsComponentManager: Beginning Shutdown.\n")); 861 841 862 842 PRInt32 i; … … 866 846 nsresult rv = WritePersistentRegistry(); 867 847 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")); 872 849 } 873 850 } … … 910 887 mShuttingDown = NS_SHUTDOWN_COMPLETE; 911 888 912 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Shutdown complete.")); 913 889 Log(("nsComponentManager: Shutdown complete.\n")); 914 890 return NS_OK; 915 891 } … … 917 893 nsComponentManagerImpl::~nsComponentManagerImpl() 918 894 { 919 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning destruction.")); 920 895 Log(("nsComponentManager: Beginning destruction.\n")); 921 896 if (mShuttingDown != NS_SHUTDOWN_COMPLETE) 922 897 Shutdown(); … … 925 900 nsAutoMonitor::DestroyMonitor(mMon); 926 901 } 927 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Destroyed."));902 Log(("nsComponentManager: Destroyed.\n")); 928 903 } 929 904 … … 1556 1531 rv = aEntry->GetFactory(aFactory, this); 1557 1532 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)); 1561 1535 return rv; 1562 1536 } … … 1622 1596 nsIFactory **aFactory) 1623 1597 { 1624 PR_ASSERT(aFactory != nsnull);1598 Assert(aFactory != nsnull); 1625 1599 1626 1600 nsFactoryEntry *entry = GetFactoryEntry(aClass); … … 1638 1612 nsIFactory **aFactory) 1639 1613 { 1640 PR_ASSERT(aFactory != nsnull);1614 Assert(aFactory != nsnull); 1641 1615 1642 1616 nsFactoryEntry *entry = GetFactoryEntry(contractID, aContractIDLen); … … 1662 1636 nsCOMPtr<nsIFactory> factory; 1663 1637 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); 1672 1643 #endif 1673 1644 1674 PR_ASSERT(aResult != nsnull);1645 Assert(aResult != nsnull); 1675 1646 1676 1647 rv = FindFactory(aClass, getter_AddRefs(factory)); … … 1679 1650 rv = factory->QueryInterface(aIID, aResult); 1680 1651 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")); 1684 1653 return rv; 1685 1654 } … … 1695 1664 nsCOMPtr<nsIFactory> factory; 1696 1665 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); 1705 1668 1706 1669 rv = FindFactory(contractID, strlen(contractID), getter_AddRefs(factory)); … … 1709 1672 rv = factory->QueryInterface(aIID, aResult); 1710 1673 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")); 1714 1675 return rv; 1715 1676 } … … 1739 1700 rv = NS_OK; 1740 1701 } 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); 1752 1710 #endif 1753 1711 return rv; … … 1770 1728 1771 1729 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); 1782 1737 #endif 1783 1738 return rv; … … 1882 1837 } 1883 1838 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); 1894 1845 #endif 1895 1846 … … 1965 1916 } 1966 1917 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")); 1971 1920 return rv; 1972 1921 } … … 2464 2413 registryName[registryNameLen] = '\0'; 2465 2414 *regName = registryName; 2466 2467 #ifdef DEBUG_shaver_off2468 fprintf(stderr, "MakeRegistryName(%s, %s, &[%s])\n",2469 aDllName, prefix, *regName);2470 #endif2471 2415 2472 2416 return NS_OK; … … 2604 2548 { 2605 2549 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); 2616 2556 #endif 2617 2557 nsFactoryEntry *entry = nsnull; … … 2632 2572 { 2633 2573 // Already registered 2634 PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 2635 ("\t\tFactory already registered.")); 2574 Log(("\t\tFactory already registered.")); 2636 2575 return NS_ERROR_FACTORY_EXISTS; 2637 2576 } … … 2653 2592 nsresult rv = HashContractID(aContractID, strlen(aContractID), entry); 2654 2593 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)); 2658 2596 return rv; 2659 2597 } 2660 2598 } 2661 2599 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>")); 2666 2602 return NS_OK; 2667 2603 } … … 2768 2704 const char *contractID = (aContractID && *aContractID) ? aContractID : nsnull; 2769 2705 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); 2782 2713 #endif 2783 2714 if (entry && !aReplace) { 2784 PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 2785 ("\t\tFactory already registered.")); 2715 Log(("\t\tFactory already registered.")); 2786 2716 return NS_ERROR_FACTORY_EXISTS; 2787 2717 } … … 2792 2722 nsresult rv = GetLoaderForType(typeIndex, getter_AddRefs(loader)); 2793 2723 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)); 2796 2725 return rv; 2797 2726 } … … 2830 2759 rv = HashContractID(contractID, aContractIDLen, entry); 2831 2760 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)); 2834 2762 return rv; 2835 2763 } … … 2982 2910 nsIFactory *aFactory) 2983 2911 { 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); 2993 2917 #endif 2994 2918 nsFactoryEntry *old; … … 3008 2932 } 3009 2933 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")); 3013 2936 return rv; 3014 2937 } … … 3019 2942 { 3020 2943 #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); 3029 2948 #endif 3030 2949 … … 3043 2962 } 3044 2963 3045 PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, 3046 ("nsComponentManager: Factory unregister(%s) succeeded.", registryName)); 3047 2964 Log(("nsComponentManager: Factory unregister(%s) succeeded.", registryName)); 3048 2965 return NS_OK; 3049 2966 } … … 3074 2991 nsAutoMonitor mon(mMon); 3075 2992 3076 PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, 3077 ("nsComponentManager: Unloading Libraries.")); 2993 Log(("nsComponentManager: Unloading Libraries.")); 3078 2994 3079 2995 // UnloadAll the loaders
Note:
See TracChangeset
for help on using the changeset viewer.