Bug 1243936 - Convert remaining callsites within devtools/ and toolkit/ to use channel.open2()

This commit is contained in:
Christoph Kerschbaumer 2016-01-29 09:16:13 -08:00
parent c71b5c6b4f
commit 12a3f8477f
4 changed files with 13 additions and 20 deletions

View File

@ -26,7 +26,7 @@ function getDefaultSettings() {
let chan = NetUtil.newChannel({ let chan = NetUtil.newChannel({
uri: NetUtil.newURI(settingsFile), uri: NetUtil.newURI(settingsFile),
loadUsingSystemPrincipal: true}); loadUsingSystemPrincipal: true});
let stream = chan.open(); let stream = chan.open2();
// Obtain a converter to read from a UTF-8 encoded input stream. // Obtain a converter to read from a UTF-8 encoded input stream.
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"] let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter); .createInstance(Ci.nsIScriptableUnicodeConverter);

View File

@ -273,7 +273,7 @@ var AboutProtocolParent = {
} else { } else {
channel.loadGroup = null; channel.loadGroup = null;
} }
let stream = channel.open(); let stream = channel.open2();
let data = NetUtil.readInputStreamToString(stream, stream.available(), {}); let data = NetUtil.readInputStreamToString(stream, stream.available(), {});
return { return {
data: data, data: data,

View File

@ -53,18 +53,14 @@ function run_test() {
engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml"); engineTemplateFile.copyTo(engineFile.parent, "test-search-engine.xml");
// The list of visibleDefaultEngines needs to match or the cache will be ignored. // The list of visibleDefaultEngines needs to match or the cache will be ignored.
let chan = NetUtil.ioService.newChannel2("resource://search-plugins/list.txt", let chan = NetUtil.newChannel({
null, // aOriginCharset uri: "resource://search-plugins/list.txt",
null, // aBaseURI loadUsingSystemPrincipal: true
null, // aLoadingNode });
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let visibleDefaultEngines = []; let visibleDefaultEngines = [];
let sis = Cc["@mozilla.org/scriptableinputstream;1"]. let sis = Cc["@mozilla.org/scriptableinputstream;1"].
createInstance(Ci.nsIScriptableInputStream); createInstance(Ci.nsIScriptableInputStream);
sis.init(chan.open()); sis.init(chan.open2());
let list = sis.read(sis.available()); let list = sis.read(sis.available());
let names = list.split("\n").filter(n => !!n); let names = list.split("\n").filter(n => !!n);
for (let name of names) { for (let name of names) {

View File

@ -131,16 +131,13 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "Locale", function() {
let channel; let channel;
let locale; let locale;
for (let res of ['app', 'gre']) { for (let res of ['app', 'gre']) {
channel = Services.io.newChannel2("resource://" + res + "/" + FILE_UPDATE_LOCALE, channel = NetUtil.newChannel({
null, uri: "resource://" + res + "/" + FILE_UPDATE_LOCALE,
null, contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST,
null, // aLoadingNode loadUsingSystemPrincipal: true
Services.scriptSecurityManager.getSystemPrincipal(), });
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST);
try { try {
let inputStream = channel.open(); let inputStream = channel.open2();
locale = NetUtil.readInputStreamToString(inputStream, inputStream.available()); locale = NetUtil.readInputStreamToString(inputStream, inputStream.available());
} catch(e) {} } catch(e) {}
if (locale) if (locale)