Bug 1363482: Part 5 - Preload component manifests off-thread during startup. r=erahm
authorKris Maglione <maglione.k@gmail.com>
Fri, 12 May 2017 17:55:47 -0700
changeset 427914 b4a57caae7d31696b3605daf24f385a5f20ecf24
parent 427913 807cf55e7f45c4a65d573d976b41e0c4c5a2f3e6
child 427915 1f5bed26622ab351107afa822a7218d6603deec6
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1363482
milestone57.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 1363482: Part 5 - Preload component manifests off-thread during startup. r=erahm MozReview-Commit-ID: 2BTkf2C5tMI
xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -44,16 +44,17 @@
 
 #include "mozilla/GenericFactory.h"
 #include "nsSupportsPrimitives.h"
 #include "nsArray.h"
 #include "nsIMutableArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsStringEnumerator.h"
 #include "mozilla/FileUtils.h"
+#include "mozilla/URLPreloader.h"
 #include "mozilla/UniquePtr.h"
 #include "nsDataHashtable.h"
 
 #include <new>     // for placement new
 
 #include "mozilla/Omnijar.h"
 
 #include "mozilla/Logging.h"
@@ -533,30 +534,22 @@ CutExtension(nsCString& aPath)
 
 static void
 DoRegisterManifest(NSLocationType aType,
                    FileLocation& aFile,
                    bool aChromeOnly,
                    bool aXPTOnly)
 {
   MOZ_ASSERT(!aXPTOnly || !nsComponentManagerImpl::gComponentManager);
-  uint32_t len;
-  FileLocation::Data data;
-  UniquePtr<char[]> buf;
-  nsresult rv = aFile.GetData(data);
-  if (NS_SUCCEEDED(rv)) {
-    rv = data.GetSize(&len);
-  }
-  if (NS_SUCCEEDED(rv)) {
-    buf = MakeUnique<char[]>(len + 1);
-    rv = data.Copy(buf.get(), len);
-  }
-  if (NS_SUCCEEDED(rv)) {
-    buf[len] = '\0';
-    ParseManifest(aType, aFile, buf.get(), aChromeOnly, aXPTOnly);
+
+  auto result = URLPreloader::Read(aFile);
+  if (result.isOk()) {
+    nsCString buf(result.unwrap());
+
+    ParseManifest(aType, aFile, buf.BeginWriting(), aChromeOnly, aXPTOnly);
   } else if (NS_BOOTSTRAPPED_LOCATION != aType) {
     nsCString uri;
     aFile.GetURIString(uri);
     LogMessage("Could not read chrome manifest '%s'.", uri.get());
   }
 }
 
 void