Implement RereadChromeManifests for bug 568691.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 22 Jun 2010 16:24:01 -0400
changeset 47025 f3c81f5a28ff48b70bbc99ac5a02e29627f249f4
parent 47024 bcb07835feedc5628db11f4d10455e3b9ff78d9f
child 47026 d64e3c36f1b74565d07d4178edd314d7a272af98
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs568691
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Implement RereadChromeManifests for bug 568691.
xpcom/components/ManifestParser.cpp
xpcom/components/ManifestParser.h
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -327,17 +327,18 @@ CheckVersionFlag(const nsString& aFlag, 
     else
       aResult = eBad;
   }
 
   return true;
 }
 
 void
-ParseManifest(NSLocationType aType, nsILocalFile* aFile, char* buf)
+ParseManifest(NSLocationType aType, nsILocalFile* aFile, char* buf,
+              bool aChromeOnly)
 {
   nsresult rv;
 
   nsComponentManagerImpl::ManifestProcessingContext mgrcx(aType, aFile);
   nsChromeRegistry::ManifestProcessingContext chromecx(aType, aFile);
 
   NS_NAMED_LITERAL_STRING(kPlatform, "platform");
   NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
@@ -473,13 +474,13 @@ ParseManifest(NSLocationType aType, nsIL
           LogMessageWithContext(aFile, line, "Chrome registry isn't available yet.");
           continue;
         }
       }
 
       (nsChromeRegistry::gChromeRegistry->*(directive->regfunc))
 	(chromecx, line, argv, platform, contentAccessible);
     }
-    else
+    else if (!aChromeOnly)
       (nsComponentManagerImpl::gComponentManager->*(directive->mgrfunc))
 	(mgrcx, line, argv);
   }
 }
--- a/xpcom/components/ManifestParser.h
+++ b/xpcom/components/ManifestParser.h
@@ -38,11 +38,12 @@
 #ifndef ManifestParser_h
 #define ManifestParser_h
 
 #include "nsComponentManager.h"
 #include "nsChromeRegistry.h"
 
 class nsILocalFile;
 
-void ParseManifest(NSLocationType type, nsILocalFile* file, char* buf);
+void ParseManifest(NSLocationType type, nsILocalFile* file, char* buf,
+                   bool aChromeOnly);
 
 #endif // ManifestParser_h
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -398,17 +398,17 @@ nsresult nsComponentManagerImpl::Init()
 
     RegisterModule(&kXPCOMModule, NULL);
 
     for (PRUint32 i = 0; i < sStaticModules->Length(); ++i)
         RegisterModule((*sStaticModules)[i], NULL);
 
     for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
         ComponentLocation& l = sModuleLocations->ElementAt(i);
-        RegisterLocation(l.type, l.location);
+        RegisterLocation(l.type, l.location, false);
     }
 
     nsCategoryManager::GetSingleton()->SuppressNotifications(false);
 
     mStatus = NORMAL;
 
     return NS_OK;
 }
@@ -479,50 +479,52 @@ nsComponentManagerImpl::RegisterContract
         return;
     }
 
     mContractIDs.Put(nsDependentCString(aEntry->contractid), f);
 }
 
 void
 nsComponentManagerImpl::RegisterLocation(NSLocationType aType,
-                                         nsILocalFile* aLocation)
+                                         nsILocalFile* aLocation,
+                                         bool aChromeOnly)
 {
     nsCOMArray<nsILocalFile> manifests;
 
     PRBool directory = PR_FALSE;
     aLocation->IsDirectory(&directory);
     if (directory)
-        RegisterDirectory(aType, aLocation, manifests);
+        RegisterDirectory(aType, aLocation, manifests, aChromeOnly);
     else
-        RegisterFile(aType, aLocation, manifests);
+        RegisterFile(aType, aLocation, manifests, aChromeOnly);
 
     for (PRInt32 i = 0; i < manifests.Count(); ++i)
-        RegisterManifestFile(aType, manifests[i]);
+        RegisterManifestFile(aType, manifests[i], aChromeOnly);
 }
 
 void
 nsComponentManagerImpl::RegisterDirectory(NSLocationType aType,
                                           nsILocalFile* aDirectory,
-                                          nsCOMArray<nsILocalFile>& aManifests)
+                                          nsCOMArray<nsILocalFile>& aManifests,
+                                          bool aChromeOnly)
 {
     nsCOMPtr<nsISimpleEnumerator> entries;
     aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
     if (!entries)
         return;
 
     PRBool more;
     while (NS_SUCCEEDED(entries->HasMoreElements(&more)) && more) {
         nsCOMPtr<nsISupports> supp;
         entries->GetNext(getter_AddRefs(supp));
         nsCOMPtr<nsILocalFile> f = do_QueryInterface(supp);
         if (!f)
             continue;
 
-        RegisterFile(aType, f, aManifests);
+        RegisterFile(aType, f, aManifests, aChromeOnly);
     }
 }
 
 static void
 GetExtension(nsILocalFile* file, nsCString& extension)
 {
     file->GetNativePath(extension);
 
@@ -531,22 +533,23 @@ GetExtension(nsILocalFile* file, nsCStri
         extension.Truncate();
     else
         extension.Cut(0, dotPos + 1);
 }
 
 void
 nsComponentManagerImpl::RegisterFile(NSLocationType aType,
                                      nsILocalFile* aFile,
-                                     nsCOMArray<nsILocalFile>& aManifests)
+                                     nsCOMArray<nsILocalFile>& aManifests,
+                                     bool aChromeOnly)
 {
     nsCString extension;
     GetExtension(aFile, extension);
 
-    if (NS_COMPONENT_LOCATION == aType) {
+    if (NS_COMPONENT_LOCATION == aType && !aChromeOnly) {
         if (extension.EqualsLiteral("xpt")) {
             xptiInterfaceInfoManager::GetSingleton()
                 ->RegisterFile(aFile,
                                xptiInterfaceInfoManager::XPT);
         }
         else if (extension.EqualsLiteral("jar")) {
             xptiInterfaceInfoManager::GetSingleton()
                 ->RegisterFile(aFile,
@@ -579,17 +582,18 @@ struct AutoCloseFD
 
     PRFileDesc* mFD;
 };
 
 } // anonymous namespace
 
 void
 nsComponentManagerImpl::RegisterManifestFile(NSLocationType aType,
-                                             nsILocalFile* aFile)
+                                             nsILocalFile* aFile,
+                                             bool aChromeOnly)
 {
     nsresult rv;
 
     AutoCloseFD fd;
     rv = aFile->OpenNSPRFileDesc(PR_RDONLY, 0444, &fd);
     if (NS_FAILED(rv))
         return;
 
@@ -605,17 +609,17 @@ nsComponentManagerImpl::RegisterManifest
     for (PRInt32 totalRead = 0; totalRead < fileInfo.size; ) {
         PRInt32 read = PR_Read(fd, data + totalRead, PRInt32(fileInfo.size));
         if (read < 0)
             return;
         totalRead += read;
     }
 
     data[fileInfo.size] = '\0';
-    ParseManifest(aType, aFile, data);
+    ParseManifest(aType, aFile, data, aChromeOnly);
 }
 
 void
 nsComponentManagerImpl::ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv)
 {
     char* file = argv[0];
 
     nsCOMPtr<nsIFile> cfile;
@@ -717,17 +721,20 @@ nsComponentManagerImpl::ManifestCategory
 
     nsCategoryManager::GetSingleton()->
         AddCategoryEntry(category, key, value);
 }
 
 void
 nsComponentManagerImpl::RereadChromeManifests()
 {
-    NS_ERROR("XXX Not done!");
+    for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
+        ComponentLocation& l = sModuleLocations->ElementAt(i);
+        RegisterLocation(l.type, l.location, true);
+    }
 }
 
 bool
 nsComponentManagerImpl::KnownModule::EnsureLoader()
 {
     if (!mLoader) {
         nsCString extension;
         GetExtension(mFile, extension);
@@ -1715,12 +1722,12 @@ XRE_AddComponentLocation(NSLocationType 
     nsComponentManagerImpl::InitializeModuleLocations();
     nsComponentManagerImpl::ComponentLocation* c = 
         nsComponentManagerImpl::sModuleLocations->AppendElement();
     c->type = aType;
     c->location = aLocation;
 
     if (nsComponentManagerImpl::gComponentManager &&
         nsComponentManagerImpl::NORMAL == nsComponentManagerImpl::gComponentManager->mStatus)
-        nsComponentManagerImpl::gComponentManager->RegisterLocation(aType, aLocation);
+        nsComponentManagerImpl::gComponentManager->RegisterLocation(aType, aLocation, false);
 
     return NS_OK;
 }
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -220,27 +220,31 @@ public:
     nsClassHashtable<nsHashableHashKey, KnownModule> mKnownFileModules;
 
     void RegisterModule(const mozilla::Module* aModule,
                         nsILocalFile* aFile);
     void RegisterCIDEntry(const mozilla::Module::CIDEntry* aEntry,
                           KnownModule* aModule);
     void RegisterContractID(const mozilla::Module::ContractIDEntry* aEntry);
 
-    void RegisterLocation(NSLocationType aType, nsILocalFile* aLocation);
+    void RegisterLocation(NSLocationType aType, nsILocalFile* aLocation,
+                          bool aChromeOnly);
 
     // Register XPT/XPTJAR files, and fills aManifests with .manifest
     // files, which must be registered after all DLLs so that networking is
     // registered.
     void RegisterDirectory(NSLocationType aType, nsILocalFile* aDirectory,
-                           nsCOMArray<nsILocalFile>& aManifests);
+                           nsCOMArray<nsILocalFile>& aManifests,
+                           bool aChromeOnly);
     void RegisterFile(NSLocationType aType, nsILocalFile* aFile,
-                      nsCOMArray<nsILocalFile>& aManifests);
+                      nsCOMArray<nsILocalFile>& aManifests,
+                      bool aChromeOnly);
 
-    void RegisterManifestFile(NSLocationType aType, nsILocalFile* aFile);
+    void RegisterManifestFile(NSLocationType aType, nsILocalFile* aFile,
+                              bool aChromeOnly);
 
     struct ManifestProcessingContext
     {
         ManifestProcessingContext(NSLocationType aType, nsILocalFile* aFile)
             : mType(aType)
             , mFile(aFile)
         { }
         ~ManifestProcessingContext() { }