Bug 1348981 - add Cu.readURI helper for sync file reading on startup r=kmag

MozReview-Commit-ID: 1yz25afCUDs

--HG--
extra : rebase_source : 549e28b7ceeb6556156d8f6e4d2a7470852d64c0
This commit is contained in:
Robert Helmer 2017-09-19 12:13:08 -07:00
parent f0cf406637
commit cb1aad0897
2 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,7 @@ interface nsIClassInfo;
interface nsIComponentManager;
interface nsICycleCollectorListener;
interface nsIFile;
interface nsIURI;
interface nsIJSCID;
interface nsIJSIID;
interface nsIPrincipal;
@ -701,6 +702,12 @@ interface nsIXPCComponents_Utils : nsISupports
* 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);
};
/**

View File

@ -3397,6 +3397,15 @@ nsXPCComponents_Utils::ReadFile(nsIFile* aFile, nsACString& aResult)
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)
{