Bug 1241561 - Convert addon-sdk to use .open2() (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2016-01-22 11:44:04 -08:00
parent 4ed97ebe1f
commit 26b22a9478
2 changed files with 8 additions and 12 deletions

View File

@ -26,6 +26,8 @@ const appInfo = Cc["@mozilla.org/xre/app-info;1"].
const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
getService(Ci.nsIVersionComparator);
const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
@ -48,18 +50,12 @@ function setResourceSubstitution(domain, uri) {
// Utility function that synchronously reads local resource from the given
// `uri` and returns content string.
function readURI(uri) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(uri, 'UTF-8'),
loadUsingSystemPrincipal: true
});
let channel = ioservice.newChannel2(uri,
'UTF-8',
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let stream = channel.open();
let stream = channel.open2();
let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
createInstance(Ci.nsIConverterInputStream);

View File

@ -81,7 +81,7 @@ function readURISync(uri, charset) {
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(uri, charset),
loadUsingSystemPrincipal: true});
let stream = channel.open();
let stream = channel.open2();
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, { charset : charset });