vbox的更動 38276 路徑 trunk/src/libs/xpcom18a4/xpcom
- 時間撮記:
- 2011-8-2 上午11:27:41 (13 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/libs/xpcom18a4/xpcom/components/nsNativeComponentLoader.cpp
r1 r38276 81 81 mCompMgr(nsnull), 82 82 mLoadedDependentLibs(16, PR_TRUE), 83 mDllStore(nsnull, nsnull, DLLStore_Destroy, 83 mDllStore(nsnull, nsnull, DLLStore_Destroy, 84 84 nsnull, 256, PR_TRUE) 85 85 { 86 86 } 87 87 88 NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader, 88 NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader, 89 89 nsIComponentLoader, 90 90 nsINativeComponentLoader) … … 100 100 if (!_retval) 101 101 return NS_ERROR_NULL_POINTER; 102 102 103 103 /* use a hashtable of WeakRefs to store the factory object? */ 104 104 … … 125 125 PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, 126 126 ("nsNativeComponentLoader: load FAILED")); 127 127 128 128 char errorMsg[1024] = "<unknown; can't get error from NSPR>"; 129 129 … … 142 142 if (NS_FAILED(rv)) 143 143 return rv; // XXX translate error code? 144 144 145 145 rv = GetFactoryFromModule(dll, aCID, _retval); 146 146 … … 159 159 // this is ok to limp along. 160 160 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Factory creation failed"); 161 161 162 162 return rv; 163 163 } … … 216 216 nsCOMPtr<nsISimpleEnumerator> dirIterator; 217 217 rv = dir->GetDirectoryEntries(getter_AddRefs(dirIterator)); 218 218 219 219 if (NS_FAILED(rv)) return rv; 220 220 221 221 // whip through the directory to register every file 222 222 nsCOMPtr<nsIFile> dirEntry; … … 236 236 { 237 237 // 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); 239 246 } 240 247 else … … 249 256 if (NS_FAILED(rv)) return rv; 250 257 } 251 258 252 259 return rv; 253 260 } … … 289 296 dll->Shutdown(); 290 297 } 291 298 292 299 // Check error status on CanUnload() call 293 300 if (NS_FAILED(rv)) … … 312 319 dll->GetDisplayPath(displayPath); 313 320 314 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 321 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 315 322 ("nsNativeComponentLoader: + Unloading \"%s\".", displayPath.get())); 316 323 #endif … … 339 346 dll->GetDisplayPath(displayPath); 340 347 341 PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, 348 PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, 342 349 ("nsNativeComponentLoader: NOT ready for unload %s", displayPath.get())); 343 350 #endif … … 354 361 355 362 static PRBool PR_CALLBACK 356 nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) 363 nsFreeLibraryEnum(nsHashKey *aKey, void *aData, void* closure) 357 364 { 358 365 nsDll *dll = (nsDll *) aData; … … 399 406 nsXPIDLCString displayPath; 400 407 dll->GetDisplayPath(displayPath); 401 408 402 409 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 403 410 ("nsNativeComponentLoader: Loaded \"%s\".", displayPath.get())); … … 420 427 nsresult res2 = dll->GetDllSpec(getter_AddRefs(fs)); // don't change 'res2' -- see warning, above 421 428 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 423 430 // any optional data that this file may have had. 424 431 AddDependentLibrary(fs, nsnull); … … 434 441 nsXPIDLCString displayPath; 435 442 dll->GetDisplayPath(displayPath); 436 PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 443 PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 437 444 ("nsNativeComponentLoader: dll->GetDllSpec() on %s FAILED.", 438 445 displayPath.get())); … … 450 457 if (!fs) 451 458 return res; 452 459 453 460 fs->GetLastModifiedTime(&modTime); 454 461 nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr); 455 462 if (!manager) 456 463 return NS_ERROR_FAILURE; 457 464 458 465 nsCOMPtr<nsIFile> fs; 459 466 res = dll->GetDllSpec(getter_AddRefs(fs)); 460 467 if (NS_FAILED(res)) return res; 461 468 462 469 manager->SaveFileInfo(fs, registryLocation, modTime); 463 470 } … … 474 481 #endif 475 482 476 nsresult 477 nsNativeComponentLoader::DumpLoadError(nsDll *dll, 483 nsresult 484 nsNativeComponentLoader::DumpLoadError(nsDll *dll, 478 485 const char *aCallerName, 479 486 const char *aNsprErrorMsg) 480 487 { 481 488 PR_ASSERT(aCallerName != NULL); 482 489 483 490 if (nsnull == dll || nsnull == aNsprErrorMsg) 484 491 return NS_OK; … … 489 496 // Demangle undefined symbols 490 497 nsCAutoString undefinedMagicString("undefined symbol:"); 491 498 492 499 PRInt32 offset = errorMsg.Find(undefinedMagicString, PR_TRUE); 493 500 494 501 if (offset != kNotFound) 495 502 { 496 503 nsCAutoString symbol(errorMsg); 497 504 nsCAutoString demangledSymbol; 498 505 499 506 symbol.Cut(0,offset); 500 507 501 508 symbol.Cut(0,undefinedMagicString.Length()); 502 509 503 510 symbol.StripWhitespace(); 504 511 505 512 char demangled[4096] = "\0"; 506 513 507 514 nsTraceRefcntImpl::DemangleSymbol(symbol.get(),demangled,sizeof(demangled)); 508 515 509 516 if (demangled && *demangled != '\0') 510 517 demangledSymbol = demangled; 511 518 512 519 if (!demangledSymbol.IsEmpty()) 513 520 { 514 521 nsCAutoString tmp(errorMsg); 515 516 522 523 517 524 tmp.Cut(offset + undefinedMagicString.Length(), 518 525 tmp.Length() - offset - undefinedMagicString.Length()); 519 526 520 527 tmp += " \n"; 521 528 522 529 tmp += demangledSymbol; 523 530 524 531 errorMsg = tmp; 525 } 532 } 526 533 } 527 534 #endif // MOZ_DEMANGLE_SYMBOLS … … 530 537 531 538 #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", 534 541 aCallerName, 535 displayPath.get(), 542 displayPath.get(), 536 543 errorMsg.get()); 537 544 #endif … … 540 547 #ifdef PR_LOGGING 541 548 PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, 542 ("nsNativeComponentLoader: %s(%s) Load FAILED with error: %s", 549 ("nsNativeComponentLoader: %s(%s) Load FAILED with error: %s", 543 550 aCallerName, 544 displayPath.get(), 551 displayPath.get(), 545 552 errorMsg.get())); 546 553 #endif … … 561 568 return(NS_ERROR_FAILURE); 562 569 } 563 570 564 571 // Tell the module to self register 565 572 nsCOMPtr<nsIModule> mobj; … … 571 578 dll->GetDisplayPath(displayPath); 572 579 573 PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 580 PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, 574 581 ("nsNativeComponentLoader: %s using nsIModule to unregister self.", displayPath.get())); 575 582 #endif … … 579 586 // Get registry location for spec 580 587 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 583 590 // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. 584 591 nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &res); … … 603 610 604 611 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 606 613 // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. 607 614 nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv); … … 612 619 613 620 // Notify observers, if any, of autoregistration work 614 nsCOMPtr<nsIObserverService> observerService = 621 nsCOMPtr<nsIObserverService> observerService = 615 622 do_GetService("@mozilla.org/observer-service;1", &rv); 616 623 if (NS_SUCCEEDED(rv)) … … 647 654 nsCStringKey key(persistentDescriptor); 648 655 mDllStore.RemoveAndDelete(&key); 649 656 650 657 nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr); 651 658 NS_ASSERTION(manager, "Something is terribly wrong"); … … 704 711 #if defined(XP_MAC) // sdagley dougt fix 705 712 // rjc - on Mac, check the file's type code (skip checking the creator code) 706 713 707 714 nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface(component); 708 715 if (localFileMac) … … 727 734 { 728 735 int extlen = PL_strlen(ValidDllExtensions[i]); 729 736 730 737 // Does fullname end with this extension 731 738 if (flen >= extlen && … … 738 745 } 739 746 #endif 740 747 741 748 if (validExtension == PR_FALSE) 742 749 // Skip invalid extensions … … 744 751 745 752 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 747 754 // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. 748 755 nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv); 749 756 if (obsoleteManager) 750 rv = obsoleteManager->RegistryLocationForSpec(component, 757 rv = obsoleteManager->RegistryLocationForSpec(component, 751 758 getter_Copies(persistentDescriptor)); 752 759 if (NS_FAILED(rv)) … … 769 776 nsXPIDLCString displayPath; 770 777 dll->GetDisplayPath(displayPath); 771 778 772 779 // Dll hasn't changed. Skip. 773 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 780 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 774 781 ("nsNativeComponentLoader: + nsDll not changed \"%s\". Skipping...", 775 782 displayPath.get())); … … 784 791 785 792 // Notify observers, if any, of autoregistration work 786 nsCOMPtr<nsIObserverService> observerService = 793 nsCOMPtr<nsIObserverService> observerService = 787 794 do_GetService("@mozilla.org/observer-service;1", &rv); 788 795 if (NS_SUCCEEDED(rv)) … … 795 802 // don't have string bundles yet. 796 803 NS_ConvertASCIItoUCS2 fileName("(no name)"); 797 804 798 805 // get the file name 799 806 nsCOMPtr<nsIFile> dllSpec; … … 802 809 dllSpec->GetLeafName(fileName); 803 810 } 804 811 805 812 // this string can't come from a string bundle, because we 806 813 // don't have string bundles yet. … … 819 826 nsCOMPtr<nsIServiceManager> serviceMgr; 820 827 rv = NS_GetServiceManager(getter_AddRefs(serviceMgr)); 821 828 822 829 rv = nsFreeLibrary(dll, serviceMgr, when); 823 830 if (NS_FAILED(rv)) … … 829 836 nsXPIDLCString displayPath; 830 837 dll->GetDisplayPath(displayPath); 831 838 832 839 PR_LOG(nsComponentManagerLog, PR_LOG_WARNING, 833 840 ("nsNativeComponentLoader: *** Dll already loaded. " … … 844 851 nsXPIDLCString displayPath; 845 852 dll->GetDisplayPath(displayPath); 846 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 853 PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, 847 854 ("nsNativeComponentLoader: + Unloading \"%s\". (no CanUnloadProc).", 848 855 displayPath.get())); 849 856 #endif 850 857 } 851 858 852 859 } // dll isloaded 853 860 854 861 // Sanity. 855 862 if (dll->IsLoaded()) … … 879 886 mDllStore.Put(&key, (void *) dll); 880 887 } // dll == NULL 881 888 882 889 // Either we are seeing the dll for the first time or the dll has 883 890 // changed since we last saw it and it is unloaded successfully. 884 891 // 885 // Now we can try register the dll for sure. 892 // Now we can try register the dll for sure. 886 893 nsresult res = SelfRegisterDll(dll, persistentDescriptor, PR_FALSE); 887 894 if (NS_FAILED(res)) … … 926 933 PRBool *aRegistered) 927 934 { 928 #ifdef DEBUG 935 #ifdef DEBUG 929 936 fprintf(stderr, "nNCL: registering deferred (%d)\n", 930 937 mDeferredComponents.Count()); … … 933 940 if (!mDeferredComponents.Count()) 934 941 return NS_OK; 935 942 936 943 for (int i = mDeferredComponents.Count() - 1; i >= 0; i--) { 937 944 nsDll *dll = NS_STATIC_CAST(nsDll *, mDeferredComponents[i]); … … 960 967 nsNativeComponentLoader::OnRegister(const nsIID &aCID, const char *aType, 961 968 const char *aClassName, 962 const char *aContractID, 969 const char *aContractID, 963 970 const char *aLocation, 964 PRBool aReplace, 971 PRBool aReplace, 965 972 PRBool aPersist) 966 973 { … … 1001 1008 // {NULL, rel:libpref.so, 8985659, 20987} 1002 1009 nsresult 1003 nsNativeComponentLoader::CreateDll(nsIFile *aSpec, 1010 nsNativeComponentLoader::CreateDll(nsIFile *aSpec, 1004 1011 const char *aLocation, 1005 1012 nsDll **aDll) … … 1020 1027 if (!aSpec) 1021 1028 { 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 1023 1030 // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. 1024 1031 nsCOMPtr<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv); … … 1067 1074 { 1068 1075 nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr); 1069 if (!manager) 1076 if (!manager) 1070 1077 { 1071 1078 NS_WARNING("Something is terribly wrong"); … … 1074 1081 1075 1082 // 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 1077 1084 // names 1078 1085 1079 if (!libName) 1086 if (!libName) 1080 1087 { 1081 1088 manager->SetOptionalData(aFile, nsnull, nsnull); … … 1090 1097 1091 1098 data.Append(nsDependentCString(libName)); 1092 1099 1093 1100 manager->SetOptionalData(aFile, nsnull, data); 1094 1101 return NS_OK;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器