Bug 695843 part 2 - Avoid code duplication for components manifest registration. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 08 Dec 2011 11:03:36 +0100
changeset 82244 8e345e9d93e9b2cd2d3cce19f76e33ca38dbcff8
parent 82243 a31949628a7e971ecef6d25aca4bc633f3d4cfd4
child 82245 3032fd2bd96a5afe71c8e73b627c6bc97465bc9d
push id21587
push userbmo@edmorley.co.uk
push dateThu, 08 Dec 2011 15:13:43 +0000
treeherdermozilla-central@98db2311a44c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs695843
milestone11.0a1
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
Bug 695843 part 2 - Avoid code duplication for components manifest registration. r=bsmedberg
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -394,28 +394,17 @@ nsresult nsComponentManagerImpl::Init()
     nsCOMPtr<nsIFile> greOmnijar = mozilla::Omnijar::GetPath(mozilla::Omnijar::GRE);
     if (greOmnijar) {
         cl = sModuleLocations->InsertElementAt(0);
         cl->type = NS_COMPONENT_LOCATION;
         cl->location = do_QueryInterface(greOmnijar);
         cl->jar = true;
     }
 
-    for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
-        ComponentLocation& l = sModuleLocations->ElementAt(i);
-        if (!l.jar) {
-            RegisterManifestFile(l.type, l.location, false);
-            continue;
-        }
-
-        nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv);
-        rv = reader->Open(l.location);
-        if (NS_SUCCEEDED(rv))
-            RegisterJarManifest(l.type, reader, "chrome.manifest", false);
-    }
+    RereadChromeManifests(false);
 
     nsCategoryManager::GetSingleton()->SuppressNotifications(false);
 
     mStatus = NORMAL;
 
     return NS_OK;
 }
 
@@ -897,31 +886,31 @@ nsComponentManagerImpl::ManifestCategory
     char* key = argv[1];
     char* value = argv[2];
 
     nsCategoryManager::GetSingleton()->
         AddCategoryEntry(category, key, value);
 }
 
 void
-nsComponentManagerImpl::RereadChromeManifests()
+nsComponentManagerImpl::RereadChromeManifests(bool aChromeOnly)
 {
     for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
         ComponentLocation& l = sModuleLocations->ElementAt(i);
         if (!l.jar) {
-            RegisterManifestFile(l.type, l.location, true);
+            RegisterManifestFile(l.type, l.location, aChromeOnly);
             continue;
         }
 
         nsresult rv;
         nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv);
         if (NS_SUCCEEDED(rv))
             rv = reader->Open(l.location);
         if (NS_SUCCEEDED(rv))
-            RegisterJarManifest(l.type, reader, "chrome.manifest", true);
+            RegisterJarManifest(l.type, reader, "chrome.manifest", aChromeOnly);
     }
 }
 
 bool
 nsComponentManagerImpl::KnownModule::EnsureLoader()
 {
     if (!mLoader) {
         nsCString extension;
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -294,17 +294,17 @@ public:
 
     void ManifestManifest(ManifestProcessingContext& cx, int lineno, char *const * argv);
     void ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv);
     void ManifestXPT(ManifestProcessingContext& cx, int lineno, char *const * argv);
     void ManifestComponent(ManifestProcessingContext& cx, int lineno, char *const * argv);
     void ManifestContract(ManifestProcessingContext& cx, int lineno, char* const * argv);
     void ManifestCategory(ManifestProcessingContext& cx, int lineno, char* const * argv);
 
-    void RereadChromeManifests();
+    void RereadChromeManifests(bool aChromeOnly = true);
 
     // Shutdown
     enum {
         NOT_INITIALIZED,
         NORMAL,
         SHUTDOWN_IN_PROGRESS,
         SHUTDOWN_COMPLETE
     } mStatus;