VirtualBox

vbox的更動 38276 路徑 trunk/src/libs/xpcom18a4/xpcom


忽略:
時間撮記:
2011-8-2 上午11:27:41 (13 年 以前)
作者:
vboxsync
訊息:

nsNativeComponentLoader::RegisterComponentsInDir: Don't go looking for components in debug bundles on the mac.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/libs/xpcom18a4/xpcom/components/nsNativeComponentLoader.cpp

    r1 r38276  
    8181    mCompMgr(nsnull),
    8282    mLoadedDependentLibs(16, PR_TRUE),
    83     mDllStore(nsnull, nsnull, DLLStore_Destroy, 
     83    mDllStore(nsnull, nsnull, DLLStore_Destroy,
    8484              nsnull, 256, PR_TRUE)
    8585{
    8686}
    8787
    88 NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader, 
     88NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader,
    8989                              nsIComponentLoader,
    9090                              nsINativeComponentLoader)
     
    100100    if (!_retval)
    101101        return NS_ERROR_NULL_POINTER;
    102    
     102
    103103    /* use a hashtable of WeakRefs to store the factory object? */
    104104
     
    125125            PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
    126126                   ("nsNativeComponentLoader: load FAILED"));
    127        
     127
    128128            char errorMsg[1024] = "<unknown; can't get error from NSPR>";
    129129
     
    142142    if (NS_FAILED(rv))
    143143        return rv;      // XXX translate error code?
    144    
     144
    145145    rv = GetFactoryFromModule(dll, aCID, _retval);
    146146
     
    159159    // this is ok to limp along.
    160160    NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Factory creation failed");
    161    
     161
    162162    return rv;
    163163}
     
    216216    nsCOMPtr<nsISimpleEnumerator> dirIterator;
    217217    rv = dir->GetDirectoryEntries(getter_AddRefs(dirIterator));
    218    
     218
    219219    if (NS_FAILED(rv)) return rv;
    220    
     220
    221221    // whip through the directory to register every file
    222222    nsCOMPtr<nsIFile> dirEntry;
     
    236236                {
    237237                    // This is a directory. Grovel for components into the directory.
    238                     rv = RegisterComponentsInDir(when, dirEntry);
     238#ifdef RT_OS_DARWIN // But not if it's a debug bundle.
     239                    nsCAutoString leafName;
     240                    rv = dirEntry->GetNativeLeafName(leafName);
     241                    if (   NS_FAILED(rv)
     242                        || leafName.Length() < sizeof(".dSYM")
     243                        || PL_strcasecmp(leafName.get() + (leafName.Length() - sizeof(".dSYM") + 1), ".dSYM"))
     244#endif
     245                        rv = RegisterComponentsInDir(when, dirEntry);
    239246                }
    240247                else
     
    249256        if (NS_FAILED(rv)) return rv;
    250257    }
    251    
     258
    252259    return rv;
    253260}
     
    289296        dll->Shutdown();
    290297    }
    291        
     298
    292299    // Check error status on CanUnload() call
    293300    if (NS_FAILED(rv))
     
    312319            dll->GetDisplayPath(displayPath);
    313320
    314             PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 
     321            PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
    315322                   ("nsNativeComponentLoader: + Unloading \"%s\".", displayPath.get()));
    316323#endif
     
    339346        dll->GetDisplayPath(displayPath);
    340347
    341         PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, 
     348        PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    342349               ("nsNativeComponentLoader: NOT ready for unload %s", displayPath.get()));
    343350#endif
     
    354361
    355362static PRBool PR_CALLBACK
    356 nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) 
     363nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure)
    357364{
    358365    nsDll *dll = (nsDll *) aData;
     
    399406    nsXPIDLCString displayPath;
    400407    dll->GetDisplayPath(displayPath);
    401    
     408
    402409    PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
    403410           ("nsNativeComponentLoader: Loaded \"%s\".", displayPath.get()));
     
    420427        nsresult res2 = dll->GetDllSpec(getter_AddRefs(fs));    // don't change 'res2' -- see warning, above
    421428        if (NS_SUCCEEDED(res2)) {
    422             // in the case of re-registering a component, we want to remove 
     429            // in the case of re-registering a component, we want to remove
    423430            // any optional data that this file may have had.
    424431            AddDependentLibrary(fs, nsnull);
     
    434441            nsXPIDLCString displayPath;
    435442            dll->GetDisplayPath(displayPath);
    436             PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 
     443            PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    437444                   ("nsNativeComponentLoader: dll->GetDllSpec() on %s FAILED.",
    438445                    displayPath.get()));
     
    450457        if (!fs)
    451458            return res;
    452        
     459
    453460        fs->GetLastModifiedTime(&modTime);
    454461        nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr);
    455462        if (!manager)
    456463            return NS_ERROR_FAILURE;
    457        
     464
    458465        nsCOMPtr<nsIFile> fs;
    459466        res = dll->GetDllSpec(getter_AddRefs(fs));
    460467        if (NS_FAILED(res)) return res;
    461        
     468
    462469        manager->SaveFileInfo(fs, registryLocation, modTime);
    463470    }
     
    474481#endif
    475482
    476 nsresult 
    477 nsNativeComponentLoader::DumpLoadError(nsDll *dll, 
     483nsresult
     484nsNativeComponentLoader::DumpLoadError(nsDll *dll,
    478485                                       const char *aCallerName,
    479486                                       const char *aNsprErrorMsg)
    480487{
    481488    PR_ASSERT(aCallerName != NULL);
    482    
     489
    483490    if (nsnull == dll || nsnull == aNsprErrorMsg)
    484491        return NS_OK;
     
    489496    // Demangle undefined symbols
    490497    nsCAutoString undefinedMagicString("undefined symbol:");
    491    
     498
    492499    PRInt32 offset = errorMsg.Find(undefinedMagicString, PR_TRUE);
    493    
     500
    494501    if (offset != kNotFound)
    495502    {
    496503        nsCAutoString symbol(errorMsg);
    497504        nsCAutoString demangledSymbol;
    498        
     505
    499506        symbol.Cut(0,offset);
    500        
     507
    501508        symbol.Cut(0,undefinedMagicString.Length());
    502        
     509
    503510        symbol.StripWhitespace();
    504        
     511
    505512        char demangled[4096] = "\0";
    506        
     513
    507514        nsTraceRefcntImpl::DemangleSymbol(symbol.get(),demangled,sizeof(demangled));
    508        
     515
    509516        if (demangled && *demangled != '\0')
    510517            demangledSymbol = demangled;
    511        
     518
    512519        if (!demangledSymbol.IsEmpty())
    513520        {
    514521            nsCAutoString tmp(errorMsg);
    515            
    516            
     522
     523
    517524            tmp.Cut(offset + undefinedMagicString.Length(),
    518525                    tmp.Length() - offset - undefinedMagicString.Length());
    519            
     526
    520527            tmp += " \n";
    521            
     528
    522529            tmp += demangledSymbol;
    523            
     530
    524531            errorMsg = tmp;
    525         }   
     532        }
    526533    }
    527534#endif // MOZ_DEMANGLE_SYMBOLS
     
    530537
    531538#ifdef DEBUG
    532     fprintf(stderr, 
    533             "nsNativeComponentLoader: %s(%s) Load FAILED with error: %s\n", 
     539    fprintf(stderr,
     540            "nsNativeComponentLoader: %s(%s) Load FAILED with error: %s\n",
    534541            aCallerName,
    535             displayPath.get(), 
     542            displayPath.get(),
    536543            errorMsg.get());
    537544#endif
     
    540547#ifdef PR_LOGGING
    541548    PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
    542            ("nsNativeComponentLoader: %s(%s) Load FAILED with error: %s", 
     549           ("nsNativeComponentLoader: %s(%s) Load FAILED with error: %s",
    543550            aCallerName,
    544             displayPath.get(), 
     551            displayPath.get(),
    545552            errorMsg.get()));
    546553#endif
     
    561568        return(NS_ERROR_FAILURE);
    562569    }
    563        
     570
    564571    // Tell the module to self register
    565572    nsCOMPtr<nsIModule> mobj;
     
    571578        dll->GetDisplayPath(displayPath);
    572579
    573         PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 
     580        PR_LOG(nsComponentManagerLog, PR_LOG_ERROR,
    574581               ("nsNativeComponentLoader: %s using nsIModule to unregister self.", displayPath.get()));
    575582#endif
     
    579586        // Get registry location for spec
    580587        nsXPIDLCString registryName;
    581                
    582         // what I want to do here is QI for a Component Registration Manager.  Since this 
     588
     589        // what I want to do here is QI for a Component Registration Manager.  Since this
    583590        // has not been invented yet, QI to the obsolete manager.  Kids, don't do this at home.
    584591        nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &res);
     
    603610
    604611    nsXPIDLCString persistentDescriptor;
    605     // what I want to do here is QI for a Component Registration Manager.  Since this 
     612    // what I want to do here is QI for a Component Registration Manager.  Since this
    606613    // has not been invented yet, QI to the obsolete manager.  Kids, don't do this at home.
    607614    nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv);
     
    612619
    613620    // Notify observers, if any, of autoregistration work
    614     nsCOMPtr<nsIObserverService> observerService = 
     621    nsCOMPtr<nsIObserverService> observerService =
    615622             do_GetService("@mozilla.org/observer-service;1", &rv);
    616623    if (NS_SUCCEEDED(rv))
     
    647654    nsCStringKey key(persistentDescriptor);
    648655    mDllStore.RemoveAndDelete(&key);
    649    
     656
    650657    nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr);
    651658    NS_ASSERTION(manager, "Something is terribly wrong");
     
    704711#if defined(XP_MAC)  // sdagley dougt fix
    705712    // rjc - on Mac, check the file's type code (skip checking the creator code)
    706    
     713
    707714    nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface(component);
    708715    if (localFileMac)
     
    727734    {
    728735        int extlen = PL_strlen(ValidDllExtensions[i]);
    729            
     736
    730737        // Does fullname end with this extension
    731738        if (flen >= extlen &&
     
    738745    }
    739746#endif
    740        
     747
    741748    if (validExtension == PR_FALSE)
    742749        // Skip invalid extensions
     
    744751
    745752    nsXPIDLCString persistentDescriptor;
    746     // what I want to do here is QI for a Component Registration Manager.  Since this 
     753    // what I want to do here is QI for a Component Registration Manager.  Since this
    747754    // has not been invented yet, QI to the obsolete manager.  Kids, don't do this at home.
    748755    nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv);
    749756    if (obsoleteManager)
    750         rv = obsoleteManager->RegistryLocationForSpec(component, 
     757        rv = obsoleteManager->RegistryLocationForSpec(component,
    751758                                                      getter_Copies(persistentDescriptor));
    752759    if (NS_FAILED(rv))
     
    769776            nsXPIDLCString displayPath;
    770777            dll->GetDisplayPath(displayPath);
    771            
     778
    772779            // Dll hasn't changed. Skip.
    773             PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 
     780            PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
    774781                   ("nsNativeComponentLoader: + nsDll not changed \"%s\". Skipping...",
    775782                    displayPath.get()));
     
    784791
    785792        // Notify observers, if any, of autoregistration work
    786         nsCOMPtr<nsIObserverService> observerService = 
     793        nsCOMPtr<nsIObserverService> observerService =
    787794                 do_GetService("@mozilla.org/observer-service;1", &rv);
    788795        if (NS_SUCCEEDED(rv))
     
    795802            // don't have string bundles yet.
    796803            NS_ConvertASCIItoUCS2 fileName("(no name)");
    797            
     804
    798805            // get the file name
    799806            nsCOMPtr<nsIFile> dllSpec;
     
    802809              dllSpec->GetLeafName(fileName);
    803810            }
    804            
     811
    805812            // this string can't come from a string bundle, because we
    806813            // don't have string bundles yet.
     
    819826            nsCOMPtr<nsIServiceManager> serviceMgr;
    820827            rv = NS_GetServiceManager(getter_AddRefs(serviceMgr));
    821          
     828
    822829            rv = nsFreeLibrary(dll, serviceMgr, when);
    823830            if (NS_FAILED(rv))
     
    829836                nsXPIDLCString displayPath;
    830837                dll->GetDisplayPath(displayPath);
    831                
     838
    832839                PR_LOG(nsComponentManagerLog, PR_LOG_WARNING,
    833840                       ("nsNativeComponentLoader: *** Dll already loaded. "
     
    844851                nsXPIDLCString displayPath;
    845852                dll->GetDisplayPath(displayPath);
    846                 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 
     853                PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
    847854                       ("nsNativeComponentLoader: + Unloading \"%s\". (no CanUnloadProc).",
    848855                        displayPath.get()));
    849856#endif
    850857            }
    851                
     858
    852859        } // dll isloaded
    853            
     860
    854861        // Sanity.
    855862        if (dll->IsLoaded())
     
    879886        mDllStore.Put(&key, (void *) dll);
    880887    } // dll == NULL
    881        
     888
    882889    // Either we are seeing the dll for the first time or the dll has
    883890    // changed since we last saw it and it is unloaded successfully.
    884891    //
    885     // Now we can try register the dll for sure. 
     892    // Now we can try register the dll for sure.
    886893    nsresult res = SelfRegisterDll(dll, persistentDescriptor, PR_FALSE);
    887894    if (NS_FAILED(res))
     
    926933                                                    PRBool *aRegistered)
    927934{
    928 #ifdef DEBUG 
     935#ifdef DEBUG
    929936    fprintf(stderr, "nNCL: registering deferred (%d)\n",
    930937            mDeferredComponents.Count());
     
    933940    if (!mDeferredComponents.Count())
    934941        return NS_OK;
    935    
     942
    936943    for (int i = mDeferredComponents.Count() - 1; i >= 0; i--) {
    937944        nsDll *dll = NS_STATIC_CAST(nsDll *, mDeferredComponents[i]);
     
    960967nsNativeComponentLoader::OnRegister(const nsIID &aCID, const char *aType,
    961968                                    const char *aClassName,
    962                                     const char *aContractID, 
     969                                    const char *aContractID,
    963970                                    const char *aLocation,
    964                                     PRBool aReplace, 
     971                                    PRBool aReplace,
    965972                                    PRBool aPersist)
    966973{
     
    10011008//    {NULL, rel:libpref.so, 8985659, 20987}
    10021009nsresult
    1003 nsNativeComponentLoader::CreateDll(nsIFile *aSpec, 
     1010nsNativeComponentLoader::CreateDll(nsIFile *aSpec,
    10041011                                   const char *aLocation,
    10051012                                   nsDll **aDll)
     
    10201027    if (!aSpec)
    10211028    {
    1022         // what I want to do here is QI for a Component Registration Manager.  Since this 
     1029        // what I want to do here is QI for a Component Registration Manager.  Since this
    10231030        // has not been invented yet, QI to the obsolete manager.  Kids, don't do this at home.
    10241031        nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv);
     
    10671074{
    10681075    nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr);
    1069     if (!manager) 
     1076    if (!manager)
    10701077    {
    10711078        NS_WARNING("Something is terribly wrong");
     
    10741081
    10751082    // the native component loader uses the optional data
    1076     // to store a space delimited list of dependent library 
     1083    // to store a space delimited list of dependent library
    10771084    // names
    10781085
    1079     if (!libName) 
     1086    if (!libName)
    10801087    {
    10811088        manager->SetOptionalData(aFile, nsnull, nsnull);
     
    10901097
    10911098    data.Append(nsDependentCString(libName));
    1092    
     1099
    10931100    manager->SetOptionalData(aFile, nsnull, data);
    10941101    return NS_OK;
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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