Bug 1348981 - add Cu.readURI helper for sync file reading on startup r=kmag
authorRobert Helmer <rhelmer@mozilla.com>
Tue, 19 Sep 2017 12:13:08 -0700
changeset 384589 f89549271025072552c1e6fcecb792b367b3d02a
parent 384588 5ead3eb427c78aff76aba9bba21df9142a421901
child 384590 388768fdc403a256ebdf8a9513586cae0937dbb3
push id32631
push userarchaeopteryx@coole-files.de
push dateThu, 05 Oct 2017 08:51:33 +0000
treeherdermozilla-central@66042a706980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1348981
milestone58.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 1348981 - add Cu.readURI helper for sync file reading on startup r=kmag MozReview-Commit-ID: 1yz25afCUDs
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -10,16 +10,17 @@
 %}
 
 interface xpcIJSWeakReference;
 interface nsIAddonInterposition;
 interface nsIClassInfo;
 interface nsIComponentManager;
 interface nsICycleCollectorListener;
 interface nsIFile;
+interface nsIURI;
 interface nsIJSCID;
 interface nsIJSIID;
 interface nsIPrincipal;
 interface nsIStackFrame;
 
 /**
 * interface of Components.interfacesByID
 * (interesting stuff only reflected into JavaScript)
@@ -696,16 +697,22 @@ interface nsIXPCComponents_Utils : nsISu
     double now();
 
     /*
      * Reads the given file and returns its contents. If called during early
      * startup, the file will be pre-read on a background thread during profile
      * startup so its contents will be available the next time they're read.
      */
     ACString readFile(in nsIFile file);
+
+    /*
+     * Reads the given local file URL and returns its contents. This has the
+     * same semantics of readFile.
+     */
+    ACString readURI(in nsIURI url);
 };
 
 /**
 * Interface for the 'Components' object.
 *
 * The first interface contains things that are available to non-chrome XBL code
 * that runs in a scope with an ExpandedPrincipal. The second interface
 * includes members that are only exposed to chrome.
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3393,16 +3393,25 @@ nsXPCComponents_Utils::ReadFile(nsIFile*
 {
     NS_ENSURE_TRUE(aFile, NS_ERROR_INVALID_ARG);
 
     MOZ_TRY_VAR(aResult, URLPreloader::ReadFile(aFile));
     return NS_OK;
 }
 
 NS_IMETHODIMP
+nsXPCComponents_Utils::ReadURI(nsIURI* aURI, nsACString& aResult)
+{
+    NS_ENSURE_TRUE(aURI, NS_ERROR_INVALID_ARG);
+
+    MOZ_TRY_VAR(aResult, URLPreloader::ReadURI(aURI));
+    return NS_OK;
+}
+
+NS_IMETHODIMP
 nsXPCComponents_Utils::Now(double* aRetval)
 {
     TimeStamp start = TimeStamp::ProcessCreation();
     *aRetval = (TimeStamp::Now() - start).ToMilliseconds();
     return NS_OK;
 }
 
 /***************************************************************************/