Bug 1497707, part 2 - The second argument to nsComponentManagerImpl::RegisterModule is always null. r=froydnj
authorAndrew McCreight <continuation@gmail.com>
Tue, 23 Oct 2018 00:47:24 +0000
changeset 490833 bd13c578aceb65c8af0e760a2279db486b91e578
parent 490832 26d5c8531a081dda749a6ddbcec3cb86fac39c78
child 490834 3db6926e3e4441e726a4163f2a60da58584f76b6
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersfroydnj
bugs1497707
milestone65.0a1
Bug 1497707, part 2 - The second argument to nsComponentManagerImpl::RegisterModule is always null. r=froydnj This allows some code to be deleted, including a KnownModule ctor. Depends on D8168 Differential Revision: https://phabricator.services.mozilla.com/D8169
netwerk/test/gtest/TestPACMan.cpp
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
--- a/netwerk/test/gtest/TestPACMan.cpp
+++ b/netwerk/test/gtest/TestPACMan.cpp
@@ -151,17 +151,17 @@ class TestPACMan : public ::testing::Tes
     {
       ASSERT_EQ(NS_OK, GetNetworkProxyType(&originalNetworkProxyTypePref));
       nsFactoryEntry* factoryEntry = nsComponentManagerImpl::gComponentManager
           ->GetFactoryEntry(kNS_TESTDHCPCLIENTSERVICE_CID);
       if (factoryEntry) {
         nsresult rv = nsComponentManagerImpl::gComponentManager->UnregisterFactory(kNS_TESTDHCPCLIENTSERVICE_CID, factoryEntry->mFactory);
         ASSERT_EQ(NS_OK, rv);
       }
-      nsComponentManagerImpl::gComponentManager->RegisterModule(&kSysDHCPClientModule, nullptr);
+      nsComponentManagerImpl::gComponentManager->RegisterModule(&kSysDHCPClientModule);
 
       mPACMan = new nsPACMan(nullptr);
       mPACMan->SetWPADOverDHCPEnabled(true);
       mPACMan->Init(nullptr);
       ASSERT_EQ(NS_OK, SetNetworkProxyType(WPAD_PREF));
 
     }
 
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -352,27 +352,27 @@ nsComponentManagerImpl::Init()
     GetLocationFromDirectoryService(NS_GRE_DIR);
   nsCOMPtr<nsIFile> appDir =
     GetLocationFromDirectoryService(NS_XPCOM_CURRENT_PROCESS_DIR);
 
   InitializeStaticModules();
 
   nsCategoryManager::GetSingleton()->SuppressNotifications(true);
 
-  RegisterModule(&kXPCOMModule, nullptr);
+  RegisterModule(&kXPCOMModule);
 
   for (auto module : AllStaticModules()) {
     if (module) { // On local Windows builds, the list may contain null
                   // pointers from padding.
-      RegisterModule(module, nullptr);
+      RegisterModule(module);
     }
   }
 
   for (uint32_t i = 0; i < sExtraStaticModules->Length(); ++i) {
-    RegisterModule((*sExtraStaticModules)[i], nullptr);
+    RegisterModule((*sExtraStaticModules)[i]);
   }
 
   bool loadChromeManifests = (XRE_GetProcessType() != GeckoProcessType_GPU);
   if (loadChromeManifests) {
     // The overall order in which chrome.manifests are expected to be treated
     // is the following:
     // - greDir
     // - greDir's omni.ja
@@ -516,45 +516,33 @@ AsLiteralCString(const char* aStr)
   AssertNotStackAllocated(aStr);
 
   nsCString str;
   str.AssignLiteral(aStr, strlen(aStr));
   return str;
 }
 
 void
-nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule,
-                                       FileLocation* aFile)
+nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule)
 {
   mLock.AssertNotCurrentThreadOwns();
 
   if (aModule->mVersion >= kModuleVersionWithSelector &&
       !ProcessSelectorMatches(aModule->selector))
   {
     return;
   }
 
   {
     // Scope the monitor so that we don't hold it while calling into the
     // category manager.
     MutexLock lock(mLock);
 
-    KnownModule* m;
-    if (aFile) {
-      nsCString uri;
-      aFile->GetURIString(uri);
-      NS_ASSERTION(!mKnownModules.Get(uri),
-                   "Must not register a binary module twice.");
-
-      m = new KnownModule(aModule, *aFile);
-      mKnownModules.Put(uri, m);
-    } else {
-      m = new KnownModule(aModule);
-      mKnownStaticModules.AppendElement(m);
-    }
+    KnownModule* m = new KnownModule(aModule);
+    mKnownStaticModules.AppendElement(m);
 
     if (aModule->mCIDs) {
       const mozilla::Module::CIDEntry* entry;
       for (entry = aModule->mCIDs; entry->cid; ++entry) {
         RegisterCIDEntryLocked(entry, m);
       }
     }
 
@@ -1943,18 +1931,17 @@ EXPORT_XPCOM_API(nsresult)
 XRE_AddStaticComponent(const mozilla::Module* aComponent)
 {
   nsComponentManagerImpl::InitializeStaticModules();
   sExtraStaticModules->AppendElement(aComponent);
 
   if (nsComponentManagerImpl::gComponentManager &&
       nsComponentManagerImpl::NORMAL ==
         nsComponentManagerImpl::gComponentManager->mStatus) {
-    nsComponentManagerImpl::gComponentManager->RegisterModule(aComponent,
-                                                              nullptr);
+    nsComponentManagerImpl::gComponentManager->RegisterModule(aComponent);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComponentManagerImpl::AddBootstrappedManifestLocation(nsIFile* aLocation)
 {
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -193,24 +193,16 @@ public:
   static nsTArray<ComponentLocation>* sModuleLocations;
 
   class KnownModule
   {
   public:
     /**
      * Static or binary module.
      */
-    KnownModule(const mozilla::Module* aModule, mozilla::FileLocation& aFile)
-      : mModule(aModule)
-      , mFile(aFile)
-      , mLoaded(false)
-      , mFailed(false)
-    {
-    }
-
     explicit KnownModule(const mozilla::Module* aModule)
       : mModule(aModule)
       , mLoaded(false)
       , mFailed(false)
     {
     }
 
     explicit KnownModule(mozilla::FileLocation& aFile)
@@ -250,18 +242,17 @@ public:
 
   // The KnownModule is kept alive by these members, it is
   // referenced by pointer from the factory entries.
   nsTArray<nsAutoPtr<KnownModule>> mKnownStaticModules;
   // The key is the URI string of the module
   nsClassHashtable<nsCStringHashKey, KnownModule> mKnownModules;
 
   // Mutex not held
-  void RegisterModule(const mozilla::Module* aModule,
-                      mozilla::FileLocation* aFile);
+  void RegisterModule(const mozilla::Module* aModule);
 
 
   // Mutex held
   void RegisterCIDEntryLocked(const mozilla::Module::CIDEntry* aEntry,
                               KnownModule* aModule);
   void RegisterContractIDLocked(const mozilla::Module::ContractIDEntry* aEntry);
 
   // Mutex not held